Example #1
0
    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                             project=self.project,
                             username=self.user,
                             password=self.password,
                             port=self.port)
        self.org_api = Organization()
        self.env_api = Environment()

        self.start_time = time.time()
Example #2
0
    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                             project=self.project,
                             username=self.user,
                             password=self.password)
        self.org_api = Organization()
        self.ak_api = ActivationKey()
        self.env_api = Environment()
        self.prd_api = Product()
        self.prv_api = Provider()
        self.repo_api = Repository()
        self.sys_api = System()

        self.start_time = time.time()
Example #3
0
    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                             project=self.project,
                             username=self.user,
                             password=self.password,
                             port=self.port)
        self.org_api = Organization()
        self.chs_api = Changeset()
        self.cv_api = ContentView()
        self.cvd_api = ContentViewDefinition()
        self.env_api = Environment()
        self.prd_api = Product()
        self.prv_api = Provider()
        self.repo_api = Repository()
        self.sys_api = System()

        self.start_time = time.time()
Example #4
0
    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                       project=self.project,
                       username=self.user,
                       password=self.password,
                       port=self.port)
        self.org_api = Organization()
        self.env_api = Environment()

        self.start_time = time.time()
Example #5
0
    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                       project=self.project,
                       username=self.user,
                       password=self.password)
        self.org_api = Organization()
        self.ak_api = ActivationKey()
        self.env_api = Environment()
        self.prd_api = Product()
        self.prv_api = Provider()
        self.repo_api = Repository()
        self.sys_api = System()

        self.start_time = time.time()
Example #6
0
    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                       project=self.project,
                       username=self.user,
                       password=self.password,
                       port=self.port)
        self.org_api = Organization()
        self.chs_api = Changeset()
        self.cv_api = ContentView()
        self.cvd_api = ContentViewDefinition()
        self.env_api = Environment()
        self.prd_api = Product()
        self.prv_api = Provider()
        self.repo_api = Repository()
        self.sys_api = System()

        self.start_time = time.time()
Example #7
0
    def setUp(self):
        self.host = os.getenv('KATELLO_HOST')
        self.port = os.getenv('KATELLO_PORT', '443')
        self.project = os.getenv('PROJECT', '/katello')

        # Make sure that PROJECT starts with a leading "/"
        if not self.project.startswith("/"): self.project = "/" + self.project

        self.user = os.getenv('KATELLO_USERNAME', None)
        self.password = os.getenv('KATELLO_PASSWORD', None)

        self.server = Server(host=self.host,
                             project=self.project,
                             username=self.user,
                             password=self.password,
                             port=self.port)

        self.verbosity = int(os.getenv('VERBOSITY', 3))

        logging.config.fileConfig("logging.conf")

        self.logger = logging.getLogger("mangonel")
        self.logger.setLevel(self.verbosity * 10)

        self.ak_api = ActivationKey()
        self.chs_api = Changeset()
        self.cv_api = ContentView()
        self.cvd_api = ContentViewDefinition()
        self.env_api = Environment()
        self.org_api = Organization()
        self.prd_api = Product()
        self.prv_api = Provider()
        self.repo_api = Repository()
        self.sys_api = System()
        self.sys_grp_api = SystemGroup()
        self.user_api = User()

        self.start_time = time.time()
Example #8
0
class TestOrganizations(BaseTest):

    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                       project=self.project,
                       username=self.user,
                       password=self.password,
                       port=self.port)
        self.org_api = Organization()
        self.env_api = Environment()

        self.start_time = time.time()


    def tearDown(self):
        self.server = None

        self.ellapsed_time = time.time() - self.start_time
        self.logger.info("Test ellapsed time: %s" % self.ellapsed_time)

    def test_create_org1(self):
        "Creates a new organization."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']), 'Failed to create and retrieve org.')


    def test_create_org2(self):
        "Creates a new organization and then deletes it."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']), 'Failed to create and retrieve org.')

        self.logger.info("Deleting organization %s" % org['name'])
        self.org_api.delete(org['name'])
        self.assertRaises(ServerRequestError, lambda: self.org_api.organization(org['name']))


    def test_create_org3(self):
        "Creates a new organization with an initial environment."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']), 'Failed to create and retrieve org.')

        env = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Dev'))


    def test_create_org4(self):
        "Creates a new organization with several environments."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']), 'Failed to create and retrieve org.')

        env = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Dev'))

        env = self.env_api.create_environment(org, 'Testing', 'Dev')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Testing'))

        env = self.env_api.create_environment(org, 'Release', 'Testing')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Release'))
Example #9
0
class TestSystemGroups(BaseTest):
    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                             project=self.project,
                             username=self.user,
                             password=self.password,
                             port=self.port)
        self.org_api = Organization()
        self.env_api = Environment()
        self.sys_api = System()
        self.sys_grp_api = SystemGroup()

        self.start_time = time.time()

    def tearDown(self):
        self.server = None

        self.ellapsed_time = time.time() - self.start_time
        self.logger.info("Test ellapsed time: %s" % self.ellapsed_time)

    def _create_org_env(self):
        "Generic method to create a new organization and one environment"

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']),
                         'Failed to create and retrieve org.')

        env = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Dev'))

        return (org, env)

    def test_create_system_group_1(self):
        "Creates an empty system group."

        (org, env) = self._create_org_env()

        grp = self.sys_grp_api.create(org)
        self.assertEqual(grp, self.sys_grp_api.system_group(org, grp['id']))
        self.logger.debug("Created system group '%s'" % grp['name'])

    def test_create_and_delete_system_group_1(self):
        "Creates an empty system group and deletes it."

        (org, env) = self._create_org_env()

        grp = self.sys_grp_api.create(org)
        self.assertEqual(grp, self.sys_grp_api.system_group(org, grp['id']))
        self.logger.debug("Created system group '%s'" % grp['name'])

        self.sys_grp_api.delete(org, grp['id'])
        self.assertRaises(
            ServerRequestError,
            lambda: self.sys_grp_api.system_group(org, grp['id']))
        self.logger.debug("Deleted system group '%s'" % grp['name'])

    def test_create_and_copy_system_group_1(self):
        "Creates system group and copies it."
        (org, env) = self._create_org_env()

        grp1 = self.sys_grp_api.create(org)
        self.assertEqual(grp1, self.sys_grp_api.system_group(org, grp1['id']))
        self.logger.debug("Created system group '%s'" % grp1['name'])

        grp2 = self.sys_grp_api.create(org)
        self.assertEqual(grp2, self.sys_grp_api.system_group(org, grp2['id']))
        self.logger.debug("Created system group '%s'" % grp2['name'])
        self.assertEqual(len(self.sys_grp_api.system_groups(org)), 2)

    def test_create_system_group_with_system_1(self):
        "Creates system group and adds a system to it."
        (org, env) = self._create_org_env()

        grp = self.sys_grp_api.create(org)
        self.assertEqual(grp, self.sys_grp_api.system_group(org, grp['id']))
        self.logger.debug("Created system group '%s'" % grp['name'])

        sys1 = self.sys_api.create_system(org, env)
        self.logger.debug("Created system %s" % sys1['uuid'])
        self.assertEqual(sys1['uuid'],
                         self.sys_api.system(sys1['uuid'])['uuid'])

        self.assertEqual(
            len(self.sys_grp_api.system_group_systems(org, grp['id'])), 0)
        self.logger.debug("System group '%s' is empty" % grp['name'])

        self.sys_grp_api.add_systems(org, grp['id'], [
            sys1['uuid'],
        ])
        self.assertEqual(
            len(self.sys_grp_api.system_group_systems(org, grp['id'])), 1)
        self.logger.debug("System group '%s' is not empty" % grp['name'])

    def test_create_system_group_with_system_and_delete_1(self):
        "Creates system group and adds a system to it."
        (org, env) = self._create_org_env()

        grp = self.sys_grp_api.create(org)
        self.assertEqual(grp, self.sys_grp_api.system_group(org, grp['id']))
        self.logger.debug("Created system group '%s'" % grp['name'])

        sys1 = self.sys_api.create_system(org, env)
        self.logger.debug("Created system %s" % sys1['uuid'])
        self.assertEqual(sys1['uuid'],
                         self.sys_api.system(sys1['uuid'])['uuid'])
        self.assertEqual(
            len(self.sys_grp_api.system_group_systems(org, grp['id'])), 0)
        self.logger.debug("System group '%s' is empty" % grp['name'])

        self.sys_grp_api.add_systems(org, grp['id'], [
            sys1['uuid'],
        ])
        self.assertEqual(
            len(self.sys_grp_api.system_group_systems(org, grp['id'])), 1)
        self.logger.debug("System group '%s' is not empty" % grp['name'])

        self.sys_grp_api.remove_systems(org, grp['id'], [
            sys1['uuid'],
        ])
        self.assertEqual(
            len(self.sys_grp_api.system_group_systems(org, grp['id'])), 0)
        self.logger.debug("System group '%s' is empty" % grp['name'])

    def test_create_system_group_with_system_and_copy_1(self):
        "Creates system group, adds a system to it and copies it."
        (org, env) = self._create_org_env()

        grp1 = self.sys_grp_api.create(org)
        self.assertEqual(grp1, self.sys_grp_api.system_group(org, grp1['id']))
        self.logger.debug("Created system group '%s'" % grp1['name'])

        sys1 = self.sys_api.create_system(org, env)
        self.logger.debug("Created system %s" % sys1['uuid'])
        self.assertEqual(sys1['uuid'],
                         self.sys_api.system(sys1['uuid'])['uuid'])

        self.assertEqual(
            len(self.sys_grp_api.system_group_systems(org, grp1['id'])), 0)
        self.logger.debug("System group '%s' is empty" % grp1['name'])

        self.sys_grp_api.add_systems(org, grp1['id'], [
            sys1['uuid'],
        ])
        self.assertEqual(
            len(self.sys_grp_api.system_group_systems(org, grp1['id'])), 1)
        self.logger.debug("System group '%s' is not empty" % grp1['name'])

        grp2 = self.sys_grp_api.copy(org, grp1['id'])
        self.assertEqual(grp2, self.sys_grp_api.system_group(org, grp2['id']))
        self.logger.debug("Created system group '%s'" % grp2['name'])
        self.assertEqual(len(self.sys_grp_api.system_groups(org)), 2)
        self.assertEqual(
            len(self.sys_grp_api.system_group_systems(org, grp2['id'])), 1)
        self.logger.debug("System group '%s' is not empty" % grp2['name'])
Example #10
0
class TestStress(BaseTest):
    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                             project=self.project,
                             username=self.user,
                             password=self.password,
                             port=self.port)
        self.org_api = Organization()
        self.chs_api = Changeset()
        self.cv_api = ContentView()
        self.cvd_api = ContentViewDefinition()
        self.env_api = Environment()
        self.prd_api = Product()
        self.prv_api = Provider()
        self.repo_api = Repository()
        self.sys_api = System()

        self.start_time = time.time()

    def tearDown(self):
        self.server = None

        self.ellapsed_time = time.time() - self.start_time
        self.logger.info("Test ellapsed time: %s" % self.ellapsed_time)

    def test_stress_128_1(self):
        "Creates a new organization with environment and register a system."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']),
                         'Failed to create and retrieve org.')

        env1 = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environmemt %s" % env1['name'])
        self.assertEqual(env1, self.env_api.environment_by_name(org, 'Dev'))

        env2 = self.env_api.create_environment(org, 'Testing', 'Dev')
        self.logger.debug("Created environmemt %s" % env2['name'])
        self.assertEqual(env2,
                         self.env_api.environment_by_name(org, 'Testing'))

        env3 = self.env_api.create_environment(org, 'Release', 'Testing')
        self.logger.debug("Created environmemt %s" % env3['name'])
        self.assertEqual(env3,
                         self.env_api.environment_by_name(org, 'Release'))

        prv = self.prv_api.create_provider(org, 'Provider1')
        self.logger.debug("Created custom provider Provider1")
        self.assertEqual(prv, self.prv_api.provider(prv['id']))

        prd = self.prd_api.create_product(prv, 'Product1')
        self.logger.debug("Created product Product1")
        self.assertEqual(prd['id'], self.prd_api.product(org, prd['id'])['id'])

        repo = self.repo_api.create_repository(
            org, prd, 'http://hhovsepy.fedorapeople.org/fakerepos/zoo4/',
            'Repo1')
        self.logger.debug("Created repositiry Repo1")
        self.assertEqual(repo, self.repo_api.repository(repo['id']))

        # Sync
        self.prv_api.sync(prv['id'])
        self.assertEqual(
            self.prv_api.provider(prv['id'])['sync_state'], 'finished')
        self.logger.debug("Finished synchronizing Provider1")

        # Content View Definition
        cvd = self.cvd_api.create_content_view_definition(org, 'CVD1')
        self.logger.debug("Created Content View Definition CVD1")
        prods = self.cvd_api.update_products(org, cvd['id'], prd)
        self.logger.debug("Added %s to Content View Definition" % prd['name'])

        # Published Content view
        self.cvd_api.publish(org, cvd['id'], 'PublishedCVD1')
        pcvd = self.cv_api.content_views_by_label_name_or_id(
            org, name='PublishedCVD1')
        self.logger.debug("Published Content View PublishedCVD1")

        # Changeset
        chs = self.chs_api.create(org, env1, 'Promote01')
        self.logger.debug("Created promotion changeset Promote01")
        self.chs_api.add_content(chs['id'], pcvd)
        self.logger.debug("Added %s to changeset" % pcvd['name'])
        self.chs_api.apply(chs['id'])

        system_time = time.time()
        pools = self.org_api.pools(org['label'])

        all_systems = queued_work(self.sys_api.create_system, org, env1, 128,
                                  2)
        for sys1 in all_systems:
            self.assertEqual(sys1['uuid'],
                             self.sys_api.system(sys1['uuid'])['uuid'])

            for pool in pools:
                self.sys_api.subscribe(sys1['uuid'], pool['id'])
                self.logger.debug("Subscribe system to pool %s" % pool['id'])

        total_system_time = time.time() - system_time
        print "Total time spent for systems: %f" % total_system_time
        print "Mean time: %f" % (total_system_time / 128)
Example #11
0
class TestSystemGroups(BaseTest):

    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                       project=self.project,
                       username=self.user,
                       password=self.password,
                       port=self.port)
        self.org_api = Organization()
        self.env_api = Environment()
        self.sys_api = System()
        self.sys_grp_api = SystemGroup()

        self.start_time = time.time()


    def tearDown(self):
        self.server = None

        self.ellapsed_time = time.time() - self.start_time
        self.logger.info("Test ellapsed time: %s" % self.ellapsed_time)


    def _create_org_env(self):
        "Generic method to create a new organization and one environment"

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']), 'Failed to create and retrieve org.')

        env = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Dev'))

        return (org, env)


    def test_create_system_group_1(self):
        "Creates an empty system group."

        (org, env) = self._create_org_env()

        grp = self.sys_grp_api.create(org)
        self.assertEqual(grp, self.sys_grp_api.system_group(org, grp['id']))
        self.logger.debug("Created system group '%s'" % grp['name'])


    def test_create_and_delete_system_group_1(self):
        "Creates an empty system group and deletes it."

        (org, env) = self._create_org_env()

        grp = self.sys_grp_api.create(org)
        self.assertEqual(grp, self.sys_grp_api.system_group(org, grp['id']))
        self.logger.debug("Created system group '%s'" % grp['name'])

        self.sys_grp_api.delete(org, grp['id'])
        self.assertRaises(ServerRequestError, lambda: self.sys_grp_api.system_group(org, grp['id']))
        self.logger.debug("Deleted system group '%s'" % grp['name'])


    def test_create_and_copy_system_group_1(self):
        "Creates system group and copies it."
        (org, env) = self._create_org_env()

        grp1 = self.sys_grp_api.create(org)
        self.assertEqual(grp1, self.sys_grp_api.system_group(org, grp1['id']))
        self.logger.debug("Created system group '%s'" % grp1['name'])

        grp2 = self.sys_grp_api.create(org)
        self.assertEqual(grp2, self.sys_grp_api.system_group(org, grp2['id']))
        self.logger.debug("Created system group '%s'" % grp2['name'])
        self.assertEqual(len(self.sys_grp_api.system_groups(org)), 2)


    def test_create_system_group_with_system_1(self):
        "Creates system group and adds a system to it."
        (org, env) = self._create_org_env()

        grp = self.sys_grp_api.create(org)
        self.assertEqual(grp, self.sys_grp_api.system_group(org, grp['id']))
        self.logger.debug("Created system group '%s'" % grp['name'])

        sys1 = self.sys_api.create_system(org, env)
        self.logger.debug("Created system %s" % sys1['uuid'])
        self.assertEqual(sys1['uuid'], self.sys_api.system(sys1['uuid'])['uuid'])

        self.assertEqual(len(self.sys_grp_api.system_group_systems(org, grp['id'])), 0)
        self.logger.debug("System group '%s' is empty" % grp['name'])

        self.sys_grp_api.add_systems(org, grp['id'], [sys1['uuid'],])
        self.assertEqual(len(self.sys_grp_api.system_group_systems(org, grp['id'])), 1)
        self.logger.debug("System group '%s' is not empty" % grp['name'])


    def test_create_system_group_with_system_and_delete_1(self):
        "Creates system group and adds a system to it."
        (org, env) = self._create_org_env()

        grp = self.sys_grp_api.create(org)
        self.assertEqual(grp, self.sys_grp_api.system_group(org, grp['id']))
        self.logger.debug("Created system group '%s'" % grp['name'])

        sys1 = self.sys_api.create_system(org, env)
        self.logger.debug("Created system %s" % sys1['uuid'])
        self.assertEqual(sys1['uuid'], self.sys_api.system(sys1['uuid'])['uuid'])
        self.assertEqual(len(self.sys_grp_api.system_group_systems(org, grp['id'])), 0)
        self.logger.debug("System group '%s' is empty" % grp['name'])

        self.sys_grp_api.add_systems(org, grp['id'], [sys1['uuid'],])
        self.assertEqual(len(self.sys_grp_api.system_group_systems(org, grp['id'])), 1)
        self.logger.debug("System group '%s' is not empty" % grp['name'])

        self.sys_grp_api.remove_systems(org, grp['id'], [sys1['uuid'],])
        self.assertEqual(len(self.sys_grp_api.system_group_systems(org, grp['id'])), 0)
        self.logger.debug("System group '%s' is empty" % grp['name'])


    def test_create_system_group_with_system_and_copy_1(self):
        "Creates system group, adds a system to it and copies it."
        (org, env) = self._create_org_env()

        grp1 = self.sys_grp_api.create(org)
        self.assertEqual(grp1, self.sys_grp_api.system_group(org, grp1['id']))
        self.logger.debug("Created system group '%s'" % grp1['name'])

        sys1 = self.sys_api.create_system(org, env)
        self.logger.debug("Created system %s" % sys1['uuid'])
        self.assertEqual(sys1['uuid'], self.sys_api.system(sys1['uuid'])['uuid'])

        self.assertEqual(len(self.sys_grp_api.system_group_systems(org, grp1['id'])), 0)
        self.logger.debug("System group '%s' is empty" % grp1['name'])

        self.sys_grp_api.add_systems(org, grp1['id'], [sys1['uuid'],])
        self.assertEqual(len(self.sys_grp_api.system_group_systems(org, grp1['id'])), 1)
        self.logger.debug("System group '%s' is not empty" % grp1['name'])

        grp2 = self.sys_grp_api.copy(org, grp1['id'])
        self.assertEqual(grp2, self.sys_grp_api.system_group(org, grp2['id']))
        self.logger.debug("Created system group '%s'" % grp2['name'])
        self.assertEqual(len(self.sys_grp_api.system_groups(org)), 2)
        self.assertEqual(len(self.sys_grp_api.system_group_systems(org, grp2['id'])), 1)
        self.logger.debug("System group '%s' is not empty" % grp2['name'])
Example #12
0
class TestSystems(BaseTest):
    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                             project=self.project,
                             username=self.user,
                             password=self.password,
                             port=self.port)
        self.org_api = Organization()
        self.env_api = Environment()
        self.sys_api = System()

        self.start_time = time.time()

    def tearDown(self):
        self.server = None

        self.ellapsed_time = time.time() - self.start_time
        self.logger.info("Test ellapsed time: %s" % self.ellapsed_time)

    def test_create_system_1(self):
        "Creates a new organization with environment and register a system."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']),
                         'Failed to create and retrieve org.')

        env = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Dev'))

        env = self.env_api.create_environment(org, 'Testing', 'Dev')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Testing'))

        env = self.env_api.create_environment(org, 'Release', 'Testing')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Release'))

        sys1 = self.sys_api.create_system(org, env)
        self.logger.debug("Created system %s" % sys1['uuid'])
        self.assertEqual(sys1['uuid'],
                         self.sys_api.system(sys1['uuid'])['uuid'])

    def test_stress_systems_1(self):
        "Creates a new organization with environment and registers 12 systems 2 at a time."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']),
                         'Failed to create and retrieve org.')

        env = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Dev'))

        env = self.env_api.create_environment(org, 'Testing', 'Dev')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Testing'))

        env = self.env_api.create_environment(org, 'Release', 'Testing')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Release'))

        all_systems = queued_work(self.sys_api.create_system, org, env, 12, 2)

        for sys1 in all_systems:
            self.assertEqual(sys1['uuid'],
                             self.sys_api.system(sys1['uuid'])['uuid'])
Example #13
0
class TestStress(BaseTest):

    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                       project=self.project,
                       username=self.user,
                       password=self.password,
                       port=self.port)
        self.org_api = Organization()
        self.chs_api = Changeset()
        self.cv_api = ContentView()
        self.cvd_api = ContentViewDefinition()
        self.env_api = Environment()
        self.prd_api = Product()
        self.prv_api = Provider()
        self.repo_api = Repository()
        self.sys_api = System()

        self.start_time = time.time()


    def tearDown(self):
        self.server = None

        self.ellapsed_time = time.time() - self.start_time
        self.logger.info("Test ellapsed time: %s" % self.ellapsed_time)


    def test_stress_128_1(self):
        "Creates a new organization with environment and register a system."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']), 'Failed to create and retrieve org.')

        env1 = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environmemt %s" % env1['name'])
        self.assertEqual(env1, self.env_api.environment_by_name(org, 'Dev'))

        env2 = self.env_api.create_environment(org, 'Testing', 'Dev')
        self.logger.debug("Created environmemt %s" % env2['name'])
        self.assertEqual(env2, self.env_api.environment_by_name(org, 'Testing'))

        env3 = self.env_api.create_environment(org, 'Release', 'Testing')
        self.logger.debug("Created environmemt %s" % env3['name'])
        self.assertEqual(env3, self.env_api.environment_by_name(org, 'Release'))

        prv = self.prv_api.create_provider(org, 'Provider1')
        self.logger.debug("Created custom provider Provider1")
        self.assertEqual(prv, self.prv_api.provider(prv['id']))

        prd = self.prd_api.create_product(prv, 'Product1')
        self.logger.debug("Created product Product1")
        self.assertEqual(prd['id'], self.prd_api.product(org, prd['id'])['id'])

        repo = self.repo_api.create_repository(org, prd, 'http://hhovsepy.fedorapeople.org/fakerepos/zoo4/', 'Repo1')
        self.logger.debug("Created repositiry Repo1")
        self.assertEqual(repo, self.repo_api.repository(repo['id']))

        # Sync
        self.prv_api.sync(prv['id'])
        self.assertEqual(self.prv_api.provider(prv['id'])['sync_state'], 'finished')
        self.logger.debug("Finished synchronizing Provider1")

        # Content View Definition
        cvd = self.cvd_api.create_content_view_definition(org, 'CVD1')
        self.logger.debug("Created Content View Definition CVD1")
        prods = self.cvd_api.update_products(org, cvd['id'], prd)
        self.logger.debug("Added %s to Content View Definition" % prd['name'])

        # Published Content view
        self.cvd_api.publish(org, cvd['id'], 'PublishedCVD1')
        pcvd = self.cv_api.content_views_by_label_name_or_id(org, name='PublishedCVD1')
        self.logger.debug("Published Content View PublishedCVD1")

        # Changeset
        chs = self.chs_api.create(org, env1, 'Promote01')
        self.logger.debug("Created promotion changeset Promote01")
        self.chs_api.add_content(chs['id'], pcvd)
        self.logger.debug("Added %s to changeset" % pcvd['name'])
        self.chs_api.apply(chs['id'])

        system_time = time.time()
        pools = self.org_api.pools(org['label'])

        all_systems = queued_work(self.sys_api.create_system, org, env1, 128, 2)
        for sys1 in all_systems:
            self.assertEqual(sys1['uuid'], self.sys_api.system(sys1['uuid'])['uuid'])

            for pool in pools:
                self.sys_api.subscribe(sys1['uuid'], pool['id'])
                self.logger.debug("Subscribe system to pool %s" % pool['id'])

        total_system_time = time.time() - system_time
        print "Total time spent for systems: %f" % total_system_time
        print "Mean time: %f" % (total_system_time / 128)
Example #14
0
class TestOrganizations(BaseTest):
    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                             project=self.project,
                             username=self.user,
                             password=self.password,
                             port=self.port)
        self.org_api = Organization()
        self.env_api = Environment()

        self.start_time = time.time()

    def tearDown(self):
        self.server = None

        self.ellapsed_time = time.time() - self.start_time
        self.logger.info("Test ellapsed time: %s" % self.ellapsed_time)

    def test_create_org1(self):
        "Creates a new organization."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']),
                         'Failed to create and retrieve org.')

    def test_create_org2(self):
        "Creates a new organization and then deletes it."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']),
                         'Failed to create and retrieve org.')

        self.logger.info("Deleting organization %s" % org['name'])
        self.org_api.delete(org['name'])
        self.assertRaises(ServerRequestError,
                          lambda: self.org_api.organization(org['name']))

    def test_create_org3(self):
        "Creates a new organization with an initial environment."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']),
                         'Failed to create and retrieve org.')

        env = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Dev'))

    def test_create_org4(self):
        "Creates a new organization with several environments."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']),
                         'Failed to create and retrieve org.')

        env = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Dev'))

        env = self.env_api.create_environment(org, 'Testing', 'Dev')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Testing'))

        env = self.env_api.create_environment(org, 'Release', 'Testing')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Release'))
Example #15
0
class TestActivationKeys(BaseTest):

    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                       project=self.project,
                       username=self.user,
                       password=self.password)
        self.org_api = Organization()
        self.ak_api = ActivationKey()
        self.env_api = Environment()
        self.prd_api = Product()
        self.prv_api = Provider()
        self.repo_api = Repository()
        self.sys_api = System()

        self.start_time = time.time()


    def tearDown(self):
        self.server = None

        self.ellapsed_time = time.time() - self.start_time
        self.logger.info("Test ellapsed time: %s" % self.ellapsed_time)


    def test_get_ak_1(self):
        "Tries to fetch an invalid activationkey."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']), 'Failed to create and retrieve org.')

        env1 = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env1['name'])
        self.assertEqual(env1, self.env_api.environment_by_name(org, 'Dev'))

        ak1 = self.ak_api.create(env1)
        self.logger.debug("Created activationkey %s" % ak1['name'])
        self.assertEqual(ak1, self.ak_api.activation_key(org, ak1['id']))

        self.assertRaises(ServerRequestError, lambda: self.ak_api.activation_key(org, 10000))


    def test_create_ak_1(self):
        "Creates a new activationkey with no content."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']), 'Failed to create and retrieve org.')

        env1 = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env1['name'])
        self.assertEqual(env1, self.env_api.environment_by_name(org, 'Dev'))

        ak1 = self.ak_api.create(env1)
        self.logger.debug("Created activationkey %s" % ak1['name'])
        self.assertEqual(ak1, self.ak_api.activation_key(org, ak1['id']))



    def test_create_ak_2(self):
        "Creates a new activationkey and adds a pool."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']), 'Failed to create and retrieve org.')

        env1 = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env1['name'])
        self.assertEqual(env1, self.env_api.environment_by_name(org, 'Dev'))

        ak1 = self.ak_api.create(env1)
        self.logger.debug("Created activationkey %s" % ak1['name'])
        self.assertEqual(ak1, self.ak_api.activation_key(org, ak1['id']))

        prv = self.prv_api.create_provider(org, 'Provider1')
        self.logger.debug("Created custom provider Provider1")
        self.assertEqual(prv, self.prv_api.provider(prv['id']))

        prd = self.prd_api.create_product(prv, 'Product1')
        self.logger.debug("Created product Product1")
        self.assertEqual(prd['id'], self.prd_api.product(org, prd['id'])['id'])

        repo = self.repo_api.create_repository(org, prd, 'http://hhovsepy.fedorapeople.org/fakerepos/zoo4/', 'Repo1')
        self.logger.debug("Created repositiry Repo1")
        self.assertEqual(repo, self.repo_api.repository(repo['id']))

        # Sync
        self.prv_api.sync(prv['id'])
        self.assertEqual(self.prv_api.provider(prv['id'])['sync_state'], 'finished')
        self.logger.debug("Finished synchronizing Provider1")

        #TODO: There seems to be a delay between sync and pools being available
        pools = self.org_api.pools(org['label'])

        for pool in pools:
            self.ak_api.add_pool(org, ak1['id'], pool['id'])
            self.assertTrue(self.ak_api.has_pool(org, ak1['id'], pool['id']))
            self.logger.debug("Added pool id '%s'' to activationkey '%s'" % (pool['id'], ak1['name']))
Example #16
0
class TestSystems(BaseTest):

    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                       project=self.project,
                       username=self.user,
                       password=self.password,
                       port=self.port)
        self.org_api = Organization()
        self.env_api = Environment()
        self.sys_api = System()

        self.start_time = time.time()


    def tearDown(self):
        self.server = None

        self.ellapsed_time = time.time() - self.start_time
        self.logger.info("Test ellapsed time: %s" % self.ellapsed_time)


    def test_create_system_1(self):
        "Creates a new organization with environment and register a system."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']), 'Failed to create and retrieve org.')

        env = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Dev'))

        env = self.env_api.create_environment(org, 'Testing', 'Dev')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Testing'))

        env = self.env_api.create_environment(org, 'Release', 'Testing')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Release'))

        sys1 = self.sys_api.create_system(org, env)
        self.logger.debug("Created system %s" % sys1['uuid'])
        self.assertEqual(sys1['uuid'], self.sys_api.system(sys1['uuid'])['uuid'])


    def test_stress_systems_1(self):
        "Creates a new organization with environment and registers 12 systems 2 at a time."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']), 'Failed to create and retrieve org.')

        env = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Dev'))

        env = self.env_api.create_environment(org, 'Testing', 'Dev')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Testing'))

        env = self.env_api.create_environment(org, 'Release', 'Testing')
        self.logger.debug("Created environemt %s" % env['name'])
        self.assertEqual(env, self.env_api.environment_by_name(org, 'Release'))

        all_systems = queued_work(self.sys_api.create_system, org, env, 12, 2)

        for sys1 in all_systems:
            self.assertEqual(sys1['uuid'], self.sys_api.system(sys1['uuid'])['uuid'])
Example #17
0
class TestActivationKeys(BaseTest):
    def setUp(self):
        BaseTest.setUp(self)

        self.server = Server(host=self.host,
                             project=self.project,
                             username=self.user,
                             password=self.password)
        self.org_api = Organization()
        self.ak_api = ActivationKey()
        self.env_api = Environment()
        self.prd_api = Product()
        self.prv_api = Provider()
        self.repo_api = Repository()
        self.sys_api = System()

        self.start_time = time.time()

    def tearDown(self):
        self.server = None

        self.ellapsed_time = time.time() - self.start_time
        self.logger.info("Test ellapsed time: %s" % self.ellapsed_time)

    def test_get_ak_1(self):
        "Tries to fetch an invalid activationkey."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']),
                         'Failed to create and retrieve org.')

        env1 = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env1['name'])
        self.assertEqual(env1, self.env_api.environment_by_name(org, 'Dev'))

        ak1 = self.ak_api.create(env1)
        self.logger.debug("Created activationkey %s" % ak1['name'])
        self.assertEqual(ak1, self.ak_api.activation_key(org, ak1['id']))

        self.assertRaises(ServerRequestError,
                          lambda: self.ak_api.activation_key(org, 10000))

    def test_create_ak_1(self):
        "Creates a new activationkey with no content."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']),
                         'Failed to create and retrieve org.')

        env1 = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env1['name'])
        self.assertEqual(env1, self.env_api.environment_by_name(org, 'Dev'))

        ak1 = self.ak_api.create(env1)
        self.logger.debug("Created activationkey %s" % ak1['name'])
        self.assertEqual(ak1, self.ak_api.activation_key(org, ak1['id']))

    def test_create_ak_2(self):
        "Creates a new activationkey and adds a pool."

        org = self.org_api.create()
        self.logger.debug("Created organization %s" % org['name'])
        self.assertEqual(org, self.org_api.organization(org['name']),
                         'Failed to create and retrieve org.')

        env1 = self.env_api.create_environment(org, 'Dev', 'Library')
        self.logger.debug("Created environemt %s" % env1['name'])
        self.assertEqual(env1, self.env_api.environment_by_name(org, 'Dev'))

        ak1 = self.ak_api.create(env1)
        self.logger.debug("Created activationkey %s" % ak1['name'])
        self.assertEqual(ak1, self.ak_api.activation_key(org, ak1['id']))

        prv = self.prv_api.create_provider(org, 'Provider1')
        self.logger.debug("Created custom provider Provider1")
        self.assertEqual(prv, self.prv_api.provider(prv['id']))

        prd = self.prd_api.create_product(prv, 'Product1')
        self.logger.debug("Created product Product1")
        self.assertEqual(prd['id'], self.prd_api.product(org, prd['id'])['id'])

        repo = self.repo_api.create_repository(
            org, prd, 'http://hhovsepy.fedorapeople.org/fakerepos/zoo4/',
            'Repo1')
        self.logger.debug("Created repositiry Repo1")
        self.assertEqual(repo, self.repo_api.repository(repo['id']))

        # Sync
        self.prv_api.sync(prv['id'])
        self.assertEqual(
            self.prv_api.provider(prv['id'])['sync_state'], 'finished')
        self.logger.debug("Finished synchronizing Provider1")

        #TODO: There seems to be a delay between sync and pools being available
        pools = self.org_api.pools(org['label'])

        for pool in pools:
            self.ak_api.add_pool(org, ak1['id'], pool['id'])
            self.assertTrue(self.ak_api.has_pool(org, ak1['id'], pool['id']))
            self.logger.debug("Added pool id '%s'' to activationkey '%s'" %
                              (pool['id'], ak1['name']))