-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sunbeam][tests] Add product tests for sunbeam
* Move the juju tests now to sunbeam, now that we deploy using juju here, no need to mock the configuration files. * Include plugins that are associated here - kubernetes - microk8s - ovn_host - juju Related: #3622 Signed-off-by: Arif Ali <[email protected]>
- Loading branch information
Showing
10 changed files
with
363 additions
and
265 deletions.
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,88 @@ | ||
# 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,83 @@ | ||
# 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 microk8s,kubernetes' | ||
arch = ['x86_64'] | ||
|
||
ubuntu_only = True | ||
|
||
microk8s_cmd = "microk8s" | ||
|
||
def test_client_config_collected(self): | ||
self.assertFileCollected( | ||
'/var/snap/microk8s/current/credentials/client.config') | ||
|
||
def test_microk8s_cmd_ran(self): | ||
ran_cmds = [ | ||
"addons_repo_list", | ||
"config", | ||
"ctr_plugins_ls", | ||
"ctr_plugins_ls_-d", | ||
"status", | ||
"version", | ||
] | ||
for cmd_run in ran_cmds: | ||
self.assertFileCollected( | ||
f'sos_commands/microk8s/{self.microk8s_cmd}_{cmd_run}') | ||
|
||
def test_kubernetes_cmd_ran(self): | ||
kube_cmd = f"{self.microk8s_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,32 @@ | ||
# 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,116 @@ | ||
# 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) | ||
|
||
# vim: et ts=4 sw=4 |
Oops, something went wrong.