Skip to content

Commit

Permalink
Dropped PCL support for CML versions below 2.6.0
Browse files Browse the repository at this point in the history
Dropped topology support for versions below 0.1.0
  • Loading branch information
tmikuska committed Sep 26, 2024
1 parent e2b431b commit bfcf639
Show file tree
Hide file tree
Showing 11 changed files with 241 additions and 192 deletions.
1 change: 1 addition & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
pip install -U pip
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install -r test-requirements.txt
- name: Execute tests
run: |
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,29 @@ clean-test: ## remove test and coverage artifacts
rm -f .coverage
rm -fr htmlcov/
rm -f 5f0d96.yaml
rm -f 5f0d96_inventory.ini
rm -f 5f0d96_inventory.yaml
rm -f 5f0d96_testbed.yaml
rm -f default_inventory.ini
rm -f default_inventory.yaml
rm -f default_testbed.yaml
rm -f topology.yaml
rm -f .virl/cached_cml_labs/*
rm -f .virl/current_cml_lab

lint: ## check style with flake8
flake8

coverage:
PYTHONWARNINGS="ignore::DeprecationWarning" coverage run --source=virl setup.py test
coverage run --source=virl -m pytest tests/v2/*

report: coverage
coverage html
coverage report
open htmlcov/index.html

test: ## run tests quickly with the default Python
python -W ignore::DeprecationWarning setup.py test
pytest tests/v2/*

release: dist ## package and upload a release
@echo "*** Uploading virlutils... ***"
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
asyncio_default_fixture_loop_scope = function
5 changes: 3 additions & 2 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
coverage
coveralls
flake8
pytest
requests_mock
respx
flake8
setuptools
setuptools
12 changes: 6 additions & 6 deletions tests/v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def get_alt_id(self):
def get_alt_title(self):
return "Other Lab"

def get_cml23_id(self):
def get_cml24_id(self):
return "88119b68-9d08-40c4-90f5-6dc533fd0254"

def prep_respx(self, **kwargs):
Expand Down Expand Up @@ -138,22 +138,22 @@ def setup_mocks(self, m):
"populate_lab_tiles": MockCMLServer.get_lab_tiles,
"labs/{}/topology".format(self.get_test_id()): MockCMLServer.get_topology,
"labs/{}/topology".format(self.get_alt_id()): MockCMLServer.get_alt_topology,
"labs/{}/topology".format(self.get_cml23_id()): MockCMLServer.get_topology_23,
"labs/{}/topology".format(self.get_cml24_id()): MockCMLServer.get_topology_24,
"labs/{}/lab_element_state".format(self.get_test_id()): MockCMLServer.get_lab_element_state,
"labs/{}/lab_element_state".format(self.get_cml23_id()): MockCMLServer.get_lab_element_state_23,
"labs/{}/lab_element_state".format(self.get_cml24_id()): MockCMLServer.get_lab_element_state_24,
"system_information": MockCMLServer.get_sys_info,
"labs/{}/state".format(self.get_test_id()): "STARTED",
"labs/{}/state".format(self.get_cml23_id()): "STARTED",
"labs/{}/state".format(self.get_cml24_id()): "STARTED",
"labs/{}/state".format(self.get_alt_id()): "STOPPED",
"labs/{}/check_if_converged".format(self.get_test_id()): True,
"labs/{}/check_if_converged".format(self.get_cml23_id()): True,
"labs/{}/check_if_converged".format(self.get_cml24_id()): True,
"labs/{}/nodes/n1/check_if_converged".format(self.get_test_id()): True,
"users": MockCMLServer.get_users,
}

text_dict = {
"labs/{}/download".format(self.get_test_id()): MockCMLServer.download_lab,
"labs/{}/download".format(self.get_cml23_id()): MockCMLServer.download_lab_23,
"labs/{}/download".format(self.get_cml24_id()): MockCMLServer.download_lab_24,
"labs/{}/download".format(self.get_alt_id()): MockCMLServer.download_alt_lab,
"labs/{}/pyats_testbed".format(self.get_test_id()): MockCMLServer.get_pyats_testbed,
"authok": MockCMLServer.auth_ok,
Expand Down
11 changes: 1 addition & 10 deletions tests/v2/cluster.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import unittest

from click.testing import CliRunner

from . import CLIENT_VERSION, BaseCMLTest
from .mocks.github import MockGitHub # noqa

try:
from unittest.mock import patch
except ImportError:
from mock import patch # noqa
from . import BaseCMLTest


@unittest.skipIf(CLIENT_VERSION < CLIENT_VERSION.__class__("2.4.0"), "supported since 2.4.0")
class TestCMLCluster(BaseCMLTest):
def setup_mocks(self, m):
super().setup_mocks(m)
Expand Down
6 changes: 3 additions & 3 deletions tests/v2/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def test_cml_console_connect(self, call_mock):
call_mock.assert_called_once_with(["ssh", "-t", "admin@localhost", "open", "/5f0d96/n1/0"])

@patch("virl.cli.console.commands.call", autospec=False)
def test_cml_console_connect_23(self, call_mock):
def test_cml_console_connect_24(self, call_mock):
with self.get_context() as m:
# Mock the request to return what we expect from the API.
self.setup_mocks(m)
virl = self.get_virl()
runner = CliRunner()
runner.invoke(virl, ["use", "--id", self.get_cml23_id()])
runner.invoke(virl, ["use", "--id", self.get_cml24_id()])
runner.invoke(virl, ["console", "rtr-1"])
call_mock.assert_called_once_with(["ssh", "-t", "admin@localhost", "open", "/Mock", "Test", "2.3/rtr-1/0"])
call_mock.assert_called_once_with(["ssh", "-t", "admin@localhost", "open", "/Mock", "Test", "2.4/rtr-1/0"])
Loading

0 comments on commit bfcf639

Please sign in to comment.