From 6e74d42e9ee6cda409ba921437c20e9083221e0a Mon Sep 17 00:00:00 2001 From: Nageswara Nandigam Date: Sun, 25 Aug 2024 16:57:14 -0700 Subject: [PATCH 1/3] python3.5 workaround --- .github/workflows/ci_pr.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci_pr.yml b/.github/workflows/ci_pr.yml index 05d2744273..04aba384f5 100644 --- a/.github/workflows/ci_pr.yml +++ b/.github/workflows/ci_pr.yml @@ -88,6 +88,7 @@ jobs: matrix: include: - python-version: "3.5" + pip_trusted_host: "pypi.python.org pypi.org files.pythonhosted.org" - python-version: "3.6" - python-version: "3.7" - python-version: "3.8" @@ -111,6 +112,8 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + env: + PIP_TRUSTED_HOST: ${{ matrix.pip_trusted_host }} - name: Install dependencies id: install-dependencies From a7cca8a1316358ab07586314d175c55409c36e4e Mon Sep 17 00:00:00 2001 From: Nageswara Nandigam Date: Sun, 25 Aug 2024 19:03:27 -0700 Subject: [PATCH 2/3] replace assert_called_once --- .github/workflows/ci_pr.yml | 1 + tests/common/protocol/test_protocol_util.py | 8 ++++---- tests/ga/test_exthandlers.py | 2 +- tests/ga/test_exthandlers_download_extension.py | 9 +++++---- tests/test_agent.py | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci_pr.yml b/.github/workflows/ci_pr.yml index 04aba384f5..282f59395f 100644 --- a/.github/workflows/ci_pr.yml +++ b/.github/workflows/ci_pr.yml @@ -88,6 +88,7 @@ jobs: matrix: include: - python-version: "3.5" + # workaround for issue "[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:728)" on Python 3.5 pip_trusted_host: "pypi.python.org pypi.org files.pythonhosted.org" - python-version: "3.6" - python-version: "3.7" diff --git a/tests/common/protocol/test_protocol_util.py b/tests/common/protocol/test_protocol_util.py index b60ca9af95..494d25319d 100644 --- a/tests/common/protocol/test_protocol_util.py +++ b/tests/common/protocol/test_protocol_util.py @@ -188,8 +188,8 @@ def test_get_protocol_wireserver_to_wireserver_update_removes_metadataserver_art self.assertFalse(os.path.exists(mds_cert_path)) # Check firewall rules was reset - protocol_util.osutil.remove_firewall.assert_called_once() - protocol_util.osutil.enable_firewall.assert_called_once() + self.assertEqual(1, protocol_util.osutil.remove_firewall.call_count, "remove_firewall should be called once") + self.assertEqual(1, protocol_util.osutil.enable_firewall.call_count, "enable_firewall should be called once") @patch('azurelinuxagent.common.conf.get_lib_dir') @patch('azurelinuxagent.common.conf.enable_firewall') @@ -234,8 +234,8 @@ def test_get_protocol_metadataserver_to_wireserver_update_removes_metadataserver self.assertTrue(os.path.isfile(ws_cert_path)) # Check firewall rules was reset - protocol_util.osutil.remove_firewall.assert_called_once() - protocol_util.osutil.enable_firewall.assert_called_once() + self.assertEqual(1, protocol_util.osutil.remove_firewall.call_count, "remove_firewall should be called once") + self.assertEqual(1, protocol_util.osutil.enable_firewall.call_count, "enable_firewall should be called once") # Check Protocol File is updated to WireProtocol with open(os.path.join(dir, PROTOCOL_FILE_NAME), "r") as f: diff --git a/tests/ga/test_exthandlers.py b/tests/ga/test_exthandlers.py index f56ebce14b..3252dcb239 100644 --- a/tests/ga/test_exthandlers.py +++ b/tests/ga/test_exthandlers.py @@ -681,7 +681,7 @@ def test_it_should_read_only_the_head_of_large_outputs(self): self.assertGreaterEqual(len(output), 1024) self.assertLessEqual(len(output), TELEMETRY_MESSAGE_MAX_LEN) - mock_format.assert_called_once() + self.assertEqual(1, mock_format.call_count, "format_stdout_stderr should be called once") args, kwargs = mock_format.call_args # pylint: disable=unused-variable stdout, stderr = args diff --git a/tests/ga/test_exthandlers_download_extension.py b/tests/ga/test_exthandlers_download_extension.py index b3ed96a89a..9f56a0202f 100644 --- a/tests/ga/test_exthandlers_download_extension.py +++ b/tests/ga/test_exthandlers_download_extension.py @@ -127,8 +127,8 @@ def stream(_, destination, **__): self.ext_handler_instance.download() # first download attempt should succeed - mock_stream.assert_called_once() - mock_report_event.assert_called_once() + self.assertEqual(1, mock_stream.call_count, "wireserver stream should be called once") + self.assertEqual(1, mock_report_event.call_count, "report_event should be called once") self._assert_download_and_expand_succeeded() @@ -154,7 +154,7 @@ def stream(_, destination, **__): with DownloadExtensionTestCase.create_mock_stream(stream) as mock_stream: self.ext_handler_instance.download() - mock_stream.assert_called_once() + self.assertEqual(1, mock_stream.call_count, "wireserver stream should be called once") self._assert_download_and_expand_succeeded() @@ -179,7 +179,8 @@ def stream(_, destination, **__): with DownloadExtensionTestCase.create_mock_stream(stream) as mock_stream: self.ext_handler_instance.download() - mock_stream.assert_called_once() + self.assertEqual(1, mock_stream.call_count, "wireserver stream should be called once") + self._assert_download_and_expand_succeeded() self.assertEqual(self.ext_handler_instance.get_handler_state(), ExtHandlerState.NotInstalled, "Ensure that the state is maintained for extension HandlerState") diff --git a/tests/test_agent.py b/tests/test_agent.py index df1a7ca131..b57a8a7844 100644 --- a/tests/test_agent.py +++ b/tests/test_agent.py @@ -269,7 +269,7 @@ def mock_cgroup(*args, **kwargs): # pylint: disable=W0613 agent = Agent(False, conf_file_path=os.path.join(data_dir, "test_waagent.conf")) agent.collect_logs(is_full_mode=True) - mock_log_collector.assert_called_once() + self.assertEqual(1, mock_log_collector.call_count, "LogCollector should be called once") finally: CollectLogsHandler.disable_monitor_cgroups_check() From 48ff48d6e134230562b2cf57fdce219f06375e92 Mon Sep 17 00:00:00 2001 From: Nageswara Nandigam Date: Mon, 26 Aug 2024 12:15:49 -0700 Subject: [PATCH 3/3] addressing comment --- .github/workflows/ci_pr.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci_pr.yml b/.github/workflows/ci_pr.yml index 282f59395f..96db6e7f9e 100644 --- a/.github/workflows/ci_pr.yml +++ b/.github/workflows/ci_pr.yml @@ -88,7 +88,8 @@ jobs: matrix: include: - python-version: "3.5" - # workaround for issue "[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:728)" on Python 3.5 + # workaround found in https://github.com/actions/setup-python/issues/866 + # for issue "[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:728)" on Python 3.5 pip_trusted_host: "pypi.python.org pypi.org files.pythonhosted.org" - python-version: "3.6" - python-version: "3.7"