class UC3::TestClient
Identify routes for Consistency Checks and for Unit Testing
Constants
- CONSIS_QUERIES
Attributes
Public Class Methods
Source
# File app/lib/client/uc3_client.rb, line 406 def self.client UC3::UC3Client.clients.fetch(self.class.to_s, TestClient.new) end
Source
# File app/lib/client/uc3_client.rb, line 312 def initialize super(enabled: true) @test_paths = [] @consistency_checks = [] UC3Query::QueryClient.client.queries.each do |name, query| next if query.fetch(:update, false) || query.fetch(:non_report, false) || query.fetch(:test_skip, false) name = name.to_s CONSIS_QUERIES.each do |pattern| next if name =~ %r{/objlist} @consistency_checks << name if name =~ /#{pattern}/ end next if name =~ %r{/objlist} @test_paths << name unless @consistency_checks.include?(name) query.fetch(:unit_tests, []).each do |params| @test_paths << "#{name}#{params}" end end # These GET operations require specific url parameters that are not readily available for a unit test # Also, these tests are not activated for every stack. skiplist = %w[ /ops/storage/manifest /ops/storage/manifest-yaml /ops/storage/ingest-checkm /ops/storage/benchmark-fixity /ops/storage/benchmark-fixity-nodes /ops/storage/benchmark-fixity-audit /ops/storage/benchmark-fixity-access ] # These GET operations require specific url parameters that are not readily available for a unit test # Also, these tests are not activated for every stack. if AdminUI::TopMenu.instance.skip_paths.include?('/ops/zk/ingest/jobs-by-collection') skiplist += %w[ /ops/zk/ingest/jobs-by-collection/filtered /ops/zk/ingest/jobs-by-collection-and-batch/filtered ] end # These GET operations require specific url parameters that are not readily available for a unit test # Also, these tests are not activated for every stack. if AdminUI::TopMenu.instance.skip_paths.include?('/ops/zk/nodes') skiplist += %w[ /ops/zk/nodes/node-names ] end Sinatra::Application.routes['GET'].each do |path, route| # .each_keys does not work, so make use of route object puts "Route #{path}: #{route.inspect}" unless route.empty? path = path.to_s next if path.include?('**') next if path.include?('*/*') if skiplist.include?(path) # skip from unit tests elsif AdminUI::TopMenu.instance.skip_paths.include?(path) # skip from unit tests elsif path.include?('*') if path.start_with?('/source/') UC3Code::SourceCodeClient.client.reponames.each do |repo| next if %w[ui admintool].include?(repo.to_s) && path.include?('artifacts') next if %w[core core-bom core-parprop cloud zk].include?(repo.to_s) && path.include?('images') next if %w[core-bom core-parprop].include?(repo.to_s) && path.include?('tags') rpath = path.gsub('*', repo.to_s) @test_paths << rpath unless AdminUI::TopMenu.instance.skip_paths.include?(rpath) end end else @test_paths << path # TODO: SSM documentation %w[ /ldap/collections-missing /ops/zk/access/jobs /ops/zk/ingest/jobs-by-collection /ops/zk/ingest/batches /ops/zk/nodes/orphan /ops/ingest-folders/list ].each do |pattern| @consistency_checks << path if path =~ /#{pattern}/ end end end @test_paths = @test_paths.uniq.sort @consistency_checks = @consistency_checks.uniq.sort end
Calls superclass method
UC3::UC3Client::new