示例#1
0
    def setUp(self):
        super(DistributionUpgradeTests, self).setUp()

        units.SKIP_FILES = True

        # The unique keys need to be set for these tests
        units._initialize_content_types(self.tmp_test_db.database)
示例#2
0
    def test_initialize_content_types_idempotency(self):
        # Test
        units._initialize_content_types(self.tmp_test_db.database)
        result = units._initialize_content_types(self.tmp_test_db.database)

        # Verify
        self.assertTrue(result)

        types_coll = self.tmp_test_db.database.content_types
        all_types = types_coll.find()
        self.assertEqual(all_types.count(), len(units.TYPE_DEFS))
示例#3
0
    def setUp(self):
        super(DRPMUpgradeTests, self).setUp()
        new_repo = {
                'id' : 'test_drpm_repo',
                'content_types' : 'yum',
                'repomd_xml_path' : os.path.join(
                    V1_REPOS_DIR, 'repos/pulp/pulp/demo_repos/test_drpm_repo/repodata/repomd.xml'),
                'relative_path' : 'repos/pulp/pulp/demo_repos/test_drpm_repo/',
            }
        if self.v1_test_db.database.repos.find_one({'id' : 'test_drpm_repo'}):
            self.v1_test_db.database.repos.remove({'id' : 'test_drpm_repo'})
        self.v1_test_db.database.repos.insert(new_repo, safe=True)

        # The unique keys need to be set for these tests
        units._initialize_content_types(self.tmp_test_db.database)
示例#4
0
    def test_iso_idempotency(self):
        # Setup
        report = UpgradeStepReport()
        units._initialize_content_types(self.tmp_test_db.database)
        units._isos(self.v1_test_db.database, self.tmp_test_db.database, report)

        # Test
        success = units._isos(self.v1_test_db.database, self.tmp_test_db.database, report)

        # Verify
        self.assertTrue(success)

        v1_count = self.v1_test_db.database.file.find().count()
        v2_count = self.tmp_test_db.database.units_iso.find().count()

        self.assertEqual(v1_count, v2_count)
示例#5
0
    def setUp(self):
        super(DRPMUpgradeTests, self).setUp()
        new_repo = {
            "id": "test_drpm_repo",
            "content_types": "yum",
            "repomd_xml_path": os.path.join(
                V1_REPOS_DIR, "repos/pulp/pulp/demo_repos/test_drpm_repo/repodata/repomd.xml"
            ),
            "relative_path": "repos/pulp/pulp/demo_repos/test_drpm_repo/",
        }
        if self.v1_test_db.database.repos.find_one({"id": "test_drpm_repo"}):
            self.v1_test_db.database.repos.remove({"id": "test_drpm_repo"})
        self.v1_test_db.database.repos.insert(new_repo, safe=True)

        # The unique keys need to be set for these tests
        units._initialize_content_types(self.tmp_test_db.database)
示例#6
0
    def test_initialize_content_types(self):
        # Test
        result = units._initialize_content_types(self.tmp_test_db.database)

        # Verify
        self.assertTrue(result)

        types_coll = self.tmp_test_db.database.content_types
        migrations_coll = self.tmp_test_db.database.migration_trackers

        # Verify the proper creation of these collections
        types_indexes = types_coll.index_information()
        self.assertTrue('id_-1' in types_indexes)
        self.assertEqual(types_indexes['id_-1']['unique'], True)

        migrations_indexes = migrations_coll.index_information()
        self.assertTrue('name_-1' in migrations_indexes)
        self.assertEqual(migrations_indexes['name_-1']['unique'], True)

        for type_def in units.TYPE_DEFS:
            unit_coll = getattr(self.tmp_test_db.database, units._units_collection_name(type_def['id']))
            indexes = unit_coll.index_information()
            indexes.pop('_id_') # remove the default one, the other is named weird and this is easier

            total_index_count = len(type_def['search_indexes']) + 1 # 1 for unit key
            self.assertEqual(len(indexes), total_index_count)

        # Verify the data itself
        for type_def in units.TYPE_DEFS:
            found_type = types_coll.find_one({'id' : type_def['id']})
            self.assertTrue(found_type is not None)
            self.assertTrue(isinstance(found_type['_id'], ObjectId))
            self.assertEqual(found_type['id'], type_def['id'])
            self.assertEqual(found_type['display_name'], type_def['display_name'])
            self.assertEqual(found_type['description'], type_def['description'])
            self.assertEqual(found_type['unit_key'], type_def['unit_key'])
            self.assertEqual(found_type['search_indexes'], type_def['search_indexes'])
            self.assertEqual(found_type['referenced_types'], type_def['referenced_types'])

            found_tracker = migrations_coll.find_one({'name' : type_def['display_name']})
            self.assertTrue(found_tracker is not None)
            self.assertTrue(isinstance(found_tracker['_id'], ObjectId))
            self.assertEqual(found_tracker['name'], type_def['display_name'])
            self.assertEqual(found_tracker['version'], 0)
示例#7
0
    def setUp(self):
        super(PackagesUpgradeTests, self).setUp()

        # The unique keys need to be set for these tests
        units._initialize_content_types(self.tmp_test_db.database)
        units._initialize_association_collection(self.tmp_test_db.database)