Exemplo n.º 1
0
    def setup(self):
        image = self.config["image"]
        flavor = self.config["flavor"]

        image_id = types.EC2Image(self.context).pre_process(
            resource_spec=image, config={})

        for user, tenant_id in rutils.iterate_per_tenants(
                self.context["users"]):
            LOG.debug("Booting servers for tenant %s " % user["tenant_id"])
            ec2_scenario = ec2_utils.EC2Scenario({
                "user": user,
                "task": self.context["task"],
                "owner_id": self.context["owner_id"]})

            LOG.debug(
                "Calling _boot_servers with "
                "image_id=%(image_id)s flavor_name=%(flavor_name)s "
                "servers_per_tenant=%(servers_per_tenant)s"
                % {"image_id": image_id,
                   "flavor_name": flavor["name"],
                   "servers_per_tenant": self.config["servers_per_tenant"]})

            servers = ec2_scenario._boot_servers(
                image_id, flavor["name"], self.config["servers_per_tenant"])

            current_servers = [server.id for server in servers]

            self.context["tenants"][tenant_id]["ec2_servers"] = current_servers
Exemplo n.º 2
0
 def test__list_servers(self):
     servers_list = []
     self.clients("ec2").get_only_instances.return_value = servers_list
     ec2_scenario = utils.EC2Scenario()
     return_servers_list = ec2_scenario._list_servers()
     self.assertEqual(servers_list, return_servers_list)
     self._test_atomic_action_timer(ec2_scenario.atomic_actions(),
                                    "ec2.list_servers")
Exemplo n.º 3
0
 def test__boot_servers(self):
     self.clients("ec2").run_instances.return_value = self.reservations
     ec2_scenario = utils.EC2Scenario(context={})
     ec2_scenario._update_resource = mock.Mock()
     ec2_scenario._boot_servers("image", "flavor", 2)
     expected = [
         mock.call(
             self.server1,
             ready_statuses=["RUNNING"],
             update_resource=ec2_scenario._update_resource,
             check_interval=CONF.openstack.ec2_server_boot_poll_interval,
             timeout=CONF.openstack.ec2_server_boot_timeout),
         mock.call(
             self.server2,
             ready_statuses=["RUNNING"],
             update_resource=ec2_scenario._update_resource,
             check_interval=CONF.openstack.ec2_server_boot_poll_interval,
             timeout=CONF.openstack.ec2_server_boot_timeout)
     ]
     self.mock_wait_for_status.mock.assert_has_calls(expected)
     self._test_atomic_action_timer(ec2_scenario.atomic_actions(),
                                    "ec2.boot_servers")
Exemplo n.º 4
0
 def test__update_resource(self):
     resource = mock.MagicMock()
     scenario = utils.EC2Scenario(self.context)
     self.assertEqual(scenario._update_resource(resource), resource)
     resource.update.assert_called_once_with()