Skip to content

Commit

Permalink
Remove OpenStack bundle and make the backup test in the smoke bundle (#…
Browse files Browse the repository at this point in the history
…190)

* Remove OpenStack bundle and make the backup test in the smoke bundle

Currently, COU is using a heavy OpenStack bundle to just test the
backup functionality. It's possible to mock the part that checks
if there is a relation between keystone and mysql and use a lighter
bundle containing just 3 units of mysql-innodb-cluster and 1 unit
of designate-bind.

The upgrade of more complex bundles probably will happen on SolQA
environment (TBD).

Pros:
- faster testing
- less time running the CI
- No need to have a dedicated github runner to run the project
- Same functional test coverage with less time and less resources.

Cons:
- Miss the plan generation and run of more complex bundles.

Closes: #189

- include mysql-innodb-cluster into cou run tests.

* - add model connect on setUp
  • Loading branch information
gabrielcocenza authored Dec 8, 2023
1 parent e2669e1 commit 2154966
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 311 deletions.
34 changes: 20 additions & 14 deletions tests/functional/tests/backup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""Generic setup for functional tests."""
import logging
import os
import pathlib
import unittest
from unittest.mock import patch

import zaza
import zaza.model as zazamodel

from cou.steps.backup import backup
from cou.utils import COU_DATA
Expand All @@ -17,21 +16,28 @@
class BackupTest(unittest.TestCase):
"""Code for backup test."""

def setUp(self) -> None:
zaza.get_or_create_libjuju_thread()
model_name = zaza.model.get_juju_model()
self.model = COUModel(model_name)
zaza.sync_wrapper(self.model.connect)()

def tearDown(self) -> None:
zaza.sync_wrapper(self.model._model.disconnect)()
zaza.clean_up_libjuju_thread()

def test_backup(self):
"""Backup Test."""
# create the COU_DATA path to place the backup file
pathlib.Path(COU_DATA).mkdir(parents=True, exist_ok=True)
zaza.get_or_create_libjuju_thread()
COU_DATA.mkdir(parents=True, exist_ok=True)
sync_backup = zaza.sync_wrapper(backup)

logger.info("Running backup test....")
model_name = zazamodel.get_juju_model()
model = COUModel(model_name)
sync_connect = zaza.sync_wrapper(model.connect)

sync_connect()
backup_file = sync_backup(model)
logger.info("Backup file: %s", backup_file)
assert os.path.getsize(backup_file) > 0
self.addCleanup(os.remove, backup_file)
self.addCleanup(zaza.clean_up_libjuju_thread)
# NOTE(gabrielcocenza) mocking _check_db_relations to return True allows
# backup test without the need of deploying a heavy OpenStack bundle.
with patch("cou.steps.backup._check_db_relations") as mock_relations:
mock_relations.return_value = True
backup_file = sync_backup(self.model)
logger.info("Backup file: %s", backup_file)
assert os.path.getsize(backup_file) > 0
self.addCleanup(os.remove, backup_file)
260 changes: 0 additions & 260 deletions tests/functional/tests/bundles/openstack.yaml

This file was deleted.

4 changes: 4 additions & 0 deletions tests/functional/tests/bundles/smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ applications:
charm: ch:designate-bind
num_units: 1
channel: ussuri/stable
mysql-innodb-cluster:
charm: ch:mysql-innodb-cluster
num_units: 3
channel: 8.0/stable
Loading

0 comments on commit 2154966

Please sign in to comment.