diff --git a/devops-service/Gemfile.lock b/devops-service/Gemfile.lock index 452a513..8a53856 100644 --- a/devops-service/Gemfile.lock +++ b/devops-service/Gemfile.lock @@ -80,7 +80,7 @@ GEM moneta (0.6.0) mongo (1.9.2) bson (~> 1.9.2) - multi_json (1.8.4) + multi_json (1.7.8) multi_test (0.1.1) net-scp (1.1.2) net-ssh (>= 2.6.5) @@ -168,9 +168,9 @@ DEPENDENCIES mime-types (~> 1.25.1) mixlib-shellout mongo - multi_json + multi_json (= 1.7.8) rufus-scheduler (= 2.0.24) - sidekiq + sidekiq (= 3.2.6) sinatra (= 1.4.3) sinatra-contrib (= 1.4.1) sinatra-websocket (~> 0.3.0) diff --git a/devops-service/tests/features/api_v2/00_list/flavor.feature b/devops-service/tests/features/api_v2/00_list/flavor.feature deleted file mode 100644 index 92a5aba..0000000 --- a/devops-service/tests/features/api_v2/00_list/flavor.feature +++ /dev/null @@ -1,64 +0,0 @@ -@flavor -Feature: Flavors - - @openstack - Scenario: Get list of openstack flavors - When I send GET '/v2.0/flavors/openstack' query - Then response should be '200' - And the Content-Type header should include 'application/json' - And the JSON response should be an array - And response array should contains elements like: - """ - [ - { - "id": "flavor_id", - "v_cpus": "v_cpus", - "ram": "ram", - "disk": "disk" - } - ] - """ - - @ec2 - Scenario: Get list of ec2 flavors - When I send GET '/v2.0/flavors/ec2' query - Then response should be '200' - And the Content-Type header should include 'application/json' - And the JSON response should be an array - And response array should contains elements like: - """ - [ - { - "id": "t1.micro", - "cores": 2, - "disk": 0, - "name": "Micro Instance", - "ram": 613 - } - ] - """ - - @static - Scenario: Get list of static flavors - When I send GET '/v2.0/flavors/static' query - Then response should be '200' - And the Content-Type header should include 'application/json' - And the JSON response should be an array - And response array should be empty - - @static - Scenario: Get flavors list of static provider without 'Accept' header - When I send GET '/v2.0/flavors/static' query without headers 'Accept' - Then response should be '406' - - Scenario: Get flavors list of unknown provider - When I send GET '/v2.0/flavors/foo' query - Then response should be '404' - - Scenario: Get flavors list of unknown provider without 'Accept' header - When I send GET '/v2.0/flavors/foo' query without headers 'Accept' - Then response should be '406' - - Scenario: Get flavors list of unknown provider without privileges - When I send GET '/v2.0/flavors/foo' query with user without privileges - Then response should be '401' diff --git a/devops-service/tests/generate_tests.rb b/devops-service/tests/generate_tests.rb index f268bfc..bd4eced 100755 --- a/devops-service/tests/generate_tests.rb +++ b/devops-service/tests/generate_tests.rb @@ -15,18 +15,43 @@ class Generator < OpenStruct super(:config => @config) end - def make_tests_config + def configure! c = {} %w{host port username password path_prefix username_without_privileges password_without_privileges}.each do |key| c[key] = @config[key] end File.open(TESTS_CONFIG, "w") {|f| f.write(c.to_yaml) } + self end + def generate!(templates) + templates.each do |input, output| + if File.exists?(input) + data = render(File.read(input)) + dir = File.dirname(output) + FileUtils.mkdir_p(dir) unless File.exists?(dir) + File.open(output, "w") {|f| f.write(data)} + else + puts "WARN: file '#{input}' does not exist" + end + end + end + + def clean!(feature_files) + feature_files.each do |feature_file| + if File.exists?(feature_file) + FileUtils.rm(feature_file) + else + puts "WARN: file '#{feature_file}' does not exist" + end + end + end + + private + def render(template) ERB.new(template).result(binding) end - end templates = { @@ -54,16 +79,12 @@ templates = { "templates/api_v2/90_delete/90_user.feature.erb" => "features/api_v2/90_delete/90_user.feature" } -generator = Generator.new -generator.make_tests_config -templates.each do |input, output| - if File.exists?(input) - data = generator.render(File.read(input)) - dir = File.dirname(output) - FileUtils.mkdir_p(dir) unless File.exists?(dir) - File.open(output, "w") {|f| f.write(data)} - else - puts "WARN: file '#{input}' does not exist" - end +generator = Generator.new.configure! +if ARGV.first != 'clean' + generator.generate!(templates) +else + generator.clean!(templates.values) end + +