Beispiel #1
0
class GlanceImages(utils.GlanceScenario, nova_utils.NovaScenario):

    RESOURCE_NAME_PREFIX = "rally_image_"
    RESOURCE_NAME_LENGTH = 16

    @base.scenario(context={"cleanup": ["glance"]})
    def create_and_list_image(self, container_format,
                              image_location, disk_format, **kwargs):
        """Test adding an image and then listing all images.

        This scenario is a very useful tool to measure
        the "glance image-list" command performance.

        If you have only 1 user in your context, you will
        add 1 image on every iteration. So you will have more
        and more images and will be able to measure the
        performance of the "glance image-list" command depending on
        the number of images owned by users.
        """
        self._create_image(self._generate_random_name(),
                           container_format,
                           image_location,
                           disk_format,
                           **kwargs)
        self._list_images()

    @base.scenario(context={"cleanup": ["glance"]})
    def create_and_delete_image(self, container_format,
                                image_location, disk_format, **kwargs):
        """Test adds and then deletes image."""
        image_name = self._generate_random_name()
        image = self._create_image(image_name,
                                   container_format,
                                   image_location,
                                   disk_format,
                                   **kwargs)
        self._delete_image(image)

    @types.set(flavor=types.FlavorResourceType)
    @validation.add_validator(validation.flavor_exists("flavor"))
    @base.scenario(context={"cleanup": ["glance", "nova"]})
    def create_image_and_boot_instances(self, container_format,
                                        image_location, disk_format,
                                        flavor, number_instances,
                                        **kwargs):
        """Test adds image, boots instance from it and then deletes them."""
        image_name = self._generate_random_name()
        image = self._create_image(image_name,
                                   container_format,
                                   image_location,
                                   disk_format,
                                   **kwargs)
        image_id = image.id
        server_name = self._generate_random_name(prefix="rally_novaserver_")
        self._boot_servers(server_name, image_id,
                           flavor, number_instances, **kwargs)
Beispiel #2
0
 def test_flavor_exists(self, mock_osclients):
     fakenclient = fakes.FakeNovaClient()
     fakenclient.flavors = mock.MagicMock()
     mock_osclients.nova.return_value = fakenclient
     validator = validation.flavor_exists("flavor_id")
     test_flavor_id = 1
     result = validator(clients=mock_osclients, flavor_id=test_flavor_id)
     fakenclient.flavors.get.assert_called_once_with(flavor=test_flavor_id)
     self.assertTrue(result.is_valid)
     self.assertIsNone(result.msg)
Beispiel #3
0
 def test_flavor_exists(self):
     fakenclient = fakes.FakeClients().get_nova_client()
     fakenclient.flavors = mock.MagicMock()
     validator = validation.flavor_exists("flavor_id")
     test_flavor_id = 1
     result = validator(clients={"nova": fakenclient},
                        flavor_id=test_flavor_id)
     fakenclient.flavors.get.assert_called_once_with(flavor=test_flavor_id)
     self.assertTrue(result.is_valid)
     self.assertIsNone(result.msg)
Beispiel #4
0
 def test_flavor_exists(self, mock_osclients):
     fakenclient = fakes.FakeNovaClient()
     fakenclient.flavors = mock.MagicMock()
     mock_osclients.nova.return_value = fakenclient
     validator = validation.flavor_exists("flavor_id")
     test_flavor_id = 1
     result = validator(clients=mock_osclients,
                        flavor_id=test_flavor_id)
     fakenclient.flavors.get.assert_called_once_with(flavor=test_flavor_id)
     self.assertTrue(result.is_valid)
     self.assertIsNone(result.msg)
Beispiel #5
0
 def test_flavor_exists_fail(self, mock_osclients):
     fakenclient = fakes.FakeNovaClient()
     fakenclient.flavors = mock.MagicMock()
     fakenclient.flavors.get.side_effect = nova_exc.NotFound(code=404)
     mock_osclients.nova.return_value = fakenclient
     validator = validation.flavor_exists("flavor_id")
     test_flavor_id = 101
     result = validator(clients=mock_osclients, flavor_id=test_flavor_id)
     fakenclient.flavors.get.assert_called_once_with(flavor=test_flavor_id)
     self.assertFalse(result.is_valid)
     self.assertIsNotNone(result.msg)
Beispiel #6
0
 def test_flavor_exists_fail(self):
     fakenclient = fakes.FakeClients().get_nova_client()
     fakenclient.flavors = mock.MagicMock()
     fakenclient.flavors.get.side_effect = nova_exc.NotFound(code=404)
     validator = validation.flavor_exists("flavor_id")
     test_flavor_id = 101
     result = validator(clients={"nova": fakenclient},
                        flavor_id=test_flavor_id)
     fakenclient.flavors.get.assert_called_once_with(flavor=test_flavor_id)
     self.assertFalse(result.is_valid)
     self.assertIsNotNone(result.msg)
Beispiel #7
0
 def test_flavor_exists(self, mock_osclients):
     fakenclient = fakes.FakeNovaClient()
     fakenclient.flavors = mock.MagicMock()
     mock_osclients.nova.return_value = fakenclient
     validator = validation.flavor_exists("flavor")
     test_flavor_id = 1
     resource = {"id": test_flavor_id}
     config = {"args": {"flavor": resource}}
     result = validator(config, clients=mock_osclients, task=None)
     fakenclient.flavors.get.assert_called_once_with(flavor=test_flavor_id)
     self.assertTrue(result.is_valid)
     self.assertIsNone(result.msg)
Beispiel #8
0
 def test_flavor_exists_fail(self, mock_osclients):
     fakenclient = fakes.FakeNovaClient()
     fakenclient.flavors = mock.MagicMock()
     fakenclient.flavors.get.side_effect = nova_exc.NotFound(code=404)
     mock_osclients.nova.return_value = fakenclient
     validator = validation.flavor_exists("flavor_id")
     test_flavor_id = 101
     result = validator(clients=mock_osclients,
                        flavor_id=test_flavor_id)
     fakenclient.flavors.get.assert_called_once_with(flavor=test_flavor_id)
     self.assertFalse(result.is_valid)
     self.assertIsNotNone(result.msg)
Beispiel #9
0
 def test_flavor_exists(self, mock_osclients):
     fakenclient = fakes.FakeNovaClient()
     fakenclient.flavors = mock.MagicMock()
     mock_osclients.nova.return_value = fakenclient
     validator = validation.flavor_exists("flavor")
     test_flavor_id = 1
     resource = {"id": test_flavor_id}
     config = {"args": {"flavor": resource}}
     result = validator(config, clients=mock_osclients, task=None)
     fakenclient.flavors.get.assert_called_once_with(flavor=test_flavor_id)
     self.assertTrue(result.is_valid)
     self.assertIsNone(result.msg)
Beispiel #10
0
class SaharaClusters(utils.SaharaScenario):
    @types.set(flavor=types.FlavorResourceType)
    @validation.add(validation.flavor_exists('flavor'))
    @validation.required_services(consts.Service.SAHARA)
    @validation.required_contexts("users", "sahara_image")
    @validation.add(
        validation.number("node_count", minval=2, integer_only=True))
    @base.scenario(context={"cleanup": ["sahara"]})
    def create_and_delete_cluster(self,
                                  flavor,
                                  node_count,
                                  plugin_name="vanilla",
                                  hadoop_version="2.3.0"):
        """Test the Sahara Cluster launch and delete commands.

        This scenario launches a Hadoop cluster, waits until it becomes
        'Active' and deletes it.

        :param flavor: The Nova flavor that will be for nodes in the
        created node groups
        :param node_count: The total number of instances in a cluster (>= 2)
        :param plugin_name: The name of a provisioning plugin
        :param hadoop_version: The version of Hadoop distribution supported by
        the specified plugin.
        """

        tenant_id = self.clients("keystone").tenant_id
        image_id = self.context()["sahara_images"][tenant_id]

        LOG.debug("Using Image: %s" % image_id)

        cluster = self._launch_cluster(flavor_id=flavor,
                                       image_id=image_id,
                                       node_count=node_count,
                                       plugin_name=plugin_name,
                                       hadoop_version=hadoop_version)

        self._delete_cluster(cluster)
class SaharaNodeGroupTemplates(utils.SaharaScenario):

    @types.set(flavor=types.FlavorResourceType)
    @validation.add(validation.flavor_exists('flavor'))
    @base.scenario(context={"cleanup": ["sahara"]})
    @validation.required_services(consts.Service.SAHARA)
    def create_and_list_node_group_templates(self, flavor,
                                             plugin_name="vanilla",
                                             hadoop_version="1.2.1"):
        """Test the sahara Node Group Templates create and list commands.

        This scenario creates two Node Group Templates with different set of
        node processes. The master Node Group Template contains Hadoop's
        management processes. The worker Node Group Template contains
        Haddop's worker processes.

        By default the templates are created for the vanilla Hadoop
        provisioning plugin using the version 1.2.1

        After the templates are created the list operation is called.

        :param flavor: The Nova flavor that will be for nodes in the
        created node groups
        :param plugin_name: The name of a provisioning plugin
        :param hadoop_version: The version of Hadoop distribution supported by
        the specified plugin.
        """

        self._create_master_node_group_template(flavor_id=flavor,
                                                plugin_name=plugin_name,
                                                hadoop_version=hadoop_version)
        self._create_worker_node_group_template(flavor_id=flavor,
                                                plugin_name=plugin_name,
                                                hadoop_version=hadoop_version)
        self._list_node_group_templates()

    @types.set(flavor=types.FlavorResourceType)
    @validation.add(validation.flavor_exists('flavor'))
    @base.scenario(context={"cleanup": ["sahara"]})
    @validation.required_services(consts.Service.SAHARA)
    def create_delete_node_group_templates(self, flavor,
                                           plugin_name="vanilla",
                                           hadoop_version="1.2.1"):
        """Test create and delete commands.

        This scenario creates and deletes two most common types of
        Node Group Templates.

        By default the templates are created for the vanilla Hadoop
        provisioning plugin using the version 1.2.1

        :param flavor: The Nova flavor that will be for nodes in the
        created node groups
        :param plugin_name: The name of a provisioning plugin
        :param hadoop_version: The version of Hadoop distribution supported by
        the specified plugin.
        """

        master_ngt = self._create_master_node_group_template(
            flavor_id=flavor,
            plugin_name=plugin_name,
            hadoop_version=hadoop_version)

        worker_ngt = self._create_worker_node_group_template(
            flavor_id=flavor,
            plugin_name=plugin_name,
            hadoop_version=hadoop_version)

        self._delete_node_group_template(master_ngt)
        self._delete_node_group_template(worker_ngt)