tempesta-tech / tempesta-test

Test suite for Tempesta FW
10 stars 4 forks source link

merge `on-the-fly` tests into usual tests #558

Open RomanBelozerov opened 6 months ago

RomanBelozerov commented 6 months ago

We have tests for on-the-fly configuration (see reconf directory) and they repeat the logic of similar tests without on-the-fly configuration. The difference between these tests:

The scheme of the usual test:

  1. setUp + start of all services;
  2. checking the functionality;
  3. tearDown + stop of all services.

The scheme of the on-the-fly test:

  1. setUp + start of all services;
  2. Tempesta reload;
  3. checking the functionality;
  4. tearDown + stop of all services.

I suggest merging usual tests with on-the-fly tests and:

Vitaly-Skopets commented 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.