Exemple #1
0
    def test_positive_update_interval(self):
        """Create a sync plan and update its interval.

        :id: cf2eddf8-b4db-430e-a9b0-83c626b45068

        :expectedresults: A sync plan is created and its interval can be
            updated with the specified interval.

        :CaseImportance: Critical
        """
        for interval in valid_sync_interval():
            sync_plan = entities.SyncPlan(
                description=gen_string('alpha'),
                organization=self.org,
                interval=interval
            )
            if interval == SYNC_INTERVAL['custom']:
                sync_plan.cron_expression = gen_choice(valid_cron_expressions())
            sync_plan = sync_plan.create()

            valid_intervals = valid_sync_interval()
            valid_intervals.remove(interval)
            new_interval = gen_choice(valid_intervals)
            sync_plan.interval = new_interval
            if new_interval == SYNC_INTERVAL['custom']:
                sync_plan.cron_expression = gen_choice(valid_cron_expressions())
                sync_plan = sync_plan.update(['interval', 'cron_expression'])
            else:
                sync_plan = sync_plan.update(['interval'])
            self.assertEqual(sync_plan.interval, new_interval)
Exemple #2
0
def test_positive_update_interval(module_org, interval):
    """Create a sync plan and update its interval.

    :id: cf2eddf8-b4db-430e-a9b0-83c626b45068

    :parametrized: yes

    :expectedresults: A sync plan is created and its interval can be
        updated with the specified interval.

    :CaseImportance: Critical
    """
    sync_plan = entities.SyncPlan(description=gen_string('alpha'),
                                  organization=module_org,
                                  interval=interval)
    if interval == SYNC_INTERVAL['custom']:
        sync_plan.cron_expression = gen_choice(valid_cron_expressions())
    sync_plan = sync_plan.create()
    # ensure "new interval" not equal to "interval"
    new_interval = 'hourly' if interval != 'hourly' else 'daily'
    sync_plan.interval = new_interval
    if new_interval == SYNC_INTERVAL['custom']:
        sync_plan.cron_expression = gen_choice(valid_cron_expressions())
        sync_plan = sync_plan.update(['interval', 'cron_expression'])
    else:
        sync_plan = sync_plan.update(['interval'])
    sync_plan = sync_plan.read()
    assert sync_plan.interval == new_interval
Exemple #3
0
    def test_positive_update_interval(self):
        """Create a sync plan and update its interval.

        :id: cf2eddf8-b4db-430e-a9b0-83c626b45068

        :expectedresults: A sync plan is created and its interval can be
            updated with the specified interval.

        :CaseImportance: Critical
        """
        for interval in valid_sync_interval():
            sync_plan = entities.SyncPlan(description=gen_string('alpha'),
                                          organization=self.org,
                                          interval=interval)
            if interval == SYNC_INTERVAL['custom']:
                sync_plan.cron_expression = gen_choice(
                    valid_cron_expressions())
            sync_plan = sync_plan.create()

            valid_intervals = valid_sync_interval()
            self.assertIn(interval, valid_intervals)
            valid_intervals.remove(interval)
            new_interval = gen_choice(valid_intervals)
            sync_plan.interval = new_interval
            if new_interval == SYNC_INTERVAL['custom']:
                sync_plan.cron_expression = gen_choice(
                    valid_cron_expressions())
                sync_plan = sync_plan.update(['interval', 'cron_expression'])
            else:
                sync_plan = sync_plan.update(['interval'])
            self.assertEqual(sync_plan.interval, new_interval)
Exemple #4
0
def test_positive_update_interval(module_org, interval):
    """Create a sync plan and update its interval.

    :id: cf2eddf8-b4db-430e-a9b0-83c626b45068

    :parametrized: yes

    :expectedresults: A sync plan is created and its interval can be
        updated with the specified interval.

    :CaseImportance: Critical
    """
    sync_plan = entities.SyncPlan(description=gen_string('alpha'),
                                  organization=module_org,
                                  interval=interval)
    if interval == SYNC_INTERVAL['custom']:
        sync_plan.cron_expression = gen_choice(valid_cron_expressions())
    sync_plan = sync_plan.create()
    # get another random interval and workaround issue #7231
    new_interval = gen_choice(valid_sync_interval())
    while new_interval == interval:
        new_interval = gen_choice(valid_sync_interval())
    sync_plan.interval = new_interval
    if new_interval == SYNC_INTERVAL['custom']:
        sync_plan.cron_expression = gen_choice(valid_cron_expressions())
        sync_plan = sync_plan.update(['interval', 'cron_expression'])
    else:
        sync_plan = sync_plan.update(['interval'])
    sync_plan = sync_plan.read()
    assert sync_plan.interval == new_interval
def test_post_sync_plan_migration(pre_upgrade_data):
    """Post-upgrade scenario that tests existing sync plans are working as
    expected after satellite upgrade with migrating from pulp to katello

    :id: 61f65f5d-351c-4aa4-83dc-71afae5dc1e0

    :steps:
        1. Verify sync plan exists and works as earlier

    :expectedresults: Post Upgrade, Sync plans exists and works as earlier.

     """
    org = entities.Organization(id=pre_upgrade_data.get('org_id'))
    product = entities.Product(id=pre_upgrade_data.get("product_id")).read()
    sync_plan = entities.SyncPlan(id=pre_upgrade_data.get("sync_plan_id"),
                                  organization=org).read()
    assert product.sync_plan.id == sync_plan.id
    assert sync_plan.name == pre_upgrade_data.get("sync_plan_name")
    assert sync_plan.interval == pre_upgrade_data.get("interval")
    assert sync_plan.sync_date == pre_upgrade_data.get("sync_date")
    # checking sync plan update on upgraded satellite
    sync_plan.interval = SYNC_INTERVAL['custom']
    sync_plan.cron_expression = gen_choice(valid_cron_expressions())
    assert (sync_plan.update(['interval', 'cron_expression'
                              ]).interval == SYNC_INTERVAL['custom'])
    # checking sync plan delete on upgraded satellite
    sync_plan.delete()
    product = product.read()
    assert product.sync_plan is None
    with raises(HTTPError):
        sync_plan.read()
Exemple #6
0
def test_post_sync_plan_migration(pre_upgrade_data):
    """Post-upgrade scenario that tests existing sync plans are working as
    expected after satellite upgrade with migrating from pulp to katello

    :id: 61f65f5d-351c-4aa4-83dc-71afae5dc1e0

    :steps:
        1. Verify sync plan exists and works as earlier

    :expectedresults: Post Upgrade, Sync plans exists and works as earlier.

     """
    org = entities.Organization(id=pre_upgrade_data.get('org_id'))
    product = entities.Product(id=pre_upgrade_data.get("product_id")).read()
    sync_plan = entities.SyncPlan(id=pre_upgrade_data.get("sync_plan_id"),
                                  organization=org).read()
    assert product.sync_plan.id == sync_plan.id
    assert sync_plan.name == pre_upgrade_data.get("sync_plan_name")
    assert sync_plan.interval == pre_upgrade_data.get("interval")
    assert sync_plan.sync_date == pre_upgrade_data.get("sync_date")
    # checking sync plan update on upgraded satellite
    sync_plan.interval = SYNC_INTERVAL['custom']
    sync_plan.cron_expression = gen_choice(valid_cron_expressions())
    assert (sync_plan.update(['interval', 'cron_expression']).interval
            == SYNC_INTERVAL['custom'])
    # checking sync plan delete on upgraded satellite
    sync_plan.delete()
    product = product.read()
    assert product.sync_plan is None
    with raises(HTTPError):
        sync_plan.read()
Exemple #7
0
    def test_post_sync_plan_migration(self):
        """Post-upgrade scenario that tests existing sync plans are working as
        expected after satellite upgrade with migrating from pulp to katello

        :id: badaeec2-d42f-41d5-bd85-4b23d6d5a724

        :steps:
            1. Verify sync plan exists and works as earlier

        :expectedresults: Post Upgrade, Sync plans exists and works as earlier.

         """
        entity_data = get_entity_data(self.__class__.__name__)
        org = entities.Organization(id=entity_data.get('org_id'))
        product = entities.Product(id=entity_data.get("product_id")).read()
        sync_plan = entities.SyncPlan(id=entity_data.get("sync_plan_id"),
                                      organization=org).read()
        self.assertEqual(product.sync_plan.id, sync_plan.id)
        self.assertEqual(sync_plan.name, entity_data.get("sync_plan_name"))
        self.assertEqual(sync_plan.interval, entity_data.get("interval"))
        self.assertEqual(sync_plan.sync_date, entity_data.get("sync_date"))
        # checking sync plan update on upgraded satellite
        sync_plan.interval = SYNC_INTERVAL['custom']
        sync_plan.cron_expression = gen_choice(valid_cron_expressions())
        self.assertEqual(
            sync_plan.update(['interval', 'cron_expression']).interval,
            SYNC_INTERVAL['custom'])
        # checking sync plan delete on upgraded satellite
        sync_plan.delete()
        product = product.read()
        self.assertIsNone(product.sync_plan)
        with self.assertRaises(HTTPError):
            sync_plan.read()
Exemple #8
0
def test_positive_delete_synced_product_custom_cron(module_org):
    """Create a sync plan with custom cron with one synced
    product and delete it.

    :id: f13936f5-7522-43b8-a986-26795637cde9

    :expectedresults: A sync plan is created with one synced product and
        sync plan can be deleted.

    :CaseLevel: Integration
    """
    sync_plan = entities.SyncPlan(
        organization=module_org,
        interval='custom cron',
        cron_expression=gen_choice(valid_cron_expressions()),
    ).create()
    product = entities.Product(organization=module_org).create()
    entities.Repository(product=product).create()
    sync_plan.add_products(data={'product_ids': [product.id]})
    product.sync()
    product = product.read()
    assert product.sync_plan.id == sync_plan.id
    sync_plan.delete()
    product = product.read()
    assert product.sync_plan is None
    with pytest.raises(HTTPError):
        sync_plan.read()
    def test_positive_add_remove_products_custom_cron(self):
        """Create a sync plan with two products having custom_cron interval
         and then remove both products from it.

         :id: 5ce34eaa-3574-49ba-ab02-aa25515394aa

         :expectedresults: A sync plan can be created and both products can be
            removed from it.
         :CaseLevel: Integration
        """
        cron_expression = gen_choice(valid_cron_expressions())

        syncplan = entities.SyncPlan(organization=self.org,
                                     interval='custom cron',
                                     cron_expression=cron_expression
                                     ).create()
        products = [
            entities.Product(organization=self.org).create() for _ in range(2)
        ]
        syncplan.add_products(data={
            'product_ids': [product.id for product in products],
        })
        self.assertEqual(len(syncplan.read().product), 2)
        syncplan.remove_products(data={
            'product_ids': [product.id for product in products],
        })
        self.assertEqual(len(syncplan.read().product), 0)
    def test_post_sync_plan_migration(self):
        """Post-upgrade scenario that tests existing sync plans are working as
        expected after satellite upgrade with migrating from pulp to katello

        :id: badaeec2-d42f-41d5-bd85-4b23d6d5a724

        :steps:
            1. Verify sync plan exists and works as earlier

        :expectedresults: Post Upgrade, Sync plans exists and works as earlier.

         """
        entity_data = get_entity_data(self.__class__.__name__)
        org = entities.Organization(id=entity_data.get('org_id'))
        product = entities.Product(id=entity_data.get("product_id")).read()
        sync_plan = entities.SyncPlan(id=entity_data.get("sync_plan_id"),
                                      organization=org).read()
        self.assertEqual(product.sync_plan.id, sync_plan.id)
        self.assertEqual(sync_plan.name, entity_data.get("sync_plan_name"))
        self.assertEqual(sync_plan.interval, entity_data.get("interval"))
        self.assertEqual(sync_plan.sync_date, entity_data.get("sync_date"))
        # checking sync plan update on upgraded satellite
        sync_plan.interval = SYNC_INTERVAL['custom']
        sync_plan.cron_expression = gen_choice(valid_cron_expressions())
        self.assertEqual(
            sync_plan.update(['interval', 'cron_expression']).interval,
            SYNC_INTERVAL['custom']
        )
        # checking sync plan delete on upgraded satellite
        sync_plan.delete()
        product = product.read()
        self.assertIsNone(product.sync_plan)
        with self.assertRaises(HTTPError):
            sync_plan.read()
    def test_positive_update_interval(self):
        """Create a sync plan and update its interval.

        :id: cf2eddf8-b4db-430e-a9b0-83c626b45068

        :expectedresults: A sync plan is created and its interval can be
            updated with the specified interval.

        :CaseImportance: Critical
        """
        for interval in valid_sync_interval():
            with self.subTest(interval):
                sync_plan = entities.SyncPlan(organization=self.org)
                result = sync_plan.get_fields()['interval']
                sync_plan.interval = sample(
                    set(result.choices) - set([interval]),
                    1
                )[0]
                sync_plan = sync_plan.create()
                sync_plan.interval = interval
                if (interval == 'custom cron'):
                    sync_plan.cron_expression = gen_choice(valid_cron_expressions())
                    sync_plan = sync_plan.update(['interval', 'cron_expression'])
                else:
                    sync_plan = sync_plan.update(['interval'])
                self.assertEqual(sync_plan.interval, interval)
 def test_filtered_datapoint_True(self):
     """Tests if run_one_datapoint=false returns all data points"""
     settings.run_one_datapoint = False
     self.assertEqual(len(generate_strings_list()), 7)
     self.assertEqual(len(invalid_emails_list()), 8)
     self.assertEqual(len(invalid_id_list()), 4)
     self.assertEqual(len(invalid_interfaces_list()), 8)
     self.assertEqual(len(invalid_names_list()), 7)
     self.assertEqual(len(invalid_values_list()), 10)
     self.assertEqual(len(invalid_usernames_list()), 4)
     self.assertEqual(len(valid_labels_list()), 2)
     self.assertEqual(len(valid_data_list()), 7)
     self.assertEqual(len(valid_emails_list()), 8)
     self.assertEqual(len(valid_environments_list()), 4)
     self.assertEqual(len(valid_hosts_list()), 3)
     self.assertEqual(len(valid_hostgroups_list()), 7)
     self.assertEqual(len(valid_interfaces_list()), 3)
     self.assertEqual(len(valid_names_list()), 15)
     self.assertEqual(len(valid_org_names_list()), 7)
     self.assertEqual(len(valid_usernames_list()), 6)
     self.assertEqual(len((valid_cron_expressions())), 4)
     with mock.patch('robottelo.datafactory.bz_bug_is_open',
                     return_value=True):
         self.assertEqual(len(valid_docker_repository_names()), 6)
     with mock.patch('robottelo.datafactory.bz_bug_is_open',
                     return_value=False):
         self.assertEqual(len(valid_docker_repository_names()), 7)
    def test_positive_delete_synced_product_custom_cron(self):
        """Create a sync plan with custom cron with one synced
        product and delete it.

        :id: f13936f5-7522-43b8-a986-26795637cde9

        :expectedresults: A sync plan is created with one synced product and
            sync plan can be deleted.

        :CaseLevel: Integration
        """
        sync_plan = entities.SyncPlan(
            organization=self.org,
            interval='custom cron',
            cron_expression=gen_choice((valid_cron_expressions()))).create()
        product = entities.Product(organization=self.org).create()
        entities.Repository(product=product).create()
        sync_plan.add_products(data={'product_ids': [product.id]})
        product.sync()
        product = product.read()
        self.assertEqual(product.sync_plan.id, sync_plan.id)
        sync_plan.delete()
        product = product.read()
        self.assertIsNone(product.sync_plan)
        with self.assertRaises(HTTPError):
            sync_plan.read()
Exemple #14
0
def test_positive_add_remove_products_custom_cron(module_org):
    """Create a sync plan with two products having custom cron interval
    and then remove both products from it.

    :id: 5ce34eaa-3574-49ba-ab02-aa25515394aa

    :expectedresults: A sync plan can be created and both products can be
        removed from it.

    :CaseLevel: Integration
    """
    cron_expression = gen_choice(valid_cron_expressions())

    syncplan = entities.SyncPlan(organization=module_org,
                                 interval='custom cron',
                                 cron_expression=cron_expression).create()
    products = [
        entities.Product(organization=module_org).create() for _ in range(2)
    ]
    syncplan.add_products(
        data={'product_ids': [product.id for product in products]})
    assert len(syncplan.read().product) == 2
    syncplan.remove_products(
        data={'product_ids': [product.id for product in products]})
    assert len(syncplan.read().product) == 0
 def test_filtered_datapoint(self, run_one_datapoint):
     """Tests if run_one_datapoint=false returns all data points"""
     if run_one_datapoint:
         assert len(datafactory.generate_strings_list()) == 1
         assert len(datafactory.invalid_emails_list()) == 1
         assert len(datafactory.invalid_environments_list()) == 1
         assert len(datafactory.invalid_id_list()) == 1
         assert len(datafactory.invalid_interfaces_list()) == 1
         assert len(datafactory.invalid_names_list()) == 1
         assert len(datafactory.invalid_values_list()) == 1
         assert len(datafactory.valid_data_list()) == 1
         assert len(datafactory.valid_docker_repository_names()) == 1
         assert len(datafactory.valid_emails_list()) == 1
         assert len(datafactory.valid_environments_list()) == 1
         assert len(datafactory.valid_hosts_list()) == 1
         assert len(datafactory.valid_hostgroups_list()) == 1
         assert len(datafactory.valid_interfaces_list()) == 1
         assert len(datafactory.valid_labels_list()) == 1
         assert len(datafactory.valid_names_list()) == 1
         assert len(datafactory.valid_org_names_list()) == 1
         assert len(datafactory.valid_usernames_list()) == 1
         assert len(datafactory.valid_cron_expressions()) == 1
     else:
         assert len(datafactory.generate_strings_list()) == 7
         assert len(datafactory.invalid_emails_list()) == 8
         assert len(datafactory.invalid_environments_list()) == 4
         assert len(datafactory.invalid_id_list()) == 4
         assert len(datafactory.invalid_interfaces_list()) == 8
         assert len(datafactory.invalid_names_list()) == 7
         assert len(datafactory.invalid_values_list()) == 10
         assert len(datafactory.invalid_usernames_list()) == 4
         assert len(datafactory.valid_labels_list()) == 2
         assert len(datafactory.valid_data_list()) == 7
         assert len(datafactory.valid_emails_list()) == 8
         assert len(datafactory.valid_environments_list()) == 4
         assert len(datafactory.valid_hosts_list()) == 3
         assert len(datafactory.valid_hostgroups_list()) == 7
         assert len(datafactory.valid_interfaces_list()) == 3
         assert len(datafactory.valid_names_list()) == 15
         assert len(datafactory.valid_org_names_list()) == 7
         assert len(datafactory.valid_usernames_list()) == 6
         assert len(datafactory.valid_cron_expressions()) == 4
         assert len(datafactory.valid_docker_repository_names()) == 7
Exemple #16
0
def test_positive_end_to_end_custom_cron(session):
    """Perform end to end scenario for sync plan component with custom cron

    :id: 48c88529-6318-47b0-97bc-eb46aae0294a

    :expectedresults: All CRUD actions for component finished successfully

    :CaseLevel: Integration
    """
    plan_name = gen_string('alpha')
    description = gen_string('alpha')
    cron_expression = gen_choice(valid_cron_expressions())
    with session:
        # workaround: force session.browser to point to browser object on next line
        session.contenthost.read_all('current_user')
        startdate = session.browser.get_client_datetime() + timedelta(
            minutes=10)
        # Create new sync plan and check all values in entity that was created
        session.syncplan.create({
            'name':
            plan_name,
            'interval':
            SYNC_INTERVAL['custom'],
            'description':
            description,
            'cron_expression':
            cron_expression,
            'date_time.start_date':
            startdate.strftime("%Y-%m-%d"),
            'date_time.hours':
            startdate.strftime('%H'),
            'date_time.minutes':
            startdate.strftime('%M'),
        })
        assert session.syncplan.search(plan_name)[0]['Name'] == plan_name
        syncplan_values = session.syncplan.read(plan_name)
        assert syncplan_values['details']['interval'] == SYNC_INTERVAL[
            'custom']
        assert syncplan_values['details']['cron_expression'] == cron_expression
        assert syncplan_values['details']['recurring_logic'].isdigit()
        time = syncplan_values['details']['date_time'].rpartition(':')[0]
        assert time == startdate.strftime("%B %-d, %Y, %I")
        # Update sync plan with new description
        session.syncplan.update(plan_name,
                                {'details.interval': SYNC_INTERVAL['day']})
        syncplan_values = session.syncplan.read(plan_name)
        assert syncplan_values['details']['interval'] == SYNC_INTERVAL['day']
        assert not syncplan_values['details']['cron_expression']
        # Delete sync plan
        session.syncplan.delete(plan_name)
        assert plan_name not in session.syncplan.search(plan_name)
    def test_return_type(self):
        """This test validates return types for functions:

        1. :meth:`robottelo.datafactory.generate_strings_list`
        2. :meth:`robottelo.datafactory.invalid_emails_list`
        3. :meth:`robottelo.datafactory.invalid_names_list`
        4. :meth:`robottelo.datafactory.valid_data_list`
        5. :meth:`robottelo.datafactory.valid_docker_repository_names`
        6. :meth:`robottelo.datafactory.valid_emails_list`
        7. :meth:`robottelo.datafactory.valid_environments_list`
        8. :meth:`robottelo.datafactory.valid_hosts_list`
        9. :meth:`robottelo.datafactory.valid_hostgroups_list`
        10. :meth:`robottelo.datafactory.valid_labels_list`
        11. :meth:`robottelo.datafactory.valid_names_list`
        12. :meth:`robottelo.datafactory.valid_org_names_list`
        13. :meth:`robottelo.datafactory.valid_usernames_list`
        14. :meth:`robottelo.datafactory.invalid_id_list`
        15. :meth:`robottelo.datafactory.invalid_interfaces_list`
        16. :meth:`robottelo.datafactory.valid_interfaces_list`
        17. :meth:`robottelo.datafactory.valid_cron_expressions`

        """
        with mock.patch('robottelo.datafactory.bz_bug_is_open',
                        return_value=False):
            for item in itertools.chain(
                    generate_strings_list(),
                    invalid_emails_list(),
                    invalid_interfaces_list(),
                    invalid_names_list(),
                    valid_data_list(),
                    valid_docker_repository_names(),
                    valid_emails_list(),
                    valid_environments_list(),
                    valid_hosts_list(),
                    valid_hostgroups_list(),
                    valid_interfaces_list(),
                    valid_labels_list(),
                    valid_names_list(),
                    valid_org_names_list(),
                    valid_cron_expressions(),
                    valid_usernames_list()):
                self.assertIsInstance(item, six.text_type)
            for item in invalid_id_list():
                if not (
                        isinstance(item, (six.text_type, int)) or item is None
                        ):
                    self.fail('Unexpected data type')
Exemple #18
0
def test_positive_product_create_with_create_sync_plan(session, module_org):
    """Perform Sync Plan Create from Product Create Page

    :id: 4a87b533-12b6-4d4e-8a99-4bb95efc4321

    :expectedresults: Ensure sync get created and assigned to Product.

    :CaseLevel: Integration

    :CaseImportance: Medium
    """
    product_name = gen_string('alpha')
    product_description = gen_string('alpha')
    gpg_key = entities.GPGKey(content=read_data_file(VALID_GPG_KEY_FILE),
                              organization=module_org).create()
    plan_name = gen_string('alpha')
    description = gen_string('alpha')
    cron_expression = gen_choice(valid_cron_expressions())
    with session:
        session.organization.select(module_org.name)
        startdate = session.browser.get_client_datetime() + timedelta(
            minutes=10)
        sync_plan_values = {
            'name': plan_name,
            'interval': SYNC_INTERVAL['custom'],
            'description': description,
            'cron_expression': cron_expression,
            'date_time.start_date': startdate.strftime("%Y-%m-%d"),
            'date_time.hours': startdate.strftime('%H'),
            'date_time.minutes': startdate.strftime('%M'),
        }
        session.product.create(
            {
                'name': product_name,
                'gpg_key': gpg_key.name,
                'description': product_description
            },
            sync_plan_values=sync_plan_values,
        )
        assert session.product.search(product_name)[0]['Name'] == product_name
        product_values = session.product.read(product_name,
                                              widget_names='details')
        assert product_values['details']['name'] == product_name
        assert product_values['details']['sync_plan'] == plan_name
        # Delete product
        session.product.delete(product_name)
        assert session.product.search(product_name)[0]['Name'] != product_name
Exemple #19
0
    def test_positive_create_with_interval(self):
        """Create a sync plan with a random interval.

        :id: d160ed1c-b698-42dc-be0b-67ac693c7840

        :expectedresults: A sync plan is created with the specified interval.

        :CaseImportance: Critical
        """
        for interval in valid_sync_interval():
            sync_plan = entities.SyncPlan(
                description=gen_string('alpha'), organization=self.org, interval=interval
            )
            if interval == SYNC_INTERVAL['custom']:
                sync_plan.cron_expression = gen_choice((valid_cron_expressions()))
            sync_plan = sync_plan.create()
            self.assertEqual(sync_plan.interval, interval)
    def test_return_type(self):
        """This test validates return types for functions:

        1. :meth:`robottelo.datafactory.generate_strings_list`
        2. :meth:`robottelo.datafactory.invalid_emails_list`
        3. :meth:`robottelo.datafactory.invalid_environments_list`
        4. :meth:`robottelo.datafactory.invalid_names_list`
        5. :meth:`robottelo.datafactory.valid_data_list`
        6. :meth:`robottelo.datafactory.valid_docker_repository_names`
        7. :meth:`robottelo.datafactory.valid_emails_list`
        8. :meth:`robottelo.datafactory.valid_environments_list`
        9. :meth:`robottelo.datafactory.valid_hosts_list`
        10. :meth:`robottelo.datafactory.valid_hostgroups_list`
        11. :meth:`robottelo.datafactory.valid_labels_list`
        12. :meth:`robottelo.datafactory.valid_names_list`
        13. :meth:`robottelo.datafactory.valid_org_names_list`
        14. :meth:`robottelo.datafactory.valid_usernames_list`
        15. :meth:`robottelo.datafactory.invalid_id_list`
        16. :meth:`robottelo.datafactory.invalid_interfaces_list`
        17. :meth:`robottelo.datafactory.valid_interfaces_list`
        18. :meth:`robottelo.datafactory.valid_cron_expressions`

        """
        for item in itertools.chain(
                datafactory.generate_strings_list(),
                datafactory.invalid_emails_list(),
                datafactory.invalid_environments_list(),
                datafactory.invalid_interfaces_list(),
                datafactory.invalid_names_list(),
                datafactory.valid_data_list(),
                datafactory.valid_docker_repository_names(),
                datafactory.valid_emails_list(),
                datafactory.valid_environments_list(),
                datafactory.valid_hosts_list(),
                datafactory.valid_hostgroups_list(),
                datafactory.valid_interfaces_list(),
                datafactory.valid_labels_list(),
                datafactory.valid_names_list(),
                datafactory.valid_org_names_list(),
                datafactory.valid_cron_expressions(),
                datafactory.valid_usernames_list(),
        ):
            assert isinstance(item, str)
        for item in datafactory.invalid_id_list():
            if not (isinstance(item, (str, int)) or item is None):
                pytest.fail('Unexpected data type')
Exemple #21
0
def test_positive_end_to_end_custom_cron(session):
    """Perform end to end scenario for sync plan component with custom cron

    :id: 48c88529-6318-47b0-97bc-eb46aae0294a

    :expectedresults: All CRUD actions for component finished successfully

    :CaseLevel: Integration
    """
    plan_name = gen_string('alpha')
    description = gen_string('alpha')
    cron_expression = gen_choice(valid_cron_expressions())
    with session:
        startdate = (
                session.browser.get_client_datetime() + timedelta(minutes=10))
        # Create new sync plan and check all values in entity that was created
        session.syncplan.create({
            'name': plan_name,
            'interval': SYNC_INTERVAL['custom'],
            'description': description,
            'cron_expression': cron_expression,
            'date_time.start_date': startdate.strftime("%Y-%m-%d"),
            'date_time.hours': startdate.strftime('%H'),
            'date_time.minutes': startdate.strftime('%M'),
        })
        assert session.syncplan.search(plan_name)[0]['Name'] == plan_name
        syncplan_values = session.syncplan.read(plan_name)
        assert syncplan_values['details']['interval'] == SYNC_INTERVAL['custom']
        assert syncplan_values['details']['cron_expression'] == cron_expression
        assert syncplan_values['details']['recurring_logic'].isdigit()
        time = syncplan_values['details']['date_time'].rpartition(':')[0]
        assert time == startdate.strftime("%Y/%m/%d %H:%M")
        # Update sync plan with new description
        session.syncplan.update(
            plan_name,
            {'details.interval': SYNC_INTERVAL['day']
             }
        )
        syncplan_values = session.syncplan.read(plan_name)
        assert syncplan_values['details']['interval'] == SYNC_INTERVAL['day']
        assert not syncplan_values['details']['cron_expression']
        # Delete sync plan
        session.syncplan.delete(plan_name)
        assert not session.syncplan.search(plan_name)
def test_positive_product_create_with_create_sync_plan(session, module_org):
    """Perform Sync Plan Create from Product Create Page

    :id: 4a87b533-12b6-4d4e-8a99-4bb95efc4321

    :expectedresults: Ensure sync get created and assigned to Product.

    :CaseLevel: Integration

    :CaseImportance: medium
    """
    product_name = gen_string('alpha')
    product_description = gen_string('alpha')
    gpg_key = entities.GPGKey(
        content=read_data_file(VALID_GPG_KEY_FILE),
        organization=module_org
    ).create()
    plan_name = gen_string('alpha')
    description = gen_string('alpha')
    cron_expression = gen_choice(valid_cron_expressions())
    with session:
        startdate = (
                session.browser.get_client_datetime() + timedelta(minutes=10))
        sync_plan_values = {
            'name': plan_name,
            'interval': SYNC_INTERVAL['custom'],
            'description': description,
            'cron_expression': cron_expression,
            'date_time.start_date': startdate.strftime("%Y-%m-%d"),
            'date_time.hours': startdate.strftime('%H'),
            'date_time.minutes': startdate.strftime('%M'),
        }
        session.product.create({
            'name': product_name,
            'gpg_key': gpg_key.name,
            'description': product_description,
        }, sync_plan_values=sync_plan_values)
        assert session.product.search(product_name)[0]['Name'] == product_name
        product_values = session.product.read(product_name)
        assert product_values['details']['name'] == product_name
        assert product_values['details']['sync_plan'] == plan_name
        # Delete product
        session.product.delete(product_name)
        assert not session.product.search(product_name)
Exemple #23
0
def test_positive_create_with_interval(module_org, interval):
    """Create a sync plan with a random interval.

    :id: d160ed1c-b698-42dc-be0b-67ac693c7840

    :parametrized: yes

    :expectedresults: A sync plan is created with the specified interval.

    :CaseImportance: Critical
    """
    sync_plan = entities.SyncPlan(description=gen_string('alpha'),
                                  organization=module_org,
                                  interval=interval)
    if interval == SYNC_INTERVAL['custom']:
        sync_plan.cron_expression = gen_choice(valid_cron_expressions())
    sync_plan = sync_plan.create()
    sync_plan = sync_plan.read()
    assert sync_plan.interval == interval
Exemple #24
0
    def test_positive_create_with_interval(self):
        """Create a sync plan with a random interval.

        :id: d160ed1c-b698-42dc-be0b-67ac693c7840

        :expectedresults: A sync plan is created with the specified interval.

        :CaseImportance: Critical
        """
        for interval in valid_sync_interval():
            sync_plan = entities.SyncPlan(
                description=gen_string('alpha'),
                organization=self.org,
                interval=interval
            )
            if interval == SYNC_INTERVAL['custom']:
                sync_plan.cron_expression = gen_choice((valid_cron_expressions()))
            sync_plan = sync_plan.create()
            self.assertEqual(sync_plan.interval, interval)
 def test_filtered_datapoint_False(self):
     """Tests if run_one_datapoint=True returns one data point"""
     settings.run_one_datapoint = True
     self.assertEqual(len(generate_strings_list()), 1)
     self.assertEqual(len(invalid_emails_list()), 1)
     self.assertEqual(len(invalid_id_list()), 1)
     self.assertEqual(len(invalid_interfaces_list()), 1)
     self.assertEqual(len(invalid_names_list()), 1)
     self.assertEqual(len(invalid_values_list()), 1)
     self.assertEqual(len(valid_data_list()), 1)
     self.assertEqual(len(valid_docker_repository_names()), 1)
     self.assertEqual(len(valid_emails_list()), 1)
     self.assertEqual(len(valid_environments_list()), 1)
     self.assertEqual(len(valid_hosts_list()), 1)
     self.assertEqual(len(valid_hostgroups_list()), 1)
     self.assertEqual(len(valid_interfaces_list()), 1)
     self.assertEqual(len(valid_labels_list()), 1)
     self.assertEqual(len(valid_names_list()), 1)
     self.assertEqual(len(valid_org_names_list()), 1)
     self.assertEqual(len(valid_usernames_list()), 1)
     self.assertEqual(len((valid_cron_expressions())), 1)
Exemple #26
0
    def test_positive_update_interval_custom_cron(self):
        """Create a sync plan and update its interval to custom cron.

        :id: 26c58319-cae0-4b0c-b388-2a1fe3f22344

        :expectedresults: A sync plan is created and its interval can be
            updated to custom cron.

        :CaseImportance: Critical
        """
        for interval in valid_sync_interval():
            if interval != SYNC_INTERVAL['custom']:
                sync_plan = entities.SyncPlan(description=gen_string('alpha'),
                                              organization=self.org,
                                              interval=interval).create()

                sync_plan.interval = SYNC_INTERVAL['custom']
                sync_plan.cron_expression = gen_choice(
                    valid_cron_expressions())
                self.assertEqual(
                    sync_plan.update(['interval', 'cron_expression']).interval,
                    SYNC_INTERVAL['custom'])
Exemple #27
0
def test_positive_update_interval_custom_cron(module_org, interval):
    """Create a sync plan and update its interval to custom cron.

    :id: 26c58319-cae0-4b0c-b388-2a1fe3f22344

    :parametrized: yes

    :expectedresults: A sync plan is created and its interval can be
        updated to custom cron.

    :CaseImportance: Critical
    """
    if interval != SYNC_INTERVAL['custom']:
        sync_plan = entities.SyncPlan(description=gen_string('alpha'),
                                      organization=module_org,
                                      interval=interval).create()

        sync_plan.interval = SYNC_INTERVAL['custom']
        sync_plan.cron_expression = gen_choice(valid_cron_expressions())
        sync_plan.update(['interval', 'cron_expression'])
        sync_plan = sync_plan.read()
        assert sync_plan.interval == SYNC_INTERVAL['custom']
Exemple #28
0
    def test_post_sync_plan_migration(self, request, dependent_scenario_name):
        """After upgrade, Sync interval update should work on existing sync plan(created before
        upgrade)

        :id: badaeec2-d42f-41d5-bd85-4b23d6d5a724

        :steps:
            1. Verify sync plan exists and works as earlier
            2. Check the all available sync_interval type update with pre-created sync_plan

        :expectedresults: After upgrade, the sync plan should remain the same with their all
        entities and sync_interval updated with their all supported sync interval type.

        """
        pre_test_name = dependent_scenario_name
        org = entities.Organization().search(
            query={'search': f'name="{pre_test_name}_org"'})[0]
        request.addfinalizer(org.delete)
        product = entities.Product(organization=org.id).search(
            query={'search': f'name="{pre_test_name}_prod"'})[0]
        request.addfinalizer(product.delete)
        sync_plan = entities.SyncPlan(organization=org.id).search(
            query={'search': f'name="{pre_test_name}_syncplan"'})[0]
        request.addfinalizer(sync_plan.delete)
        assert product.sync_plan.id == sync_plan.id
        assert sync_plan.name == f'{pre_test_name}_syncplan'
        assert sync_plan.interval == 'hourly'
        for sync_interval in SYNC_INTERVAL:
            if sync_interval == "custom":
                sync_plan.interval = SYNC_INTERVAL['custom']
                sync_plan.cron_expression = gen_choice(
                    valid_cron_expressions())
                sync_plan.update(['interval', 'cron_expression'])
            else:
                sync_plan.interval = SYNC_INTERVAL[sync_interval]
                sync_plan.update(['interval'])
            sync_plan = sync_plan.read()
            assert sync_plan.interval == SYNC_INTERVAL[sync_interval]
    def test_positive_update_interval_custom_cron(self):
        """Create a sync plan and update its interval to custom cron.

        :id: 26c58319-cae0-4b0c-b388-2a1fe3f22344

        :expectedresults: A sync plan is created and its interval can be
            updated to custom cron.

        :CaseImportance: Critical
        """
        for interval in valid_sync_interval():
            sync_plan = entities.SyncPlan(
                description=gen_string('alpha'),
                organization=self.org,
                interval=interval
            ).create()

            sync_plan.interval = SYNC_INTERVAL['custom']
            sync_plan.cron_expression = gen_choice(valid_cron_expressions())
            self.assertEqual(
                sync_plan.update(['interval', 'cron_expression']).interval,
                SYNC_INTERVAL['custom']
            )