tests generator
This commit is contained in:
parent
a6f5a6b4bf
commit
c3ec9f31f2
14
devops-service/tests/config.yml
Normal file
14
devops-service/tests/config.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
openstack:
|
||||||
|
flavor: "as_long_as_image"
|
||||||
|
image: "08093b30-8393-42c3-8fb3-c4df56deb967"
|
||||||
|
project:
|
||||||
|
name: "test_openstack"
|
||||||
|
env: "test"
|
||||||
|
|
||||||
|
ec2:
|
||||||
|
flavor: "m1.small"
|
||||||
|
image: "ami-63071b0a"
|
||||||
|
project:
|
||||||
|
name: "test_ec2"
|
||||||
|
env: "test"
|
||||||
32
devops-service/tests/generate_tests.rb
Executable file
32
devops-service/tests/generate_tests.rb
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
#
|
||||||
|
require "erb"
|
||||||
|
require "yaml"
|
||||||
|
require "ostruct"
|
||||||
|
|
||||||
|
class Generator
|
||||||
|
|
||||||
|
CONFIG = "config.yml"
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
@config = YAML.load_file(File.new(CONFIG))
|
||||||
|
end
|
||||||
|
|
||||||
|
def render(template)
|
||||||
|
ERB.new(template).result(binding)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
templates = {
|
||||||
|
"templates/00_list/flavor.feature.erb" => "flavor.feature"
|
||||||
|
}
|
||||||
|
generator = Generator.new
|
||||||
|
|
||||||
|
templates.each do |input, output|
|
||||||
|
if File.exists?(input)
|
||||||
|
data = generator.render(File.read(input))
|
||||||
|
File.open(output, "w") {|f| f.write(data)}
|
||||||
|
else
|
||||||
|
puts "WARN: file '#{input}' does not exist"
|
||||||
|
end
|
||||||
|
end
|
||||||
64
devops-service/tests/templates/00_list/flavor.feature.erb
Normal file
64
devops-service/tests/templates/00_list/flavor.feature.erb
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
@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'
|
||||||
Loading…
Reference in New Issue
Block a user