Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RHELC-1535] Test set envar through config #1440

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions plans/tier1.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,9 @@ adjust+:
- proxy-conversion/proxy_conversion

/error-after-ponr:
enabled: false
adjust+:
- enabled: true
when: distro == alma-9, rocky-9, oracle-9
because: It will behave the same anywhere. Too expensive to run it on more hosts.
- enabled: false
because: The test is very flaky and expensive to maintain. Needs further investigation.
discover+:
# Disregarding inheritance in the test discovery.
# As the conversion fails and the system is left in an undetermined state,
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/tier1/destructive/host-metering/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ link:
- https://issues.redhat.com/browse/RHELC-1226

/test_host_metering_conversion:
environment+:
CONVERT2RHEL_CONFIGURE_HOST_METERING: force
tag+:
- test-host-metering-conversion
test: pytest -m test_run_conversion_with_host_metering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from conftest import TEST_VARS
import configparser


def setup_test_metering_endpoint():
Expand All @@ -39,6 +40,19 @@ def setup_test_metering_endpoint():
)


# TODO (danmyway) refactor this into a helper function/class when we move away from the environment variables completely
def set_the_option_in_config():
"""
Set the configure_host_metering option through the config file.
"""
config_path = "/etc/convert2rhel.ini"
config = configparser.ConfigParser()
config.read(config_path)
config.set("host_metering", "configure_host_metering", "force")
Copy link
Member

Choose a reason for hiding this comment

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

Cannot we make this as a generic helper function?, I can see that this can be used in other tests. Maybe make it as a class, that can sets different values?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have that in my backlog 😅
When we move away from the envars completely, and we'll need to set overrides through the config, I'll refactor this to a proper parameterizable helper function.
At the moment given the time constraints I see this as sufficient.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, this can be fixed later on then.

with open(config_path, "w") as file:
config.write(file)


# TODO (danmyway) We might boil this down to just a preparation of the envar and the endpoint
# and then use whatever basic conversion method for the conversion itself
# We do not really need to care about the output of the utility
Expand All @@ -52,6 +66,7 @@ def test_run_conversion_with_host_metering(shell, convert2rhel):
service on hyperscalers on RHEL 7.9.
"""
setup_test_metering_endpoint()
set_the_option_in_config()

with convert2rhel(
"-y --serverurl {} --username {} --password {} --debug".format(
Expand Down
Loading