Merge "Migrate test_load_balancer_basic to tempest client"
diff --git a/tempest/api/data_processing/base.py b/tempest/api/data_processing/base.py
index 65085b9..2ec1017 100644
--- a/tempest/api/data_processing/base.py
+++ b/tempest/api/data_processing/base.py
@@ -24,8 +24,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(BaseDataProcessingTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseDataProcessingTest, cls).resource_setup()
if not CONF.service_available.sahara:
raise cls.skipException('Sahara support is required')
@@ -43,7 +43,7 @@
cls._jobs = []
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.cleanup_resources(getattr(cls, '_cluster_templates', []),
cls.client.delete_cluster_template)
cls.cleanup_resources(getattr(cls, '_node_group_templates', []),
@@ -56,7 +56,7 @@
cls.cleanup_resources(getattr(cls, '_data_sources', []),
cls.client.delete_data_source)
cls.clear_isolated_creds()
- super(BaseDataProcessingTest, cls).tearDownClass()
+ super(BaseDataProcessingTest, cls).resource_cleanup()
@staticmethod
def cleanup_resources(resource_id_list, method):
diff --git a/tempest/api/data_processing/test_cluster_templates.py b/tempest/api/data_processing/test_cluster_templates.py
index ff67c1c..537f90c 100644
--- a/tempest/api/data_processing/test_cluster_templates.py
+++ b/tempest/api/data_processing/test_cluster_templates.py
@@ -22,9 +22,8 @@
sahara/restapi/rest_api_v1.0.html#cluster-templates
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ClusterTemplateTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(ClusterTemplateTest, cls).resource_setup()
# create node group template
node_group_template = {
'name': data_utils.rand_name('sahara-ng-template'),
diff --git a/tempest/api/data_processing/test_data_sources.py b/tempest/api/data_processing/test_data_sources.py
index aae56c4..3650751 100644
--- a/tempest/api/data_processing/test_data_sources.py
+++ b/tempest/api/data_processing/test_data_sources.py
@@ -19,8 +19,8 @@
class DataSourceTest(dp_base.BaseDataProcessingTest):
@classmethod
- def setUpClass(cls):
- super(DataSourceTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(DataSourceTest, cls).resource_setup()
cls.swift_data_source_with_creds = {
'url': 'swift://sahara-container.sahara/input-source',
'description': 'Test data source',
diff --git a/tempest/api/data_processing/test_job_binaries.py b/tempest/api/data_processing/test_job_binaries.py
index 15ee145..d006991 100644
--- a/tempest/api/data_processing/test_job_binaries.py
+++ b/tempest/api/data_processing/test_job_binaries.py
@@ -22,9 +22,8 @@
sahara/restapi/rest_api_v1.1_EDP.html#job-binaries
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(JobBinaryTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(JobBinaryTest, cls).resource_setup()
cls.swift_job_binary_with_extra = {
'url': 'swift://sahara-container.sahara/example.jar',
'description': 'Test job binary',
diff --git a/tempest/api/data_processing/test_job_binary_internals.py b/tempest/api/data_processing/test_job_binary_internals.py
index 45e1140..7e99867 100644
--- a/tempest/api/data_processing/test_job_binary_internals.py
+++ b/tempest/api/data_processing/test_job_binary_internals.py
@@ -22,8 +22,8 @@
sahara/restapi/rest_api_v1.1_EDP.html#job-binary-internals
"""
@classmethod
- def setUpClass(cls):
- super(JobBinaryInternalTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(JobBinaryInternalTest, cls).resource_setup()
cls.job_binary_internal_data = 'Some script may be data'
def _create_job_binary_internal(self, binary_name=None):
diff --git a/tempest/api/data_processing/test_jobs.py b/tempest/api/data_processing/test_jobs.py
index 8591dbd..5af2eef 100644
--- a/tempest/api/data_processing/test_jobs.py
+++ b/tempest/api/data_processing/test_jobs.py
@@ -22,9 +22,8 @@
sahara/restapi/rest_api_v1.1_EDP.html#jobs
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(JobTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(JobTest, cls).resource_setup()
# create job binary
job_binary = {
'name': data_utils.rand_name('sahara-job-binary'),
diff --git a/tempest/api/data_processing/test_node_group_templates.py b/tempest/api/data_processing/test_node_group_templates.py
index c2c0075..f3f59fc 100644
--- a/tempest/api/data_processing/test_node_group_templates.py
+++ b/tempest/api/data_processing/test_node_group_templates.py
@@ -19,8 +19,8 @@
class NodeGroupTemplateTest(dp_base.BaseDataProcessingTest):
@classmethod
- def setUpClass(cls):
- super(NodeGroupTemplateTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(NodeGroupTemplateTest, cls).resource_setup()
cls.node_group_template = {
'description': 'Test node group template',
'plugin_name': 'vanilla',
diff --git a/tempest/api/database/base.py b/tempest/api/database/base.py
index 6e0f431..c9f16ca 100644
--- a/tempest/api/database/base.py
+++ b/tempest/api/database/base.py
@@ -27,8 +27,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(BaseDatabaseTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseDatabaseTest, cls).resource_setup()
if not CONF.service_available.trove:
skip_msg = ("%s skipped as trove is not available" % cls.__name__)
raise cls.skipException(skip_msg)
diff --git a/tempest/api/database/flavors/test_flavors.py b/tempest/api/database/flavors/test_flavors.py
index a5c8caa..aed1abe 100644
--- a/tempest/api/database/flavors/test_flavors.py
+++ b/tempest/api/database/flavors/test_flavors.py
@@ -20,8 +20,8 @@
class DatabaseFlavorsTest(base.BaseDatabaseTest):
@classmethod
- def setUpClass(cls):
- super(DatabaseFlavorsTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(DatabaseFlavorsTest, cls).resource_setup()
cls.client = cls.database_flavors_client
@test.attr(type='smoke')
diff --git a/tempest/api/database/flavors/test_flavors_negative.py b/tempest/api/database/flavors/test_flavors_negative.py
index 202dc48..9f14cce 100644
--- a/tempest/api/database/flavors/test_flavors_negative.py
+++ b/tempest/api/database/flavors/test_flavors_negative.py
@@ -21,8 +21,8 @@
class DatabaseFlavorsNegativeTest(base.BaseDatabaseTest):
@classmethod
- def setUpClass(cls):
- super(DatabaseFlavorsNegativeTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(DatabaseFlavorsNegativeTest, cls).resource_setup()
cls.client = cls.database_flavors_client
@test.attr(type=['negative', 'gate'])
diff --git a/tempest/api/database/versions/test_versions.py b/tempest/api/database/versions/test_versions.py
index 453abe7..80fcecf 100644
--- a/tempest/api/database/versions/test_versions.py
+++ b/tempest/api/database/versions/test_versions.py
@@ -21,8 +21,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(DatabaseVersionsTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(DatabaseVersionsTest, cls).resource_setup()
cls.client = cls.database_versions_client
@test.attr(type='smoke')
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index ca0f8a5..48eff84 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -73,6 +73,7 @@
)
cls.admin_manager = clients.Manager(cls.admin_credentials())
# Clients (in alphabetical order)
+ cls.flavors_client = cls.manager.flavors_client
cls.floating_ips_client = cls.manager.floating_ips_client
# Glance image client v1
cls.image_client = cls.manager.image_client
@@ -146,7 +147,7 @@
def addCleanup_with_wait(self, waiter_callable, thing_id, thing_id_param,
cleanup_callable, cleanup_args=None,
cleanup_kwargs=None, ignore_error=True):
- """Adds wait for ansyc resource deletion at the end of cleanups
+ """Adds wait for async resource deletion at the end of cleanups
@param waiter_callable: callable to wait for the resource to delete
@param thing_id: the id of the resource to be cleaned-up
@@ -321,8 +322,9 @@
if isinstance(server_or_ip, six.string_types):
ip = server_or_ip
else:
- network_name_for_ssh = CONF.compute.network_for_ssh
- ip = server_or_ip.networks[network_name_for_ssh][0]
+ addr = server_or_ip['addresses'][CONF.compute.network_for_ssh][0]
+ ip = addr['addr']
+
if username is None:
username = CONF.scenario.ssh_user
if private_key is None:
@@ -439,6 +441,22 @@
_, volume = self.volumes_client.get_volume(self.volume['id'])
self.assertEqual('available', volume['status'])
+ def rebuild_server(self, server_id, image=None,
+ preserve_ephemeral=False, wait=True,
+ rebuild_kwargs=None):
+ if image is None:
+ image = CONF.compute.image_ref
+
+ rebuild_kwargs = rebuild_kwargs or {}
+
+ LOG.debug("Rebuilding server (id: %s, image: %s, preserve eph: %s)",
+ server_id, image, preserve_ephemeral)
+ self.servers_client.rebuild(server_id=server_id, image_ref=image,
+ preserve_ephemeral=preserve_ephemeral,
+ **rebuild_kwargs)
+ if wait:
+ self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+
# TODO(yfried): change this class name to NetworkScenarioTest once client
# migration is complete
@@ -624,7 +642,7 @@
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- proc.wait()
+ proc.communicate()
return (proc.returncode == 0) == should_succeed
return tempest.test.call_until_true(
@@ -1516,7 +1534,7 @@
ERROR = 'error'
-class BaremetalScenarioTest(OfficialClientTest):
+class BaremetalScenarioTest(ScenarioTest):
@classmethod
def setUpClass(cls):
super(BaremetalScenarioTest, cls).setUpClass()
@@ -1527,12 +1545,13 @@
raise cls.skipException(msg)
# use an admin client manager for baremetal client
- admin_creds = cls.admin_credentials()
- manager = clients.OfficialClientManager(credentials=admin_creds)
+ manager = clients.Manager(
+ credentials=cls.admin_credentials()
+ )
cls.baremetal_client = manager.baremetal_client
# allow any issues obtaining the node list to raise early
- cls.baremetal_client.node.list()
+ cls.baremetal_client.list_nodes()
def _node_state_timeout(self, node_id, state_attr,
target_states, timeout=10, interval=1):
@@ -1541,7 +1560,7 @@
def check_state():
node = self.get_node(node_id=node_id)
- if getattr(node, state_attr) in target_states:
+ if node.get(state_attr) in target_states:
return True
return False
@@ -1581,14 +1600,20 @@
def get_node(self, node_id=None, instance_id=None):
if node_id:
- return self.baremetal_client.node.get(node_id)
+ _, body = self.baremetal_client.show_node(node_id)
+ return body
elif instance_id:
- return self.baremetal_client.node.get_by_instance_uuid(instance_id)
+ _, body = self.baremetal_client.show_node_by_instance_uuid(
+ instance_id)
+ if body['nodes']:
+ return body['nodes'][0]
- def get_ports(self, node_id):
+ def get_ports(self, node_uuid):
ports = []
- for port in self.baremetal_client.node.list_ports(node_id):
- ports.append(self.baremetal_client.port.get(port.uuid))
+ _, body = self.baremetal_client.list_node_ports(node_uuid)
+ for port in body['ports']:
+ _, p = self.baremetal_client.show_port(port['uuid'])
+ ports.append(p)
return ports
def add_keypair(self):
@@ -1603,42 +1628,37 @@
def boot_instance(self):
create_kwargs = {
- 'key_name': self.keypair.id
+ 'key_name': self.keypair['name']
}
self.instance = self.create_server(
wait_on_boot=False, create_kwargs=create_kwargs)
- self.addCleanup_with_wait(self.compute_client.servers,
- self.instance.id,
- cleanup_callable=self.delete_wrapper,
- cleanup_args=[self.instance])
+ self.wait_node(self.instance['id'])
+ self.node = self.get_node(instance_id=self.instance['id'])
- self.wait_node(self.instance.id)
- self.node = self.get_node(instance_id=self.instance.id)
-
- self.wait_power_state(self.node.uuid, BaremetalPowerStates.POWER_ON)
+ self.wait_power_state(self.node['uuid'], BaremetalPowerStates.POWER_ON)
self.wait_provisioning_state(
- self.node.uuid,
+ self.node['uuid'],
[BaremetalProvisionStates.DEPLOYWAIT,
BaremetalProvisionStates.ACTIVE],
timeout=15)
- self.wait_provisioning_state(self.node.uuid,
+ self.wait_provisioning_state(self.node['uuid'],
BaremetalProvisionStates.ACTIVE,
timeout=CONF.baremetal.active_timeout)
- self.status_timeout(
- self.compute_client.servers, self.instance.id, 'ACTIVE')
-
- self.node = self.get_node(instance_id=self.instance.id)
- self.instance = self.compute_client.servers.get(self.instance.id)
+ self.servers_client.wait_for_server_status(self.instance['id'],
+ 'ACTIVE')
+ self.node = self.get_node(instance_id=self.instance['id'])
+ _, self.instance = self.servers_client.get_server(self.instance['id'])
def terminate_instance(self):
- self.instance.delete()
- self.wait_power_state(self.node.uuid, BaremetalPowerStates.POWER_OFF)
+ self.servers_client.delete_server(self.instance['id'])
+ self.wait_power_state(self.node['uuid'],
+ BaremetalPowerStates.POWER_OFF)
self.wait_provisioning_state(
- self.node.uuid,
+ self.node['uuid'],
BaremetalProvisionStates.NOSTATE,
timeout=CONF.baremetal.unprovision_timeout)
@@ -1867,7 +1887,7 @@
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- proc.wait()
+ proc.communicate()
return (proc.returncode == 0) == should_succeed
return tempest.test.call_until_true(
@@ -2302,7 +2322,7 @@
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- proc.wait()
+ proc.communicate()
return (proc.returncode == 0) == should_succeed
return tempest.test.call_until_true(
diff --git a/tempest/scenario/orchestration/test_autoscaling.py b/tempest/scenario/orchestration/test_autoscaling.py
deleted file mode 100644
index 8894106..0000000
--- a/tempest/scenario/orchestration/test_autoscaling.py
+++ /dev/null
@@ -1,125 +0,0 @@
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import time
-
-import heatclient.exc as heat_exceptions
-
-from tempest import config
-from tempest.scenario import manager
-from tempest import test
-
-CONF = config.CONF
-
-
-class AutoScalingTest(manager.OrchestrationScenarioTest):
-
- def setUp(self):
- super(AutoScalingTest, self).setUp()
- if not CONF.orchestration.image_ref:
- raise self.skipException("No image available to test")
- self.client = self.orchestration_client
-
- def assign_keypair(self):
- self.stack_name = self._stack_rand_name()
- if CONF.orchestration.keypair_name:
- self.keypair_name = CONF.orchestration.keypair_name
- else:
- self.keypair = self.create_keypair()
- self.keypair_name = self.keypair.id
-
- def launch_stack(self):
- net = self._get_default_network()
- self.parameters = {
- 'KeyName': self.keypair_name,
- 'InstanceType': CONF.orchestration.instance_type,
- 'ImageId': CONF.orchestration.image_ref,
- 'StackStart': str(time.time()),
- 'Subnet': net['subnets'][0]
- }
-
- # create the stack
- self.template = self._load_template(__file__, 'test_autoscaling.yaml')
- self.client.stacks.create(
- stack_name=self.stack_name,
- template=self.template,
- parameters=self.parameters)
-
- self.stack = self.client.stacks.get(self.stack_name)
- self.stack_identifier = '%s/%s' % (self.stack_name, self.stack.id)
-
- # if a keypair was set, do not delete the stack on exit to allow
- # for manual post-mortums
- if not CONF.orchestration.keypair_name:
- self.addCleanup(self.client.stacks.delete, self.stack)
-
- @test.skip_because(bug="1257575")
- @test.attr(type='slow')
- @test.services('orchestration', 'compute')
- def test_scale_up_then_down(self):
-
- self.assign_keypair()
- self.launch_stack()
-
- sid = self.stack_identifier
- timeout = CONF.orchestration.build_timeout
- interval = 10
-
- self.assertEqual('CREATE', self.stack.action)
- # wait for create to complete.
- self.status_timeout(self.client.stacks, sid, 'COMPLETE',
- error_status='FAILED')
-
- self.stack.get()
- self.assertEqual('CREATE_COMPLETE', self.stack.stack_status)
-
- # the resource SmokeServerGroup is implemented as a nested
- # stack, so servers can be counted by counting the resources
- # inside that nested stack
- resource = self.client.resources.get(sid, 'SmokeServerGroup')
- nested_stack_id = resource.physical_resource_id
-
- def server_count():
- # the number of servers is the number of resources
- # in the nested stack
- self.server_count = len(
- self.client.resources.list(nested_stack_id))
- return self.server_count
-
- def assertScale(from_servers, to_servers):
- test.call_until_true(lambda: server_count() == to_servers,
- timeout, interval)
- self.assertEqual(to_servers, self.server_count,
- 'Failed scaling from %d to %d servers. '
- 'Current server count: %s' % (
- from_servers, to_servers,
- self.server_count))
-
- # he marched them up to the top of the hill
- assertScale(1, 2)
- assertScale(2, 3)
-
- # and he marched them down again
- assertScale(3, 2)
- assertScale(2, 1)
-
- # delete stack on completion
- self.stack.delete()
- self.status_timeout(self.client.stacks, sid, 'COMPLETE',
- error_status='FAILED',
- not_found_exception=heat_exceptions.NotFound)
-
- try:
- self.stack.get()
- self.assertEqual('DELETE_COMPLETE', self.stack.stack_status)
- except heat_exceptions.NotFound:
- pass
diff --git a/tempest/scenario/orchestration/test_autoscaling.yaml b/tempest/scenario/orchestration/test_autoscaling.yaml
deleted file mode 100644
index 4651284..0000000
--- a/tempest/scenario/orchestration/test_autoscaling.yaml
+++ /dev/null
@@ -1,185 +0,0 @@
-HeatTemplateFormatVersion: '2012-12-12'
-Description: |
- Template which tests autoscaling and load balancing
-Parameters:
- KeyName:
- Type: String
- InstanceType:
- Type: String
- ImageId:
- Type: String
- Subnet:
- Type: String
- StackStart:
- Description: Epoch seconds when the stack was launched
- Type: Number
- ConsumeStartSeconds:
- Description: Seconds after invocation when memory should be consumed
- Type: Number
- Default: '60'
- ConsumeStopSeconds:
- Description: Seconds after StackStart when memory should be released
- Type: Number
- Default: '420'
- ScaleUpThreshold:
- Description: Memory percentage threshold to scale up on
- Type: String
- Default: '70'
- ScaleDownThreshold:
- Description: Memory percentage threshold to scale down on
- Type: String
- Default: '60'
- ConsumeMemoryLimit:
- Description: Memory percentage threshold to consume
- Type: Number
- Default: '71'
-Resources:
- SmokeServerGroup:
- Type: AWS::AutoScaling::AutoScalingGroup
- Properties:
- AvailabilityZones: {'Fn::GetAZs': ''}
- LaunchConfigurationName: {Ref: LaunchConfig}
- MinSize: '1'
- MaxSize: '3'
- VPCZoneIdentifier: [{Ref: Subnet}]
- SmokeServerScaleUpPolicy:
- Type: AWS::AutoScaling::ScalingPolicy
- Properties:
- AdjustmentType: ChangeInCapacity
- AutoScalingGroupName: {Ref: SmokeServerGroup}
- Cooldown: '60'
- ScalingAdjustment: '1'
- SmokeServerScaleDownPolicy:
- Type: AWS::AutoScaling::ScalingPolicy
- Properties:
- AdjustmentType: ChangeInCapacity
- AutoScalingGroupName: {Ref: SmokeServerGroup}
- Cooldown: '60'
- ScalingAdjustment: '-1'
- MEMAlarmHigh:
- Type: AWS::CloudWatch::Alarm
- Properties:
- AlarmDescription: Scale-up if MEM > ScaleUpThreshold% for 10 seconds
- MetricName: MemoryUtilization
- Namespace: system/linux
- Statistic: Average
- Period: '10'
- EvaluationPeriods: '1'
- Threshold: {Ref: ScaleUpThreshold}
- AlarmActions: [{Ref: SmokeServerScaleUpPolicy}]
- Dimensions:
- - Name: AutoScalingGroupName
- Value: {Ref: SmokeServerGroup}
- ComparisonOperator: GreaterThanThreshold
- MEMAlarmLow:
- Type: AWS::CloudWatch::Alarm
- Properties:
- AlarmDescription: Scale-down if MEM < ScaleDownThreshold% for 10 seconds
- MetricName: MemoryUtilization
- Namespace: system/linux
- Statistic: Average
- Period: '10'
- EvaluationPeriods: '1'
- Threshold: {Ref: ScaleDownThreshold}
- AlarmActions: [{Ref: SmokeServerScaleDownPolicy}]
- Dimensions:
- - Name: AutoScalingGroupName
- Value: {Ref: SmokeServerGroup}
- ComparisonOperator: LessThanThreshold
- CfnUser:
- Type: AWS::IAM::User
- SmokeKeys:
- Type: AWS::IAM::AccessKey
- Properties:
- UserName: {Ref: CfnUser}
- SmokeSecurityGroup:
- Type: AWS::EC2::SecurityGroup
- Properties:
- GroupDescription: Standard firewall rules
- SecurityGroupIngress:
- - {IpProtocol: tcp, FromPort: '22', ToPort: '22', CidrIp: 0.0.0.0/0}
- - {IpProtocol: tcp, FromPort: '80', ToPort: '80', CidrIp: 0.0.0.0/0}
- LaunchConfig:
- Type: AWS::AutoScaling::LaunchConfiguration
- Metadata:
- AWS::CloudFormation::Init:
- config:
- files:
- /etc/cfn/cfn-credentials:
- content:
- Fn::Replace:
- - $AWSAccessKeyId: {Ref: SmokeKeys}
- $AWSSecretKey: {'Fn::GetAtt': [SmokeKeys, SecretAccessKey]}
- - |
- AWSAccessKeyId=$AWSAccessKeyId
- AWSSecretKey=$AWSSecretKey
- mode: '000400'
- owner: root
- group: root
- /root/watch_loop:
- content:
- Fn::Replace:
- - _hi_: {Ref: MEMAlarmHigh}
- _lo_: {Ref: MEMAlarmLow}
- - |
- #!/bin/bash
- while :
- do
- /opt/aws/bin/cfn-push-stats --watch _hi_ --mem-util
- /opt/aws/bin/cfn-push-stats --watch _lo_ --mem-util
- sleep 4
- done
- mode: '000700'
- owner: root
- group: root
- /root/consume_memory:
- content:
- Fn::Replace:
- - StackStart: {Ref: StackStart}
- ConsumeStopSeconds: {Ref: ConsumeStopSeconds}
- ConsumeStartSeconds: {Ref: ConsumeStartSeconds}
- ConsumeMemoryLimit: {Ref: ConsumeMemoryLimit}
- - |
- #!/usr/bin/env python
- import psutil
- import time
- import datetime
- import sys
- a = []
- sleep_until_consume = ConsumeStartSeconds
- stack_start = StackStart
- consume_stop_time = stack_start + ConsumeStopSeconds
- memory_limit = ConsumeMemoryLimit
- if sleep_until_consume > 0:
- sys.stdout.flush()
- time.sleep(sleep_until_consume)
- while psutil.virtual_memory().percent < memory_limit:
- sys.stdout.flush()
- a.append(' ' * 10**5)
- time.sleep(0.1)
- sleep_until_exit = consume_stop_time - time.time()
- if sleep_until_exit > 0:
- time.sleep(sleep_until_exit)
- mode: '000700'
- owner: root
- group: root
- Properties:
- ImageId: {Ref: ImageId}
- InstanceType: {Ref: InstanceType}
- KeyName: {Ref: KeyName}
- SecurityGroups: [{Ref: SmokeSecurityGroup}]
- UserData:
- Fn::Base64:
- Fn::Replace:
- - ConsumeStopSeconds: {Ref: ConsumeStopSeconds}
- ConsumeStartSeconds: {Ref: ConsumeStartSeconds}
- ConsumeMemoryLimit: {Ref: ConsumeMemoryLimit}
- - |
- #!/bin/bash -v
- /opt/aws/bin/cfn-init
- # report on memory consumption every 4 seconds
- /root/watch_loop &
- # wait ConsumeStartSeconds then ramp up memory consumption
- # until it is over ConsumeMemoryLimit%
- # then exits ConsumeStopSeconds seconds after stack launch
- /root/consume_memory > /root/consume_memory.log &
diff --git a/tempest/scenario/test_baremetal_basic_ops.py b/tempest/scenario/test_baremetal_basic_ops.py
index efbf4ce..35571c6 100644
--- a/tempest/scenario/test_baremetal_basic_ops.py
+++ b/tempest/scenario/test_baremetal_basic_ops.py
@@ -41,26 +41,23 @@
expected state transitions
"""
def rebuild_instance(self, preserve_ephemeral=False):
- self.rebuild_server(self.instance,
+ self.rebuild_server(server_id=self.instance['id'],
preserve_ephemeral=preserve_ephemeral,
wait=False)
- node = self.get_node(instance_id=self.instance.id)
- self.instance = self.compute_client.servers.get(self.instance.id)
-
- self.addCleanup_with_wait(self.compute_client.servers,
- self.instance.id,
- cleanup_callable=self.delete_wrapper,
- cleanup_args=[self.instance])
+ node = self.get_node(instance_id=self.instance['id'])
# We should remain on the same node
- self.assertEqual(self.node.uuid, node.uuid)
+ self.assertEqual(self.node['uuid'], node['uuid'])
self.node = node
- self.status_timeout(self.compute_client.servers, self.instance.id,
- 'REBUILD')
- self.status_timeout(self.compute_client.servers, self.instance.id,
- 'ACTIVE')
+ self.servers_client.wait_for_server_status(
+ server_id=self.instance['id'],
+ status='REBUILD',
+ ready_wait=False)
+ self.servers_client.wait_for_server_status(
+ server_id=self.instance['id'],
+ status='ACTIVE')
def create_remote_file(self, client, filename):
"""Create a file on the remote client connection.
@@ -99,23 +96,26 @@
def get_flavor_ephemeral_size(self):
"""Returns size of the ephemeral partition in GiB."""
- f_id = self.instance.flavor['id']
- ephemeral = self.compute_client.flavors.get(f_id).ephemeral
- if ephemeral != 'N/A':
- return int(ephemeral)
- return None
+ f_id = self.instance['flavor']['id']
+ _, flavor = self.flavors_client.get_flavor_details(f_id)
+ ephemeral = flavor.get('OS-FLV-EXT-DATA:ephemeral')
+ if not ephemeral or ephemeral == 'N/A':
+ return None
+ return int(ephemeral)
def add_floating_ip(self):
- floating_ip = self.compute_client.floating_ips.create()
- self.instance.add_floating_ip(floating_ip)
- return floating_ip.ip
+ _, floating_ip = self.floating_ips_client.create_floating_ip()
+ self.floating_ips_client.associate_floating_ip_to_server(
+ floating_ip['ip'], self.instance['id'])
+ return floating_ip['ip']
def validate_ports(self):
- for port in self.get_ports(self.node.uuid):
- n_port_id = port.extra['vif_port_id']
- n_port = self.network_client.show_port(n_port_id)['port']
- self.assertEqual(n_port['device_id'], self.instance.id)
- self.assertEqual(n_port['mac_address'], port.address)
+ for port in self.get_ports(self.node['uuid']):
+ n_port_id = port['extra']['vif_port_id']
+ _, body = self.network_client.show_port(n_port_id)
+ n_port = body['port']
+ self.assertEqual(n_port['device_id'], self.instance['id'])
+ self.assertEqual(n_port['mac_address'], port['address'])
@test.services('baremetal', 'compute', 'image', 'network')
def test_baremetal_server_ops(self):
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index 4783273..f2c3dcd 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -15,7 +15,6 @@
import time
-from cinderclient import exceptions as cinder_exceptions
import testtools
from tempest.common.utils import data_utils
@@ -30,7 +29,7 @@
LOG = logging.getLogger(__name__)
-class TestStampPattern(manager.OfficialClientTest):
+class TestStampPattern(manager.ScenarioTest):
"""
This test is for snapshotting an instance/volume and attaching the volume
created from snapshot to the instance booted from snapshot.
@@ -59,13 +58,13 @@
raise cls.skipException("Cinder volume snapshots are disabled")
def _wait_for_volume_snapshot_status(self, volume_snapshot, status):
- self.status_timeout(self.volume_client.volume_snapshots,
- volume_snapshot.id, status)
+ self.snapshots_client.wait_for_snapshot_status(volume_snapshot['id'],
+ status)
def _boot_image(self, image_id):
- security_groups = [self.security_group.name]
+ security_groups = [self.security_group]
create_kwargs = {
- 'key_name': self.keypair.name,
+ 'key_name': self.keypair['name'],
'security_groups': security_groups
}
return self.create_server(image=image_id, create_kwargs=create_kwargs)
@@ -74,53 +73,54 @@
self.keypair = self.create_keypair()
def _create_floating_ip(self):
- floating_ip = self.compute_client.floating_ips.create()
- self.addCleanup(self.delete_wrapper, floating_ip)
+ _, floating_ip = self.floating_ips_client.create_floating_ip()
+ self.addCleanup(self.delete_wrapper,
+ self.floating_ips_client.delete_floating_ip,
+ floating_ip['id'])
return floating_ip
def _add_floating_ip(self, server, floating_ip):
- server.add_floating_ip(floating_ip)
+ self.floating_ips_client.associate_floating_ip_to_server(
+ floating_ip['ip'], server['id'])
def _ssh_to_server(self, server_or_ip):
return self.get_remote_client(server_or_ip)
def _create_volume_snapshot(self, volume):
snapshot_name = data_utils.rand_name('scenario-snapshot-')
- volume_snapshots = self.volume_client.volume_snapshots
- snapshot = volume_snapshots.create(
- volume.id, display_name=snapshot_name)
+ _, snapshot = self.snapshots_client.create_snapshot(
+ volume['id'], display_name=snapshot_name)
def cleaner():
- volume_snapshots.delete(snapshot)
+ self.snapshots_client.delete_snapshot(snapshot['id'])
try:
- while volume_snapshots.get(snapshot.id):
+ while self.snapshots_client.get_snapshot(snapshot['id']):
time.sleep(1)
- except cinder_exceptions.NotFound:
+ except exceptions.NotFound:
pass
self.addCleanup(cleaner)
self._wait_for_volume_status(volume, 'available')
- self._wait_for_volume_snapshot_status(snapshot, 'available')
- self.assertEqual(snapshot_name, snapshot.display_name)
+ self.snapshots_client.wait_for_snapshot_status(snapshot['id'],
+ 'available')
+ self.assertEqual(snapshot_name, snapshot['display_name'])
return snapshot
def _wait_for_volume_status(self, volume, status):
- self.status_timeout(
- self.volume_client.volumes, volume.id, status)
+ self.volumes_client.wait_for_volume_status(volume['id'], status)
def _create_volume(self, snapshot_id=None):
return self.create_volume(snapshot_id=snapshot_id)
def _attach_volume(self, server, volume):
- attach_volume_client = self.compute_client.volumes.create_server_volume
- attached_volume = attach_volume_client(server.id,
- volume.id,
- '/dev/vdb')
- self.assertEqual(volume.id, attached_volume.id)
+ # TODO(andreaf) we should use device from config instead if vdb
+ _, attached_volume = self.servers_client.attach_volume(
+ server['id'], volume['id'], device='/dev/vdb')
+ attached_volume = attached_volume['volumeAttachment']
+ self.assertEqual(volume['id'], attached_volume['id'])
self._wait_for_volume_status(attached_volume, 'in-use')
def _detach_volume(self, server, volume):
- detach_volume_client = self.compute_client.volumes.delete_server_volume
- detach_volume_client(server.id, volume.id)
+ self.servers_client.detach_volume(server['id'], volume['id'])
self._wait_for_volume_status(volume, 'available')
def _wait_for_volume_available_on_the_system(self, server_or_ip):
@@ -157,7 +157,7 @@
def test_stamp_pattern(self):
# prepare for booting a instance
self._add_keypair()
- self.security_group = self._create_security_group_nova()
+ self.security_group = self._create_security_group()
# boot an instance and create a timestamp file in it
volume = self._create_volume()
@@ -167,7 +167,7 @@
if CONF.compute.use_floatingip_for_ssh:
floating_ip_for_server = self._create_floating_ip()
self._add_floating_ip(server, floating_ip_for_server)
- ip_for_server = floating_ip_for_server.ip
+ ip_for_server = floating_ip_for_server['ip']
else:
ip_for_server = server
@@ -184,17 +184,17 @@
# create second volume from the snapshot(volume2)
volume_from_snapshot = self._create_volume(
- snapshot_id=volume_snapshot.id)
+ snapshot_id=volume_snapshot['id'])
# boot second instance from the snapshot(instance2)
- server_from_snapshot = self._boot_image(snapshot_image.id)
+ server_from_snapshot = self._boot_image(snapshot_image['id'])
# create and add floating IP to server_from_snapshot
if CONF.compute.use_floatingip_for_ssh:
floating_ip_for_snapshot = self._create_floating_ip()
self._add_floating_ip(server_from_snapshot,
floating_ip_for_snapshot)
- ip_for_snapshot = floating_ip_for_snapshot.ip
+ ip_for_snapshot = floating_ip_for_snapshot['ip']
else:
ip_for_snapshot = server_from_snapshot
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index 88b68d3..947ba7a 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -175,11 +175,12 @@
return resp, body
def wait_for_server_status(self, server_id, status, extra_timeout=0,
- raise_on_error=True):
+ raise_on_error=True, ready_wait=True):
"""Waits for a server to reach a given status."""
return waiters.wait_for_server_status(self, server_id, status,
extra_timeout=extra_timeout,
- raise_on_error=raise_on_error)
+ raise_on_error=raise_on_error,
+ ready_wait=ready_wait)
def wait_for_server_termination(self, server_id, ignore_error=False):
"""Waits for server to reach termination."""
diff --git a/tempest/stress/actions/ssh_floating.py b/tempest/stress/actions/ssh_floating.py
index 478cd07..d78112c 100644
--- a/tempest/stress/actions/ssh_floating.py
+++ b/tempest/stress/actions/ssh_floating.py
@@ -30,7 +30,7 @@
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- proc.wait()
+ proc.communicate()
success = proc.returncode == 0
return success
diff --git a/tempest/tests/test_wrappers.py b/tempest/tests/test_wrappers.py
index 3f4ac7d..0fd41f9 100644
--- a/tempest/tests/test_wrappers.py
+++ b/tempest/tests/test_wrappers.py
@@ -62,14 +62,11 @@
p = subprocess.Popen(
"bash %s" % cmd, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- # wait in the general case is dangerous, however the amount of
- # data coming back on those pipes is small enough it shouldn't be
- # a problem.
- p.wait()
+ out, err = p.communicate()
self.assertEqual(
p.returncode, expected,
- "Stdout: %s; Stderr: %s" % (p.stdout.read(), p.stderr.read()))
+ "Stdout: %s; Stderr: %s" % (out, err))
def test_pretty_tox(self):
# Git init is required for the pbr testr command. pbr requires a git