Skip to content

Refactor: Extract common network test utilities into base class #626

@RusselSand

Description

@RusselSand

Problem
Network infrastructure setup/teardown code (create_network, destroy_network) is duplicated across multiple functional test modules:

tests/functional/sdk/dns/init.py
tests/functional/sdk/vlb/init.py
tests/functional/sdk/nat/v2/test_gateway.py
tests/functional/sdk/dcaas/v2/base.py

Each module has its own copy of essentially the same code for creating network, subnet, router and cleaning them up.

Proposal
Create a shared base class NetworkBaseFunctionalTest in tests/functional/base.py:

class NetworkBaseFunctionalTest(BaseFunctionalTest):
    """Base class for tests requiring network infrastructure."""
    
    def create_network(self, prefix='sdk-test'):
        """Create network, subnet, router and return dict with IDs."""
        ...
    
    def destroy_network(self, params: dict):
        """Cleanup network infrastructure."""
        ...
    
    def create_port(self, network_id, prefix='sdk-test'):
        """Create a port in the given network."""
        ...
    
    def destroy_port(self, port):
        """Delete the given port."""

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions