Example #1
0
 def test_create_validation_resources_neutron(self, mock_create_sg):
     expected_floating_network_id = 'my_fni'
     expected_floating_network_name = 'my_fnn'
     resources = vr.create_validation_resources(
         self.os,
         keypair=True,
         floating_ip=True,
         security_group=True,
         security_group_rules=True,
         ethertype='IPv6',
         use_neutron=True,
         floating_network_id=expected_floating_network_id,
         floating_network_name=expected_floating_network_name)
     # Keypair calls
     self.assertGreater(self.mock_kp.mock.call_count, 0)
     # Floating IP calls
     self.assertEqual(self.mock_fip_compute.mock.call_count, 0)
     self.assertGreater(self.mock_fip_network.mock.call_count, 0)
     for call in self.mock_fip_compute.mock.call_args_list[1:]:
         self.assertIn(expected_floating_network_id, call[1].values())
         self.assertNotIn(expected_floating_network_name, call[1].values())
     # SG calls
     mock_create_sg.assert_called_once()
     # Resources
     for resource in ['keypair', 'floating_ip', 'security_group']:
         self.assertIn(resource, resources)
     self.assertEqual(FAKE_KEYPAIR['keypair'], resources['keypair'])
     self.assertEqual(FAKE_SECURITY_GROUP['security_group'],
                      resources['security_group'])
     self.assertIn('ip', resources['floating_ip'])
     self.assertEqual(resources['floating_ip']['ip'],
                      FAKE_FIP_NEUTRON['floatingip']['floating_ip_address'])
     self.assertEqual(resources['floating_ip']['id'],
                      FAKE_FIP_NEUTRON['floatingip']['id'])
 def test_create_validation_resources_neutron(self, mock_create_sg):
     expected_floating_network_id = 'my_fni'
     expected_floating_network_name = 'my_fnn'
     resources = vr.create_validation_resources(
         self.os, keypair=True, floating_ip=True, security_group=True,
         security_group_rules=True, ethertype='IPv6', use_neutron=True,
         floating_network_id=expected_floating_network_id,
         floating_network_name=expected_floating_network_name)
     # Keypair calls
     self.assertGreater(self.mock_kp.mock.call_count, 0)
     # Floating IP calls
     self.assertEqual(self.mock_fip_compute.mock.call_count, 0)
     self.assertGreater(self.mock_fip_network.mock.call_count, 0)
     for call in self.mock_fip_compute.mock.call_args_list[1:]:
         self.assertIn(expected_floating_network_id, call[1].values())
         self.assertNotIn(expected_floating_network_name, call[1].values())
     # SG calls
     mock_create_sg.assert_called_once()
     # Resources
     for resource in ['keypair', 'floating_ip', 'security_group']:
         self.assertIn(resource, resources)
     self.assertEqual(FAKE_KEYPAIR['keypair'], resources['keypair'])
     self.assertEqual(FAKE_SECURITY_GROUP['security_group'],
                      resources['security_group'])
     self.assertIn('ip', resources['floating_ip'])
     self.assertEqual(resources['floating_ip']['ip'],
                      FAKE_FIP_NEUTRON['floatingip']['floating_ip_address'])
     self.assertEqual(resources['floating_ip']['id'],
                      FAKE_FIP_NEUTRON['floatingip']['id'])
Example #3
0
    def get_class_validation_resources(cls, os_clients):
        """Provision validation resources according to configuration

        This is a wrapper around `create_validation_resources` from
        `tempest.common.validation_resources` that passes parameters from
        Tempest configuration. Only one instance of class level
        validation resources is managed by the helper, so If resources
        were already provisioned before, existing ones will be returned.

        Resources are returned as a dictionary. They are also scheduled for
        automatic cleanup during class teardown using
        `addClassResourcesCleanup`.

        If `CONF.validation.run_validation` is False no resource will be
        provisioned at all.

        @param os_clients: Clients to be used to provision the resources.
        """
        if not CONF.validation.run_validation:
            return

        if os_clients in cls._validation_resources:
            return cls._validation_resources[os_clients]

        if (CONF.validation.ip_version_for_ssh not in (4, 6) and
                CONF.service_available.neutron):
            msg = "Invalid IP version %s in ip_version_for_ssh. Use 4 or 6"
            raise lib_exc.InvalidConfiguration(
                msg % CONF.validation.ip_version_for_ssh)

        resources = vr.create_validation_resources(
            os_clients,
            **cls._validation_resources_params_from_conf())

        cls.addClassResourceCleanup(
            vr.clear_validation_resources, os_clients,
            use_neutron=CONF.service_available.neutron,
            **resources)
        cls._validation_resources[os_clients] = resources
        return resources
Example #4
0
    def get_class_validation_resources(cls, os_clients):
        """Provision validation resources according to configuration

        This is a wrapper around `create_validation_resources` from
        `tempest.common.validation_resources` that passes parameters from
        Tempest configuration. Only one instance of class level
        validation resources is managed by the helper, so If resources
        were already provisioned before, existing ones will be returned.

        Resources are returned as a dictionary. They are also scheduled for
        automatic cleanup during class teardown using
        `addClassResourcesCleanup`.

        If `CONF.validation.run_validation` is False no resource will be
        provisioned at all.

        @param os_clients: Clients to be used to provision the resources.
        """
        if not CONF.validation.run_validation:
            return

        if os_clients in cls._validation_resources:
            return cls._validation_resources[os_clients]

        if (CONF.validation.ip_version_for_ssh not in (4, 6) and
                CONF.service_available.neutron):
            msg = "Invalid IP version %s in ip_version_for_ssh. Use 4 or 6"
            raise lib_exc.InvalidConfiguration(
                msg % CONF.validation.ip_version_for_ssh)

        resources = vr.create_validation_resources(
            os_clients,
            **cls._validation_resources_params_from_conf())

        cls.addClassResourceCleanup(
            vr.clear_validation_resources, os_clients,
            use_neutron=CONF.service_available.neutron,
            **resources)
        cls._validation_resources[os_clients] = resources
        return resources