From 355053e7f5e0c476fc2e0ac02621d905a332d7e3 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Wed, 14 Feb 2024 13:24:58 +0100 Subject: [PATCH 1/6] Add tests to actions --- .github/workflows/main.yaml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/main.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 00000000..36b2e7cc --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,34 @@ +name: Test IM + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Check out the codebase. + uses: actions/checkout@v4 + + - name: Set up Python 3. + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: python -m pip install -r requirements-tests.txt + + - name: Check code style + run: pycodestyle --max-line-length=120 --ignore=E402,W504,W605,E722 . --exclude=doc + + - name: Test with nose + run: nosetests test/unit/connectors/*.py test/unit/*.py test/functional/*.py -v --stop --with-xunit --with-coverage --cover-erase --cover-xml --cover-package=IM,contextualization + + - name: Report coverage + uses: codacy/codacy-coverage-reporter-action@v1 + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + coverage-reports: coverage.xml \ No newline at end of file From 2c001ccd97148f694ff94a2e7c6dfac22259b41f Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Wed, 14 Feb 2024 13:27:52 +0100 Subject: [PATCH 2/6] Add tests to actions --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 36b2e7cc..67964e82 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -16,7 +16,7 @@ jobs: - name: Set up Python 3. uses: actions/setup-python@v5 with: - python-version: '3.x' + python-version: '3.10' - name: Install dependencies run: python -m pip install -r requirements-tests.txt From 15963189934b886f964153deecfbd03dac3c2580 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Wed, 14 Feb 2024 13:57:36 +0100 Subject: [PATCH 3/6] Add tests to actions --- .github/workflows/main.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 67964e82..e9dc16cf 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -25,7 +25,11 @@ jobs: run: pycodestyle --max-line-length=120 --ignore=E402,W504,W605,E722 . --exclude=doc - name: Test with nose - run: nosetests test/unit/connectors/*.py test/unit/*.py test/functional/*.py -v --stop --with-xunit --with-coverage --cover-erase --cover-xml --cover-package=IM,contextualization + #run: nosetests test/unit/connectors/*.py test/unit/*.py test/functional/*.py -v --stop --with-xunit --with-coverage --cover-erase --cover-xml --cover-package=IM,contextualization + run: python -m coverage run --source=. -m unittest discover -s test/unit -p '*.py' + + - name: Generate XML coverage report + run: python -m coverage xml - name: Report coverage uses: codacy/codacy-coverage-reporter-action@v1 From 87ca07442fe05459e7dc3373c3725f8c3c394160 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Wed, 14 Feb 2024 13:57:49 +0100 Subject: [PATCH 4/6] Add tests to actions --- requirements-tests.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements-tests.txt b/requirements-tests.txt index 60573b55..1e70097d 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -1,4 +1,5 @@ ansible >= 2.4 +ansible-base paramiko >= 1.14 PyYAML cheroot @@ -31,7 +32,6 @@ pyVmomi hvac psutil scar -nose mock coverage -requests-cache \ No newline at end of file +requests-cache From 549a77d72b6f624f0792c3fe99bcc7aef4a9cb5a Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Wed, 14 Feb 2024 15:36:49 +0100 Subject: [PATCH 5/6] Fix tests --- requirements-tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-tests.txt b/requirements-tests.txt index 1e70097d..046c9c96 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -12,7 +12,7 @@ requests >= 2.19 scp tosca-parser defusedxml -urllib3>=1.23 +urllib3>=1.23,<2.0 pycodestyle suds-py3 xmltodict From 2b56fb92603fbaa0bb99cf195e2e1e84a956c6e4 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Wed, 14 Feb 2024 09:28:57 +0100 Subject: [PATCH 6/6] Fix ONE incorrect ip in test --- test/unit/connectors/OpenNebula.py | 2 +- test/unit/connectors/files/vm_info.xml | 2 +- test/unit/connectors/files/vm_info_off.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit/connectors/OpenNebula.py b/test/unit/connectors/OpenNebula.py index e6e51b58..9c897651 100755 --- a/test/unit/connectors/OpenNebula.py +++ b/test/unit/connectors/OpenNebula.py @@ -190,7 +190,7 @@ def test_30_updateVMInfo(self, server_proxy): server_proxy.return_value = one_server success, vm = one_cloud.updateVMInfo(vm, auth) - self.assertEqual(vm.info.systems[0].getValue("net_interface.1.ip"), "10.0.0.01") + self.assertEqual(vm.info.systems[0].getValue("net_interface.1.ip"), "10.0.0.1") self.assertEqual(vm.info.systems[0].getValue("net_interface.0.ip"), "158.42.1.1") self.assertTrue(success, msg="ERROR: updating VM info.") diff --git a/test/unit/connectors/files/vm_info.xml b/test/unit/connectors/files/vm_info.xml index b594fbbb..f232a630 100644 --- a/test/unit/connectors/files/vm_info.xml +++ b/test/unit/connectors/files/vm_info.xml @@ -68,7 +68,7 @@ - + diff --git a/test/unit/connectors/files/vm_info_off.xml b/test/unit/connectors/files/vm_info_off.xml index 1727c2c0..2a3af7b5 100644 --- a/test/unit/connectors/files/vm_info_off.xml +++ b/test/unit/connectors/files/vm_info_off.xml @@ -68,7 +68,7 @@ - +