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

feat: Add option to run smoke tests with fake IMDS servers. #3380

Merged
merged 1 commit into from
Jun 5, 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
10 changes: 10 additions & 0 deletions src/cloud_what/providers/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ def _smoke_tests():
"""
# Gather only information about hardware and virtualization
from rhsmlib.facts.host_collector import HostCollector
from rhsmlib.facts.custom import CustomFactsCollector
import sys

root = logging.getLogger()
Expand All @@ -396,6 +397,15 @@ def _smoke_tests():

facts = {}
facts.update(HostCollector().get_all())
# To test AWS cloud provider on localhost create following file
# /etc/rhsm/facts/aws.facts
# {
# "virt.is_guest": true,
# "dmi.bios.version": "amazon",
# "dmi.bios.vendor": "Amazon EC2",
# "virt.host_type": "aws"
# }
facts.update(CustomFactsCollector().get_all())
aws_cloud_provider = AWSCloudProvider(facts)
result = aws_cloud_provider.is_running_on_cloud()
probability = aws_cloud_provider.is_likely_running_on_cloud()
Expand Down
8 changes: 8 additions & 0 deletions src/cloud_what/providers/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def _smoke_tests():
"""
# Gather only information about hardware and virtualization
from rhsmlib.facts.host_collector import HostCollector
from rhsmlib.facts.custom import CustomFactsCollector

import sys

Expand All @@ -273,6 +274,13 @@ def _smoke_tests():

facts = {}
facts.update(HostCollector().get_all())
# To test Azure cloud provider on localhost create following file
# /etc/rhsm/facts/azure.facts
# {
# "virt.is_guest": true,
# "dmi.chassis.asset_tag": "7783-7084-3265-9085-8269-3286-77"
# }
facts.update(CustomFactsCollector().get_all())
azure_cloud_provider = AzureCloudProvider(facts)
result = azure_cloud_provider.is_running_on_cloud()
probability = azure_cloud_provider.is_likely_running_on_cloud()
Expand Down
5 changes: 5 additions & 0 deletions src/cloud_what/providers/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ def _smoke_test():
"""
# Gather only information about hardware and virtualization
from rhsmlib.facts.host_collector import HostCollector
from rhsmlib.facts.custom import CustomFactsCollector

import sys

Expand All @@ -363,6 +364,10 @@ def _smoke_test():

facts = {}
facts.update(HostCollector().get_all())
# To test Azure cloud provider on localhost create following file
# /etc/rhsm/facts/gcp.facts
#
facts.update(CustomFactsCollector().get_all())
gcp_cloud_provider = GCPCloudProvider(facts)
result = gcp_cloud_provider.is_running_on_cloud()
probability = gcp_cloud_provider.is_likely_running_on_cloud()
Expand Down
Loading