Skip to content
This repository was archived by the owner on Apr 7, 2022. It is now read-only.

[RFR] Automate BZ 1819310 - The special chars in AWX #10314

Merged
merged 6 commits into from
Sep 9, 2020
Merged

[RFR] Automate BZ 1819310 - The special chars in AWX #10314

merged 6 commits into from
Sep 9, 2020

Conversation

jarovo
Copy link
Contributor

@jarovo jarovo commented Sep 4, 2020

Purpose or Intent

  • Adding tests for BZ 1819310

PRT Run

needs PR !939 to yamls merged

{{pytest: --use-provider complete --long-running -v cfme/tests/infrastructure/test_providers.py::test_awx_with_special_chars_refreshes}}

@jarovo jarovo changed the title Automate BZ 1819310 - The special chars in AWX [RFR] Automate BZ 1819310 - The special chars in AWX Sep 4, 2020
initialEstimate: 1/20h
caseimportance: high
"""
provider_with_special_characters.setup()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure should I add a finalizer to remove the provider.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary, the setup_provider fixture will enforce the provider-limit option and remove providers from the appliance as necessary when running any tests that run after this.

Jaroslav Henner added 2 commits September 4, 2020 18:48
to make it work with code for adding the provider

I am not sure how to 100% reproduce this, but the traceback was:
```
2020-09-04 00:48:40,891 [E] [cfme] def validate(self, timeout=1000, delay=5):
        refresh_timer = RefreshTimer(time_for_refresh=300)
        try:
            wait_for(self.is_refreshed,
                     [refresh_timer],
                     message="is_refreshed",
                     timeout=timeout,
                     delay=delay,
>                    handle_exception=True)
E                    wait_for.TimedOutError: Could not do 'is_refreshed' at /home/jhenner/work/miq/bad_awx_template_bz/.cfme_venv3/lib64/python3.7/site-packages/varmeth/__init__.py:79 in time

cfme/common/provider.py:743: TimedOutError

During handling of the above exception, another exception occurred:

    @pytest.mark.provider([AnsibleTowerProvider], selector=ONE_PER_VERSION, scope="function")
    @pytest.mark.meta(automates=[1819310])
    def test_awx_with_special_chars_refreshes(appliance: IPAppliance, provider: AnsibleTowerProvider,
                                              add_special_characters):
        """
        Tests whether provider with special characters in template definition refreshes in CFME

        :param appliance:
        :param provider:
        :param add_special_characters:
        :return:

        Polarion:
          assignee
          initialEstimate
        """
        # TODO Fill this
        add_special_characters(provider)
>       provider.setup()

cfme/tests/infrastructure/test_providers.py:578:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cfme/common/provider.py:715: in setup
    return self.create_rest(check_existing=True, validate_inventory=True)
cfme/infrastructure/config_management/__init__.py:468: in create_rest
    self.validate(timeout=300)
cfme/common/provider.py:746: in validate
    self.load_details(refresh=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def load_details(self, refresh=False):
        """To be compatible with the Taggable and PolicyProfileAssignable mixins.

        Returns: ProviderDetails view
        """
        view = navigate_to(self, 'Details')
        if refresh:
>           view.toolbar.reload.click()
E           AttributeError: 'ConfigManagementToolbar' object has no attribute 'reload'
```


@pytest.mark.meta(automates=[1819310])
@pytest.mark.provider(gen_func=providers,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this mark, with the required_fields filter, should be decorating the fixture, not this test function.

The provider_with_special_characters fixture requires the special_chars_template field on the provider, and its current mark does not ensure that.

This probably functions fine - but any other test using provider_with_special_characters would have to include this provider mark as well.

I think that the mark can be simplified as well, since providers_by_class default gen func should work.

@pytest.mark.provider([AnsibleTowerProvider], selector=ONE_PER_VERSION, required_fields=['special_chars_template'])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems it doesn't work when the marker is only on the fixture. It has to be on the test. You can take look on the tests history and commits I made.

@dajoRH
Copy link
Contributor

dajoRH commented Sep 9, 2020

I detected some fixture changes in commit 9454503

The local fixture provider_with_special_characters is used in the following files:

  • cfme/tests/infrastructure/test_providers.py
    • test_awx_with_special_chars_refreshes

Please, consider creating a PRT run to make sure your fixture changes do not break existing usage 😃

""")}
empty_extra_vars = {'extra_vars': ""}

with closing(session):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice solution! Simple, even using requests directly and not awxkit.

@mshriver mshriver merged commit 4137776 into ManageIQ:master Sep 9, 2020
@mshriver mshriver added customer-case test-automation To be applied on PR's which are automating existing manual cases labels Sep 14, 2020
dgaikwad pushed a commit to dgaikwad/integration_tests that referenced this pull request Nov 25, 2020
* Automate BZ 1819310 - The special chars in AWX

* Add conf-based provider selection and some docs.

* Rename attribute refresh to reload

to make it work with code for adding the provider

I am not sure how to 100% reproduce this, but the traceback was:
```
2020-09-04 00:48:40,891 [E] [cfme] def validate(self, timeout=1000, delay=5):
        refresh_timer = RefreshTimer(time_for_refresh=300)
        try:
            wait_for(self.is_refreshed,
                     [refresh_timer],
                     message="is_refreshed",
                     timeout=timeout,
                     delay=delay,
>                    handle_exception=True)
E                    wait_for.TimedOutError: Could not do 'is_refreshed' at /home/jhenner/work/miq/bad_awx_template_bz/.cfme_venv3/lib64/python3.7/site-packages/varmeth/__init__.py:79 in time

cfme/common/provider.py:743: TimedOutError

During handling of the above exception, another exception occurred:

    @pytest.mark.provider([AnsibleTowerProvider], selector=ONE_PER_VERSION, scope="function")
    @pytest.mark.meta(automates=[1819310])
    def test_awx_with_special_chars_refreshes(appliance: IPAppliance, provider: AnsibleTowerProvider,
                                              add_special_characters):
        """
        Tests whether provider with special characters in template definition refreshes in CFME

        :param appliance:
        :param provider:
        :param add_special_characters:
        :return:

        Polarion:
          assignee
          initialEstimate
        """
        # TODO Fill this
        add_special_characters(provider)
>       provider.setup()

cfme/tests/infrastructure/test_providers.py:578:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cfme/common/provider.py:715: in setup
    return self.create_rest(check_existing=True, validate_inventory=True)
cfme/infrastructure/config_management/__init__.py:468: in create_rest
    self.validate(timeout=300)
cfme/common/provider.py:746: in validate
    self.load_details(refresh=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def load_details(self, refresh=False):
        """To be compatible with the Taggable and PolicyProfileAssignable mixins.

        Returns: ProviderDetails view
        """
        view = navigate_to(self, 'Details')
        if refresh:
>           view.toolbar.reload.click()
E           AttributeError: 'ConfigManagementToolbar' object has no attribute 'reload'
```

* Only mark the fixture with the provider marker.

* Use providers_by_class

* put provider marker on the test only
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer-case test-automation To be applied on PR's which are automating existing manual cases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants