-
Notifications
You must be signed in to change notification settings - Fork 543
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
[sunbeam][tests] Add product tests for sunbeam #3837
Draft
arif-ali
wants to merge
1
commit into
sosreport:main
Choose a base branch
from
arif-ali:sos-arif-sunbeam-func-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Copyright (C) 2024 Canonical Ltd., Arif Ali <[email protected]> | ||
|
||
# This file is part of the sos project: https://github.com/sosreport/sos | ||
# | ||
# This copyrighted material is made available to anyone wishing to use, | ||
# modify, copy, or redistribute it subject to the terms and conditions of | ||
# version 2 of the GNU General Public License. | ||
# | ||
# See the LICENSE file in the source distribution for further information. | ||
|
||
from sos_tests import StageOneReportTest | ||
|
||
|
||
class JujuBasicTest(StageOneReportTest): | ||
"""Ensure that a basic execution runs as expected with simple deployment. | ||
|
||
:avocado: tags=sunbeam | ||
""" | ||
|
||
sos_cmd = '-v -o juju' | ||
arch = ['x86_64'] | ||
|
||
ubuntu_only = True | ||
|
||
def test_unit_agent_conf_collected(self): | ||
self.assertFileCollected('/var/lib/juju/agents/machine-0/agent.conf') | ||
self.assertFileCollected('/var/log/juju/machine-0.log') | ||
|
||
# def test_unit_commands_collected(self): | ||
# cmds_to_check = [ | ||
# 'juju_engine_report', | ||
# 'juju_goroutines', | ||
# 'juju_heap_profile', | ||
# 'juju_leases', | ||
# 'juju_metrics', | ||
# 'juju_pubsub_report', | ||
# 'juju_presence_report', | ||
# 'juju_statepool_report', | ||
# 'juju_statetracker_report', | ||
# 'juju_unit_status', | ||
# ] | ||
# | ||
# for the_cmd in cmds_to_check: | ||
# self.assertFileCollected(f'sos_commands/juju/{the_cmd}') | ||
|
||
def test_unit_agent_conf_cert_scrubbed(self): | ||
file = '/var/lib/juju/agents/machine-0/agent.conf' | ||
|
||
check_cert_scrub = [ | ||
"cacert", | ||
"controllercert", | ||
] | ||
for cert in check_cert_scrub: | ||
self.assertFileHasContent( | ||
file, f'{cert}: |\n -----SCRUBBED CERTIFICATE-----') | ||
|
||
def test_unit_agent_conf_private_cert_scrubbed(self): | ||
file = '/var/lib/juju/agents/machine-0/agent.conf' | ||
check_priv_key = [ | ||
"controllerkey", | ||
"caprivatekey", | ||
] | ||
for priv in check_priv_key: | ||
self.assertFileHasContent( | ||
file, f'{priv}: |\n -----SCRUBBED PRIVATE KEY-----') | ||
|
||
def test_unit_agent_conf_private_cert_rsa_scrubbed(self): | ||
file = '/var/lib/juju/agents/machine-0/agent.conf' | ||
check_priv_rsa_key = [ | ||
"systemidentity", | ||
] | ||
|
||
for priv_rsa in check_priv_rsa_key: | ||
self.assertFileHasContent( | ||
file, f'{priv_rsa}: |\n -----SCRUBBED RSA PRIVATE KEY-----') | ||
|
||
def test_unit_agent_conf_secrets_scrubbed(self): | ||
file = '/var/lib/juju/agents/machine-0/agent.conf' | ||
|
||
check_key_scrub = [ | ||
"sharedsecret", | ||
"apipassword", | ||
"oldpassword", | ||
"statepassword", | ||
] | ||
|
||
for key in check_key_scrub: | ||
self.assertFileHasContent(file, rf'{key}: \*\*\*\*\*\*\*\*\*') | ||
|
||
# vim: et ts=4 sw=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Copyright (C) 2024 Canonical Ltd., Arif Ali <[email protected]> | ||
|
||
# This file is part of the sos project: https://github.com/sosreport/sos | ||
# | ||
# This copyrighted material is made available to anyone wishing to use, | ||
# modify, copy, or redistribute it subject to the terms and conditions of | ||
# version 2 of the GNU General Public License. | ||
# | ||
# See the LICENSE file in the source distribution for further information. | ||
|
||
from sos_tests import StageOneReportTest | ||
|
||
|
||
class K8sBasicTest(StageOneReportTest): | ||
"""Ensure that a basic execution runs as expected with simple deployment. | ||
|
||
:avocado: tags=sunbeam | ||
""" | ||
|
||
sos_cmd = '-v -o kubernetes' | ||
arch = ['x86_64'] | ||
|
||
ubuntu_only = True | ||
|
||
k8s_cmd = "k8s" | ||
|
||
def test_k8s_config_collected(self): | ||
k8s_common = "/var/snap/k8s/common" | ||
|
||
k8s_files = [ | ||
f"{k8s_common}/args", | ||
f"{k8s_common}/var/lib/k8s-dqlite/info.yaml", | ||
f"{k8s_common}/var/lib/k8s-dqlite/cluster.yaml", | ||
f"{k8s_common}/var/lib/k8sd/state/truststore/k8s.yaml", | ||
f"{k8s_common}/var/lib/k8sd/state/database/info.yaml", | ||
f"{k8s_common}/var/lib/k8sd/state/database/cluster.yaml", | ||
f"{k8s_common}/var/lib/k8sd/state/daemon.yaml", | ||
] | ||
|
||
for file in k8s_files: | ||
self.assertFileCollected(file) | ||
|
||
def test_k8s_cmd_ran(self): | ||
ran_cmds = [ | ||
"status", | ||
"get", | ||
] | ||
for cmd_run in ran_cmds: | ||
self.assertFileCollected( | ||
f'sos_commands/kubernetes/{self.k8s_cmd}_{cmd_run}') | ||
|
||
def test_kubectl_cmd_ran(self): | ||
kube_cmd = f"{self.k8s_cmd}_kubectl" | ||
|
||
ran_cmds = [ | ||
'config_view', | ||
'get_--all-namespaces_true_clusterrolebindings', | ||
'get_--all-namespaces_true_clusterroles', | ||
'get_--all-namespaces_true_configmaps', | ||
'get_--all-namespaces_true_cronjobs', | ||
'get_--all-namespaces_true_daemonsets', | ||
'get_--all-namespaces_true_deployments', | ||
'get_--all-namespaces_true_endpoints', | ||
'get_--all-namespaces_true_events', | ||
'get_--all-namespaces_true_ingresses', | ||
'get_--all-namespaces_true_jobs', | ||
'get_--all-namespaces_true_limitranges', | ||
'get_--all-namespaces_true_pods', | ||
'get_--all-namespaces_true_pvc', | ||
'get_--all-namespaces_true_replicasets', | ||
'get_--all-namespaces_true_resourcequotas', | ||
'get_--all-namespaces_true_secrets', | ||
'get_--all-namespaces_true_serviceaccounts', | ||
'get_--all-namespaces_true_services', | ||
'get_--all-namespaces_true_statefulsets', | ||
'get_--raw_.metrics', | ||
'get_-o_json_nodes', | ||
'get_namespaces', | ||
'get_nodes', | ||
'get_pv', | ||
'get_rolebindings', | ||
'get_roles', | ||
'get_sc', | ||
'version', | ||
] | ||
|
||
for cmd_run in ran_cmds: | ||
self.assertFileCollected( | ||
'sos_commands/kubernetes/cluster-info/' | ||
f'{kube_cmd}_{cmd_run}') | ||
|
||
|
||
# vim: et ts=4 sw=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (C) 2024 Canonical Ltd., Arif Ali <[email protected]> | ||
|
||
# This file is part of the sos project: https://github.com/sosreport/sos | ||
# | ||
# This copyrighted material is made available to anyone wishing to use, | ||
# modify, copy, or redistribute it subject to the terms and conditions of | ||
# version 2 of the GNU General Public License. | ||
# | ||
# See the LICENSE file in the source distribution for further information. | ||
|
||
from sos_tests import StageOneReportTest | ||
|
||
|
||
class OvnBasicTest(StageOneReportTest): | ||
"""Ensure that a basic execution runs as expected with simple deployment. | ||
|
||
:avocado: tags=sunbeam | ||
""" | ||
|
||
sos_cmd = '-v -o ovn_host' | ||
arch = ['x86_64'] | ||
|
||
ubuntu_only = True | ||
|
||
def test_ovn_cmds_collected(self): | ||
ran_cmds = [ | ||
'openstack-hypervisor.ovs-vsctl_list_Open_vSwitch', | ||
'openstack-hypervisor.ovs-ofctl_-O_OpenFlow13_dump-flows_br-int', | ||
'openstack-hypervisor.ovs-vsctl_list-br', | ||
] | ||
for cmd in ran_cmds: | ||
self.assertFileCollected(f'sos_commands/ovn_host/{cmd}') | ||
|
||
# vim: et ts=4 sw=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# Copyright (C) 2024 Canonical Ltd., Arif Ali <[email protected]> | ||
|
||
# This file is part of the sos project: https://github.com/sosreport/sos | ||
# | ||
# This copyrighted material is made available to anyone wishing to use, | ||
# modify, copy, or redistribute it subject to the terms and conditions of | ||
# version 2 of the GNU General Public License. | ||
# | ||
# See the LICENSE file in the source distribution for further information. | ||
|
||
from sos_tests import StageOneReportTest | ||
|
||
|
||
class SunbeamBasicTest(StageOneReportTest): | ||
"""Ensure that a basic execution runs as expected with simple deployment. | ||
|
||
:avocado: tags=sunbeam | ||
""" | ||
|
||
sos_cmd = '-v' | ||
arch = ['x86_64'] | ||
|
||
ubuntu_only = True | ||
sos_timeout = 1200 | ||
|
||
sunbeam_common = "/var/snap/openstack/common" | ||
sunbeam_current = "/var/snap/openstack/current" | ||
|
||
hypervisor_common = "/var/snap/openstack-hypervisor/common" | ||
|
||
check_obfuscate = [ | ||
r"transport_url = \*\*\*\*\*\*\*\*\*", | ||
r"password = \*\*\*\*\*\*\*\*\*", | ||
] | ||
|
||
def test_plugins_ran(self): | ||
self.assertPluginIncluded([ | ||
'juju', | ||
'libvirt', | ||
'kubernetes', | ||
'ovn_host', | ||
'sunbeam', | ||
'sunbeam_hypervisor', | ||
]) | ||
|
||
def test_sunbeam_keys_skipped(self): | ||
self.assertFileGlobNotInArchive( | ||
f"{self.hypervisor_common}/etc/pki/**/*.pem") | ||
self.assertFileGlobNotInArchive( | ||
f"{self.hypervisor_common}/etc/ssl/**/*.pem") | ||
|
||
def test_sunbeam_installer_dirs_collected(self): | ||
self.assertFileGlobInArchive("/etc/sunbeam-installer/*") | ||
self.assertFileGlobInArchive("/var/log/sunbeam-installer/*") | ||
|
||
def test_sunbeam_openstack_config_files_collected(self): | ||
files_collected = [ | ||
f'{self.sunbeam_common}/state/daemon.yaml', | ||
f'{self.sunbeam_common}/state/database/info.yaml', | ||
f'{self.sunbeam_common}/state/database/cluster.yaml', | ||
f'{self.sunbeam_current}/config.yaml', | ||
] | ||
for file in files_collected: | ||
self.assertFileCollected(file) | ||
|
||
def test_sunbeam_nova_log_collected(self): | ||
self.assertFileCollected( | ||
f'{self.hypervisor_common}/var/log/nova/nova.log') | ||
|
||
def test_sunbeam_neutron_log_collected(self): | ||
self.assertFileCollected( | ||
f'{self.hypervisor_common}/var/log/neutron/neutron.log') | ||
|
||
def test_sunbeam_ovn_controller_log_collected(self): | ||
self.assertFileCollected( | ||
f'{self.hypervisor_common}/var/log/ovn/ovn-controller.log') | ||
|
||
def test_sunbeam_openvswitch_log_collected(self): | ||
self.assertFileCollected( | ||
f'{self.hypervisor_common}/var/log/openvswitch/ovs-vswitchd.log') | ||
self.assertFileCollected( | ||
f'{self.hypervisor_common}/var/log/openvswitch/ovsdb-server.log') | ||
|
||
def test_sunbeam_cluster_list_collected_(self): | ||
self.assertFileCollected('sos_commands/sunbeam/sunbeam_cluster_list') | ||
|
||
def test_sunbeam_juju_configs_controller_collected(self): | ||
files_collected = [ | ||
'juju_status_-m_sunbeam-controller_admin.controller', | ||
'juju_model-config_-m_sunbeam-controller_admin.controller', | ||
] | ||
|
||
for file in files_collected: | ||
self.assertFileCollected(f'sos_commands/sunbeam/{file}') | ||
|
||
def test_sunbeam_nova_conf_collected_and_obfuscated(self): | ||
nova_conf = f'{self.hypervisor_common}/etc/nova/nova.conf' | ||
self.assertFileCollected(nova_conf) | ||
|
||
for check in self.check_obfuscate: | ||
self.assertFileHasContent(nova_conf, check) | ||
|
||
def test_sunbeam_neutron_conf_collected_and_obfuscated(self): | ||
neutron_conf = f'{self.hypervisor_common}/etc/neutron/neutron.conf' | ||
self.assertFileCollected(neutron_conf) | ||
|
||
for check in self.check_obfuscate: | ||
self.assertFileHasContent(neutron_conf, check) | ||
|
||
def test_sunbeam_ceilometer_conf_collected_and_obfuscated(self): | ||
ceilometer_conf = (f'{self.hypervisor_common}/etc/ceilometer/' | ||
'ceilometer.conf') | ||
self.assertFileCollected(ceilometer_conf) | ||
|
||
for check in self.check_obfuscate: | ||
self.assertFileHasContent(ceilometer_conf, check) | ||
|
||
def test_sunbeam_masakarimonitors_conf_collected_and_obfuscated(self): | ||
masakari_conf = (f'{self.hypervisor_common}/etc/masakarimonitors/' | ||
'masakarimonitors.conf') | ||
self.assertFileCollected(masakari_conf) | ||
|
||
self.assertFileHasContent( | ||
masakari_conf, r"password = \*\*\*\*\*\*\*\*\*") | ||
|
||
# vim: et ts=4 sw=4 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have left this here, as we need to add this to functional tests. We need to now figure out what happened in my previous PR on adding these commands, as we should be capturing this.
Once that is resolved, we can enable this section.