def test_use_data_volumes(self, mock_tasks): volume_type = openstack_tenant_factories.VolumeTypeFactory( settings=self.fixture.tenant_spl.service.settings) self.payload = { 'cluster': factories.ClusterFactory.get_url(self.fixture.cluster), 'subnet': openstack_tenant_factories.SubNetFactory.get_url(self.subnet), 'system_volume_size': 1024, 'memory': 1, 'cpu': 1, 'roles': ['controlplane', 'etcd', 'worker'], 'data_volumes': [{ 'size': 12 * 1024, 'volume_type': openstack_tenant_factories.VolumeTypeFactory.get_url( volume_type), 'mount_point': '/var/lib/etcd', }], } response = self.create_node(self.fixture.staff) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(self.fixture.cluster.node_set.count(), 2) node = self.fixture.cluster.node_set.exclude(name='').get() self.assertEqual(len(node.initial_data['data_volumes']), 1)
def test_if_mount_point_is_required(self, mock_tasks): volume_type = openstack_tenant_factories.VolumeTypeFactory( settings=self.fixture.tenant_spl.service.settings) self.payload = { 'cluster': factories.ClusterFactory.get_url(self.fixture.cluster), 'subnet': openstack_tenant_factories.SubNetFactory.get_url(self.subnet), 'system_volume_size': 1024, 'memory': 1, 'cpu': 1, 'roles': ['controlplane', 'etcd', 'worker'], 'data_volumes': [{ 'size': 12 * 1024, 'volume_type': openstack_tenant_factories.VolumeTypeFactory.get_url( volume_type), }], } response = self.create_node(self.fixture.staff) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_disable_data_volumes(self, mock_core_tasks): self.client.force_authenticate(self.fixture.owner) volume_type = openstack_tenant_factories.VolumeTypeFactory( settings=self.fixture.tenant_settings ) payload = { 'nodes': [ { 'subnet': openstack_tenant_factories.SubNetFactory.get_url( self.subnet ), 'system_volume_size': 1024, 'memory': 1, 'cpu': 1, 'roles': ['controlplane', 'etcd', 'worker'], 'data_volumes': [ { 'size': 12 * 1024, 'volume_type': openstack_tenant_factories.VolumeTypeFactory.get_url( volume_type ), 'mount_point': '/var/lib/etcd', } ], } ] } response = self._create_request_('new-cluster', add_payload=payload) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertTrue(models.Cluster.objects.filter(name='new-cluster').exists()) cluster = models.Cluster.objects.get(name='new-cluster') self.assertEqual(len(cluster.node_set.first().initial_data['data_volumes']), 0)
def volume_type(self): return factories.VolumeTypeFactory( settings=self.openstack_tenant_service_settings, )