Open RomanBelozerov opened 6 months ago
We could create a new mixin class that includes the additional test scenarios related to on-the-fly reconfiguration.
class OnTheFlyReconfMixin:
def test_reconf_with_valid_params(self):
# Test reconfiguration with valid parameters
# Ensure that the Framework is correctly updated and continues to work as expected
def test_reconf_with_invalid_params(self):
# Test reconfiguration with invalid parameters
# Ensure that the Framework handles invalid configurations appropriately
# Add more test methods based on different scenarios
from framework import tester
class ExistingTests(tester.TempestaTest, OnTheFlyReconfMixin):
def setUp(self):
# Set up any necessary objects or configurations before each test
self.start_all_services()
tempesta = self.get_tempesta()
def tearDown(self):
# Clean up resources after each test
self.tempesta.cleanup()
def test_existing_scenario_1(self):
# Existing test scenario 1
# ...
def test_existing_scenario_2(self):
# Existing test scenario 2
# ...
# Add more existing test scenarios
class ExistingTests(tester.TempestaTest, OnTheFlyReconfMixin):
# ...
def test_existing_scenario_1(self):
# Existing test scenario 1
# ...
# Invoke the on-the-fly reconfiguration function
self.tempesta.reconf(valid_params)
# Assert the expected behavior after reconfiguration
self.assertTrue(self.tempesta.is_correctly_updated())
def test_existing_scenario_2(self):
# Existing test scenario 2
# ...
# Invoke the on-the-fly reconfiguration function
self.tempesta.reconfig(invalid_params)
# Assert the expected behavior after reconfiguration
self.assertFalse(self.tempesta.is_updated_with_invalid_params())
# Add similar invocations to other existing test scenarios
By organizing our tests in this way, we can maintain a clean and modular test structure. The on-the-fly reconfiguration tests are included where needed without duplicating the logic of our existing tests.
We have tests for on-the-fly configuration (see
reconf
directory) and they repeat the logic of similar tests withouton-the-fly
configuration. The difference between these tests:The scheme of the usual test:
setUp
+ start of all services;tearDown
+ stop of all services.The scheme of the
on-the-fly
test:setUp
+ start of all services;tearDown
+ stop of all services.I suggest merging usual tests with
on-the-fly
tests and:reload_directives
inTempestaTest
. (list of directives withon-the-fly
configurations);reload
should be based on an existing Tempesta config and have different parameters for directives fromreload_directives
tempesta.reload()
intempesta.start()
method ifreload_directives
is present;