Skip to content

Commit

Permalink
Fix unit and smoke tests failure under Python 2.6 (#546)
Browse files Browse the repository at this point in the history
* Don't install various deb and Python dependencies when running unit and smoke
tests under Python 2.6 and skip some tests which depend on those
libraries.

For the last couple of days the tests have been failing due to
conflicting versions of some packages.

Sadly we can't easily resolve those version conflicts (it's hard to get
up to date Docker image with Python 2.6 and we don't want maintain our
own at this point).
  • Loading branch information
Kami committed May 21, 2020
1 parent eba43ec commit 4a387d0
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
10 changes: 8 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,10 @@ jobs:
python_version: "2.6"
tox_version: "2.9.1"
tox_target: "py2.6-unit-tests"
apt_dependencies: "procps build-essential"
apt_dependencies: "procps"
# NOTE: We simply skip tests which depend on those dependencies since
# there appear to be broken upstream since May 20th, 2020
#apt_dependencies: "build-essential"

smoke-standalone-27-tls12:
docker:
Expand Down Expand Up @@ -1268,7 +1271,10 @@ jobs:
tox_target: "py2.6-smoke-tests"
# NOTE: This is needed otherwise it falls back to Circle CI git client
pre_checkout_apt_dependencies: "git openssh-client"
apt_dependencies: "procps build-essential"
apt_dependencies: "procps"
# NOTE: We simply skip tests which depend on those dependencies since
# there appear to be broken upstream since May 20th, 2020
#apt_dependencies: "build-essential"

package-test-rpm:
working_directory: ~/scalyr-agent-2
Expand Down
4 changes: 3 additions & 1 deletion py26-unit-tests-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ docker==3.6.0
requests==2.18.0
pathlib2==2.3.5
PyYAML==4.2b4
psutil==5.7.0
# Depends on build-essential which we have trouble installing on
# Docker image we use
#psutil==5.7.0
# Needed by MockHTTPServer class and related tests
# NOTE: We can't use flask >= 1.1.0 because we still run tests under Python 2.6.
# Actual library is also only used by the tests.
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/builtin_monitors/linux_process_metrics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@

import mock

try:
import psutil
except ImportError:
psutil = None

from scalyr_agent.builtin_monitors.linux_process_metrics import ProcessMonitor
from scalyr_agent.scalyr_monitor import load_monitor_class
from scalyr_agent.test_base import ScalyrTestCase
Expand All @@ -31,6 +36,10 @@

class LinuxProcessMetricsMonitorTest(ScalyrTestCase):
@skipIf(platform.system() == "Darwin", "Skipping Linux Monitor tests on OSX")
@skipIf(
not psutil,
"Skipping tests because psutil is not available (likely running under Python 3.6 on Circle CI)",
)
def test_gather_sample_by_pid_success(self):
monitor_config = {
"module": "linux_process_metrics",
Expand All @@ -49,6 +58,10 @@ def test_gather_sample_by_pid_success(self):
self.assertEqual(mock_logger.emit_value.call_count, len(monitor_info.metrics))

@skipIf(platform.system() == "Darwin", "Skipping Linux Monitor tests on OSX")
@skipIf(
not psutil,
"Skipping tests because psutil is not available (likely running under Python 2.6 on Circle CI)",
)
def test_gather_sample_by_commandline_success(self):
monitor_config = {
"module": "linux_process_metrics",
Expand All @@ -67,6 +80,10 @@ def test_gather_sample_by_commandline_success(self):
self.assertEqual(mock_logger.emit_value.call_count, len(monitor_info.metrics))

@skipIf(platform.system() == "Darwin", "Skipping Linux Monitor tests on OSX")
@skipIf(
not psutil,
"Skipping tests because psutil is not available (likely running under Python 2.6 on Circle CI)",
)
def test_gather_sample_by_pid_failure_pid_doesnt_exist(self):
monitor_config = {
"module": "linux_process_metrics",
Expand Down
26 changes: 26 additions & 0 deletions tests/unit/linux_process_metrics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@

import os

try:
import psutil
except ImportError:
psutil = None

from scalyr_agent.compat import custom_defaultdict as defaultdict
from scalyr_agent.builtin_monitors.linux_process_metrics import (
ProcessMonitor,
Expand All @@ -33,6 +38,7 @@
from scalyr_agent.test_base import ScalyrTestCase
import scalyr_agent.scalyr_logging as scalyr_logging
from scalyr_agent.scalyr_monitor import MonitorInformation
from scalyr_agent.test_base import skipIf

from six.moves import range

Expand Down Expand Up @@ -217,10 +223,18 @@ def test_multi_process_multi_epochs(self):


class TestProcessListUtility(ScalyrTestCase):
@skipIf(
not psutil,
"Skipping tests because psutil is not available (likely running under Python 2.6 on Circle CI)",
)
def setUp(self):
super(TestProcessListUtility, self).setUp()
self.ps = ProcessList()

@skipIf(
not psutil,
"Skipping tests because psutil is not available (likely running under Python 2.6 on Circle CI)",
)
def test_no_process(self):
# override
self.ps.parent_to_children_map = defaultdict(list)
Expand All @@ -230,6 +244,10 @@ def test_no_process(self):
self.assertEqual(self.ps.get_matches_commandline(".*"), [])
self.assertEqual(self.ps.get_matches_commandline_with_children(".*"), [])

@skipIf(
not psutil,
"Skipping tests because psutil is not available (likely running under Python 2.6 on Circle CI)",
)
def test_single_process_no_children(self):
# override
# process id 0 is basically no process. PID 1 is the main process of a terminal
Expand All @@ -251,6 +269,10 @@ def test_single_process_no_children(self):
set(self.ps.get_matches_commandline_with_children(".*")), set([1, 2])
)

@skipIf(
not psutil,
"Skipping tests because psutil is not available (likely running under Python 2.6 on Circle CI)",
)
def test_single_process_with_children(self):
# override
# process id 0 is basically no process. PID 1 is the main process of a terminal
Expand All @@ -275,6 +297,10 @@ def test_single_process_with_children(self):
set(self.ps.get_matches_commandline_with_children(".*")), set([1, 2, 3])
)

@skipIf(
not psutil,
"Skipping tests because psutil is not available (likely running under Python 2.6 on Circle CI)",
)
def test_multiple_processes_with_children(self):
# override
# process id 0 is basically no process. PID 1 is the main process of a terminal
Expand Down

0 comments on commit 4a387d0

Please sign in to comment.