Exemplo n.º 1
0
 def test_cascade_release_deletion(self):
     release_component_table = self.meta.tables['release_components']
     release_table = self.meta.tables['releases']
     release_id = insert_table_row(
         release_table,
         {
             'name': 'release_with_components',
             'version': '2014.2.2-6.1',
             'operating_system': 'ubuntu',
             'state': 'available'
         }
     )
     component_id = insert_table_row(
         self.meta.tables['components'],
         {'name': six.text_type(uuid.uuid4()), 'type': 'hypervisor'}
     )
     insert_table_row(
         release_component_table,
         {'release_id': release_id, 'component_id': component_id}
     )
     db.execute(
         sa.delete(release_table).where(release_table.c.id == release_id))
     deleted_plugin_components = db.execute(
         sa.select([sa.func.count(release_component_table.c.id)]).
         where(release_component_table.c.release_id == release_id)
     ).fetchone()[0]
     self.assertEqual(deleted_plugin_components, 0)
Exemplo n.º 2
0
def prepare():
    meta = base.reflect_db_metadata()

    releaseid = insert_table_row(
        meta.tables["releases"],
        {"name": "test_name", "version": "2014.2.2-6.1", "operating_system": "ubuntu", "state": "available"},
    )

    clusterid = insert_table_row(
        meta.tables["clusters"],
        {
            "name": "test_env",
            "release_id": releaseid,
            "mode": "ha_compact",
            "status": "new",
            "net_provider": "neutron",
            "grouping": "roles",
            "fuel_version": "6.1",
        },
    )

    db.execute(
        meta.tables["nodegroups"].insert(),
        [
            {"cluster_id": clusterid, "name": "test_nodegroup_a"},
            {"cluster_id": clusterid, "name": "test_nodegroup_a"},
            {"cluster_id": clusterid, "name": "test_nodegroup_b"},
            {"cluster_id": clusterid, "name": "test_nodegroup_b"},
        ],
    )

    db.commit()
Exemplo n.º 3
0
    def test_new_columns_exist(self):
        deployment_graphs_table = self.meta.tables['deployment_graphs']
        db.execute(
            deployment_graphs_table.insert(),
            {
                'name': 'test',
                'node_filter': '$.status == ready',
                'on_success': '{"node_attributes": {"status": "new"}}',
                'on_error': '{"node_attributes": {"status": "error"}}',
                'on_stop': '{}'
            }
        )

        result = db.execute(
            sa.select([
                deployment_graphs_table.c.node_filter,
                deployment_graphs_table.c.on_success,
                deployment_graphs_table.c.on_error,
                deployment_graphs_table.c.on_stop,
            ]).where(deployment_graphs_table.c.name == 'test')
        ).first()

        self.assertEqual('$.status == ready', result['node_filter'])
        self.assertEqual(
            '{"node_attributes": {"status": "new"}}', result['on_success']
        )
        self.assertEqual(
            '{"node_attributes": {"status": "error"}}', result['on_error']
        )
        self.assertEqual('{}', result['on_stop'])
 def test_tun_segment_type_added(self):
     result = db.execute(
         self.meta.tables["networking_configs"].insert(),
         [
             {
                 "cluster_id": None,
                 "dns_nameservers": ["8.8.8.8"],
                 "floating_ranges": [],
                 "configuration_template": None,
             }
         ],
     )
     db.execute(
         self.meta.tables["neutron_config"].insert(),
         [
             {
                 "id": result.inserted_primary_key[0],
                 "vlan_range": [],
                 "gre_id_range": [],
                 "base_mac": "00:00:00:00:00:00",
                 "internal_cidr": "10.10.10.00/24",
                 "internal_gateway": "10.10.10.01",
                 "segmentation_type": "tun",
                 "net_l23_provider": "ovs",
             }
         ],
     )
     types = db.execute(sa.select([self.meta.tables["neutron_config"].c.segmentation_type])).fetchall()
     self.assertIn(("tun",), types)
 def test_new_fields_exists_and_empty(self):
     # check node_nic_interfaces fields
     result = db.execute(sa.select([self.meta.tables["node_nic_interfaces"].c.offloading_modes]))
     self.assertEqual(jsonutils.loads(result.fetchone()[0]), [])
     # the same for bond interfaces
     result = db.execute(sa.select([self.meta.tables["node_bond_interfaces"].c.offloading_modes]))
     self.assertEqual(jsonutils.loads(result.fetchone()[0]), [])
 def test_baremetal_fields_saving(self):
     baremetal_gateway = '192.168.3.51'
     baremetal_range = jsonutils.dumps(['192.168.3.52', '192.168.3.254'])
     result = db.execute(
         self.meta.tables['networking_configs'].insert(),
         [{
             'cluster_id': None,
             'dns_nameservers': ['8.8.8.8'],
             'floating_ranges': [],
             'configuration_template': None,
         }])
     db.execute(
         self.meta.tables['neutron_config'].insert(),
         [{
             'id': result.inserted_primary_key[0],
             'vlan_range': [],
             'gre_id_range': [],
             'base_mac': '00:00:00:00:00:00',
             'internal_cidr': '10.10.10.00/24',
             'internal_gateway': '10.10.10.01',
             'internal_name': 'my_internal_name',
             'floating_name': 'my_floating_name',
             'baremetal_gateway': baremetal_gateway,
             'baremetal_range': baremetal_range,
             'segmentation_type': 'vlan',
             'net_l23_provider': 'ovs'
         }])
     result = db.execute(
         sa.select(
             [self.meta.tables['neutron_config'].c.baremetal_gateway,
              self.meta.tables['neutron_config'].c.baremetal_range])).\
         fetchall()
     self.assertIn((baremetal_gateway, baremetal_range), result)
    def test_openstack_configs_table_saving(self):
        result = db.execute(
            sa.select([self.meta.tables['clusters'].c.id]))
        cluster_id = result.fetchone()[0]

        db.execute(
            self.meta.tables['openstack_configs'].insert(),
            [{
                'cluster_id': cluster_id,
                'is_active': True,
                'config_type': 'cluster',
                'node_id': None,
                'node_role': None,
                'created_at': datetime.now(),
                'configuration': jsonutils.dumps({
                    'config_a': {},
                    'config_b': {},
                }),
            }]
        )

        result = db.execute(
            sa.select([self.meta.tables['openstack_configs'].c.cluster_id]))
        config = result.fetchone()
        self.assertEqual(config[0], cluster_id)
 def test_unique_name_fields_insert_unique(self):
     nodegroup = db.execute(
         sa.select([self.meta.tables['nodegroups'].c.cluster_id,
                    self.meta.tables['nodegroups'].c.name])).fetchone()
     db.execute(self.meta.tables['nodegroups'].insert(),
                [{'cluster_id': nodegroup['cluster_id'],
                  'name': six.text_type(uuid.uuid4())}])
    def test_moving_plugin_attributes(self):
        clusters = self.meta.tables['clusters']
        attributes = self.meta.tables['attributes']
        plugins = self.meta.tables['plugins']
        cluster_plugins = self.meta.tables['cluster_plugins']

        query = sa.select([attributes.c.editable])\
            .select_from(
                sa.join(
                    attributes, clusters,
                    attributes.c.cluster_id == clusters.c.id))
        result = jsonutils.loads(db.execute(query).fetchone()[0])
        self.assertItemsEqual(result, {})

        query = sa.select([cluster_plugins.c.attributes])\
            .select_from(
                sa.join(
                    cluster_plugins, plugins,
                    cluster_plugins.c.plugin_id == plugins.c.id))\
            .where(plugins.c.name == 'test_plugin_a')
        result = jsonutils.loads(db.execute(query).fetchone()[0])
        self.assertNotIn('metadata', result)
        self.assertItemsEqual(result['attribute'], {
            'value': 'value',
            'type': 'text',
            'description': 'description',
            'weight': 25,
            'label': 'label'
        })
 def test_tun_segment_type_added(self):
     result = db.execute(
         self.meta.tables['networking_configs'].insert(),
         [{
             'cluster_id': None,
             'dns_nameservers': ['8.8.8.8'],
             'floating_ranges': [],
             'configuration_template': None,
         }])
     db.execute(
         self.meta.tables['neutron_config'].insert(),
         [{
             'id': result.inserted_primary_key[0],
             'vlan_range': [],
             'gre_id_range': [],
             'base_mac': '00:00:00:00:00:00',
             'internal_cidr': '10.10.10.00/24',
             'internal_gateway': '10.10.10.01',
             'segmentation_type': 'tun',
             'net_l23_provider': 'ovs'
         }])
     types = db.execute(
         sa.select(
             [self.meta.tables['neutron_config'].c.segmentation_type])).\
         fetchall()
     self.assertIn(('tun',), types)
 def test_network_group_name_is_string(self):
     db.execute(
         self.meta.tables["network_groups"].insert(),
         [{"id": 3, "name": "custom_name", "vlan_start": None, "cidr": "10.20.0.0/24", "gateway": "10.20.0.200"}],
     )
     names = db.execute(sa.select([self.meta.tables["network_groups"].c.name])).fetchall()
     self.assertIn(("custom_name",), names)
Exemplo n.º 12
0
    def test_new_fields_exists_and_empty(self):
        # check attributes_metadata field exists
        result = db.execute(
            sa.select([self.meta.tables['plugins'].c.attributes_metadata]))
        # check attributes_metadata value is empty
        self.assertEqual(
            jsonutils.loads(result.fetchone()[0]), {})

        result = db.execute(
            sa.select([self.meta.tables['plugins'].c.volumes_metadata]))
        self.assertEqual(
            jsonutils.loads(result.fetchone()[0]), {})

        result = db.execute(
            sa.select([self.meta.tables['plugins'].c.roles_metadata]))
        self.assertEqual(
            jsonutils.loads(result.fetchone()[0]), {})

        result = db.execute(
            sa.select([self.meta.tables['plugins'].c.deployment_tasks]))
        self.assertEqual(
            jsonutils.loads(result.fetchone()[0]), [])

        result = db.execute(
            sa.select([self.meta.tables['plugins'].c.tasks]))
        self.assertEqual(
            jsonutils.loads(result.fetchone()[0]), [])
Exemplo n.º 13
0
def prepare():
    meta = base.reflect_db_metadata()

    result = db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2015.1-8.0',
            'operating_system': 'ubuntu',
            'state': 'available',
            'networks_metadata': jsonutils.dumps({
                'neutron': {
                    'networks': [],
                    'config': {}
                }
            })
        }]
    )
    releaseid = result.inserted_primary_key[0]

    db.execute(
        meta.tables['clusters'].insert(),
        [{
            'name': 'test_env',
            'release_id': releaseid,
            'mode': 'ha_compact',
            'status': 'new',
            'net_provider': 'neutron',
            'grouping': 'roles',
            'fuel_version': '8.0',
            'deployment_tasks': '[]',
            'replaced_deployment_info': '{}'
        }])

    db.commit()
Exemplo n.º 14
0
def prepare():
    meta = base.reflect_db_metadata()

    result = db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2015.1-10.0',
            'operating_system': 'ubuntu',
            'state': 'available',
            'deployment_tasks': '{}',
            'roles': '{}',
            'roles_metadata': '{}',
            'is_deployable': True,
            'required_component_types': ['network', 'storage']
        }]
    )

    release_id = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['clusters'].insert(),
        [{
            'name': 'test',
            'release_id': release_id,
            'mode': 'ha_compact',
            'status': 'new',
            'net_provider': 'neutron',
            'grouping': 'roles',
            'fuel_version': '10.0',
        }]
    )
    cluster_id = result.inserted_primary_key[0]

    TestPluginLinksConstraints.prepare(meta, cluster_id)
Exemplo n.º 15
0
    def prepare(cls, meta, cluster_id):
        cls.test_link['cluster_id'] = cluster_id

        db.execute(
            meta.tables['cluster_plugin_links'].insert(),
            [cls.test_link],
        )
Exemplo n.º 16
0
    def test_cluster_status_upgraded(self):
        clusters_table = self.meta.tables['clusters']
        columns = [clusters_table.c.id, clusters_table.c.status]
        cluster = db.execute(sa.select(columns)).fetchone()

        db.execute(clusters_table.update().where(
            clusters_table.c.id == cluster.id
        ).values(status='partially_deployed'))
Exemplo n.º 17
0
 def test_unique_name_fields_insert_unique(self):
     nodegroup = db.execute(
         sa.select([self.meta.tables["nodegroups"].c.cluster_id, self.meta.tables["nodegroups"].c.name])
     ).fetchone()
     db.execute(
         self.meta.tables["nodegroups"].insert(),
         [{"cluster_id": nodegroup["cluster_id"], "name": six.text_type(uuid.uuid4())}],
     )
    def test_extensions_field_with_default_data(self):
        cluster_result = db.execute(
            sa.select([self.meta.tables['clusters'].c.extensions])).fetchone()
        release_result = db.execute(
            sa.select([self.meta.tables['releases'].c.extensions])).fetchone()

        self.assertEqual(list(cluster_result)[0], ['volume_manager'])
        self.assertEqual(list(release_result)[0], ['volume_manager'])
 def test_new_field_exists_and_filled(self):
     nic_table = self.meta.tables["node_nic_interfaces"]
     result = db.execute(sa.select([nic_table.c.pxe]).where(nic_table.c.id == 1))
     # check 'pxe' property is true for admin interfaces
     self.assertTrue(result.fetchone()[0])
     result = db.execute(sa.select([nic_table.c.pxe]).where(nic_table.c.id != 1))
     # and 'false' for any others
     for res in result.fetchall():
         self.assertFalse(res[0])
Exemplo n.º 20
0
    def test_downgrade_field_tags_from_roles(self):
        releases = self.meta.tables['releases']
        query = sa.select([releases.c.roles_metadata])
        for role_meta in db.execute(query).fetchall():
            self.assertNotIn('tags', role_meta)

        plugins = self.meta.tables['plugins']
        query = sa.select([plugins.c.roles_metadata])
        for role_meta in db.execute(query):
            self.assertNotIn('tags', role_meta)
    def test_new_fields_exists_and_empty(self):
        result = db.execute(
            sa.select([self.meta.tables['networking_configs']
                       .c.configuration_template]))
        self.assertIsNone(result.fetchone()[0])

        result = db.execute(
            sa.select([self.meta.tables['nodes']
                       .c.network_template]))
        self.assertIsNone(result.fetchone()[0])
Exemplo n.º 22
0
 def test_minimal_task_creation_success(self):
     deployment_graph_id = self._insert_deployment_graph()
     db.execute(
         self.meta.tables['deployment_graph_tasks'].insert(),
         {
             'deployment_graph_id': deployment_graph_id,
             'task_name': 'minimal task',
             'type': 'puppet'
         },
     )
Exemplo n.º 23
0
    def test_split_deployment_info(self):
        node_di_table = self.meta.tables['node_deployment_info']
        res = db.execute(sa.select([node_di_table]))
        for data in res:
            self.assertEqual(jsonutils.loads(data.deployment_info),
                             DEPLOYMENT_INFO[data.task_id][data.node_uid])

        tasks_table = self.meta.tables['tasks']
        res = db.execute(sa.select([tasks_table]))
        for data in res:
            self.assertIsNone(data.deployment_info)
 def prepare(cls, meta):
     db.execute(
         meta.tables['releases'].insert(),
         [{
             'name': cls.release_name,
             'version': cls.version,
             'operating_system': 'ubuntu',
             'state': 'available',
             'roles_metadata': '{}',
             'is_deployable': True
         }])
Exemplo n.º 25
0
 def test_field_reset_nodes_exist(self):
     db.execute(
         self.meta.tables['tasks'].insert(),
         [
             {
                 'uuid': 'fake_task_uuid_0',
                 'name': 'reset_nodes',
                 'status': 'pending'
             }
         ]
     )
Exemplo n.º 26
0
 def test_field_remove_ironic_bootstrap_exist(self):
     db.execute(
         self.meta.tables['tasks'].insert(),
         [
             {
                 'uuid': 'fake_task_uuid_0',
                 'name': 'remove_ironic_bootstrap',
                 'status': 'pending'
             }
         ]
     )
Exemplo n.º 27
0
 def test_fields_exist(self):
     db.execute(
         self.meta.tables['tasks'].insert(),
         [
             {
                 'uuid': 'fake_task_uuid_0',
                 'name': 'dry_run_deployment',
                 'status': 'pending'
             }
         ]
     )
Exemplo n.º 28
0
    def test_duplicate_cluster_link(self):
        db.execute(
            self.meta.tables['cluster_plugin_links'].insert(),
            [self.test_link]
        )

        links_count = db.execute(
            sa.select(
                [sa.func.count(self.meta.tables['cluster_plugin_links'].c.id)]
            )).fetchone()[0]
        self.assertEqual(links_count, 2)
    def test_split_deployment_info(self):
        node_di_table = self.meta.tables['node_deployment_info']
        res = db.execute(sa.select([node_di_table]))
        for data in res:
            self.assertEqual(jsonutils.loads(data.deployment_info),
                             DEPLOYMENT_INFO[data.task_id][data.node_uid])

        tasks_table = self.meta.tables['tasks']
        res = db.execute(sa.select([tasks_table]))
        for data in res:
            self.assertIsNone(data.deployment_info)
Exemplo n.º 30
0
    def test_graph_type_field_exist(self):
        db.execute(
            self.meta.tables['tasks'].insert(),
            [{
                'uuid': 'fake_task_uuid_0',
                'name': 'dump',
                'status': 'pending',
            }]
        )

        result = db.execute(sa.select([self.meta.tables['tasks']])).first()
        self.assertIn('graph_type', result)
    def test_cobbler_profile_updated(self):
        result = db.execute(
            sa.select([self.meta.tables['attributes'].c.generated]))
        generated = jsonutils.loads(result.fetchone()[0])
        self.assertEqual(generated['cobbler']['profile'], 'ubuntu_1404_x86_64')

        result = db.execute(sa.select(
            [self.meta.tables['releases'].c.attributes_metadata]))
        attrs_metadata = jsonutils.loads(result.fetchone()[0])
        self.assertEqual(
            attrs_metadata['generated']['cobbler']['profile']['generator_arg'],
            'ubuntu_1404_x86_64')