-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(ovn): add verification tests for database
We realized that we actually were pointing to the wrong folder for our database. This adds tests to make sure that we verify that the database is at the right place. Depends-On: #1044 Signed-off-by: Mohammed Naser <mnaser@vexxhost.com>
- Loading branch information
Showing
12 changed files
with
152 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,5 @@ junit.xml | |
junit-go.xml | ||
ansible-lint.xml | ||
output | ||
.stestr | ||
.tox |
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,3 @@ | ||
[DEFAULT] | ||
test_path=./atmosphere/tests | ||
top_dir=./ |
Empty file.
Empty file.
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,20 @@ | ||
# Copyright (c) 2024 VEXXHOST, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from oslotest import base # type: ignore | ||
|
||
|
||
class TestOpenVswitch(base.BaseTestCase): | ||
def test_noop(self): | ||
pass |
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,79 @@ | ||
# Copyright (c) 2024 VEXXHOST, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import os | ||
from datetime import datetime, timedelta | ||
|
||
import testscenarios # type: ignore | ||
from kubernetes import client, config # type: ignore | ||
from kubernetes.stream import stream # type: ignore | ||
from oslotest import base # type: ignore | ||
from testtools import matchers, testcase # type: ignore | ||
|
||
config.load_kube_config() | ||
|
||
|
||
class TestOVN(testscenarios.WithScenarios, testcase.WithAttributes, base.BaseTestCase): | ||
scenarios = [ | ||
("ovsdb-nb", {"statefulset": "ovn-ovsdb-nb", "filename": "ovnnb_db.db"}), | ||
("ovsdb-sb", {"statefulset": "ovn-ovsdb-sb", "filename": "ovnsb_db.db"}), | ||
] | ||
|
||
def setUp(self): | ||
super(TestOVN, self).setUp() | ||
|
||
self.corev1 = client.CoreV1Api() | ||
self.appsv1 = client.AppsV1Api() | ||
|
||
if os.environ["ATMOSPHERE_NETWORK_BACKEND"] != "ovn": | ||
self.skipTest("OVN is not deployed on this cloud.") | ||
|
||
def _read_stateful_set(self): | ||
return self.appsv1.read_namespaced_stateful_set( | ||
name=self.statefulset, namespace="openstack" | ||
) | ||
|
||
def test_ovn_is_running(self): | ||
sts = self._read_stateful_set() | ||
self.assertEqual(sts.spec.replicas, sts.status.replicas) | ||
|
||
def test_ovn_is_using_correct_database_folder(self): | ||
sts = self._read_stateful_set() | ||
self.assertThat(sts.spec.volume_claim_templates, matchers.HasLength(1)) | ||
self.assertEqual(sts.spec.volume_claim_templates[0].metadata.name, "data") | ||
|
||
volume_mounts = sts.spec.template.spec.containers[0].volume_mounts | ||
volume_mount = next( | ||
( | ||
vm | ||
for vm in volume_mounts | ||
if vm.name == sts.spec.volume_claim_templates[0].metadata.name | ||
) | ||
) | ||
|
||
self.assertEqual(volume_mount.mount_path, "/etc/ovn") | ||
|
||
db_last_modified = stream( | ||
self.corev1.connect_get_namespaced_pod_exec, | ||
f"{sts.metadata.name}-0", | ||
sts.metadata.namespace, | ||
command=["stat", "-c", "%Y", f"{volume_mount.mount_path}/{self.filename}"], | ||
stdin=False, | ||
stderr=True, | ||
stdout=True, | ||
tty=False, | ||
) | ||
|
||
db_last_modified = datetime.fromtimestamp(int(db_last_modified)) | ||
self.assertTrue(db_last_modified > datetime.now() - timedelta(minutes=1)) |
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
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
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,6 @@ | ||
kubernetes | ||
molecule | ||
molecule-plugins[docker] | ||
oslotest | ||
stestr | ||
testscenarios |
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
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