Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions .github/workflows/nosetests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ClusterShell nosetests
name: ClusterShell tests

on: [push, pull_request, merge_group]

Expand All @@ -21,27 +21,36 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
set -euxo pipefail
python -m pip install --upgrade pip
pip install coverage nose-py3 .
pip install coverage .
- name: Allow us to SSH passwordless to localhost
run: |
set -euxo pipefail
chmod og-rw ~
ssh-keygen -f ~/.ssh/id_rsa -N ""
cp ~/.ssh/{id_rsa.pub,authorized_keys}
- name: Avoid ssh "known hosts" warnings
run: |
set -euxo pipefail
printf '%s\n %s\n %s\n' 'Host *' 'StrictHostKeyChecking no' 'LogLevel ERROR' >> ~/.ssh/config
- name: Set Python paths when sshing for gateway tests
run: |
set -euxo pipefail
PYTHON_SITE_PACKAGES=$(python -c "import site; print(site.getsitepackages()[0])")
sed -i "1iexport CLUSTERSHELL_GW_PYTHON_EXECUTABLE=$(which python)" ~/.bashrc
sed -i "2iexport PYTHONPATH=\$PYTHONPATH:$(realpath $pythonLocation/lib/python*/site-packages)" ~/.bashrc
head -2 ~/.bashrc
sed -i "2iexport PYTHONPATH=\$PYTHONPATH:$PYTHON_SITE_PACKAGES" ~/.bashrc
head -3 ~/.bashrc
ssh 127.0.0.2 'python -c "import ClusterShell; print(ClusterShell.__file__)"'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this was for debugging, do we want to keep it? (ssh needs to work for tests anyway so I think it's fine to keep)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly! I forgot to remove it. It's for troubleshooting the "remote" availability of the ClusterShell modules. But it can't hurt, I will keep it for now then.

- name: Install pdsh to test WorkerPdsh
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get -y install pdsh
sudo sh -c 'echo ssh > /etc/pdsh/rcmd_default'
- name: Add tests/bin to remote PATH
run: |
set -euxo pipefail
sed -i "1iexport PATH=$PWD/tests/bin:\$PATH" ~/.bashrc
head -1 ~/.bashrc
ssh 127.0.0.2 which hostname
Expand Down Expand Up @@ -78,9 +87,11 @@ jobs:
- name: Run tests
id: tests
run: |
set -euxo pipefail
python --version
export CLUSTERSHELL_GW_PYTHON_EXECUTABLE=$(which python)
nosetests -v --all-modules --with-coverage --cover-tests --cover-erase --cover-package=ClusterShell tests
coverage run --branch --source=ClusterShell -m unittest discover -v -s tests -p '*Test.py' -t .
coverage report -m
- name: Post to Slack (end)
if: always()
continue-on-error: true
Expand Down
2 changes: 1 addition & 1 deletion tests/CLIClubakTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from textwrap import dedent
import unittest

from TLib import *
from .TLib import *
from ClusterShell.CLI.Clubak import main

from ClusterShell.NodeSet import set_std_group_resolver, \
Expand Down
9 changes: 5 additions & 4 deletions tests/CLIClushTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from subprocess import Popen, PIPE

from TLib import *
from .TLib import *
import ClusterShell.CLI.Clush
from ClusterShell.CLI.Clush import main
from ClusterShell.NodeSet import NodeSet
Expand Down Expand Up @@ -443,10 +443,11 @@ def test_027_warn_shell_globbing_nodes(self):
curdir = os.getcwd()
try:
os.chdir(tdir.name)
s = "Warning: using '-w %s' and local path '%s' exists, was it " \
"expanded by the shell?\n" % (HOSTNAME, HOSTNAME)
s = b"Warning: using '-w %s' and local path '%s' exists, was it " \
b"expanded by the shell?\n" % (HOSTNAME.encode(), HOSTNAME.encode())
# Use regex to match start of stderr, allowing for additional warnings
self._clush_t(["-w", HOSTNAME, "echo", "ok"], None,
self.output_ok, 0, s.encode())
self.output_ok, 0, re.compile(re.escape(s)))
finally:
os.chdir(curdir)
tfile.close()
Expand Down
2 changes: 1 addition & 1 deletion tests/CLIConfigTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from textwrap import dedent
import unittest

from TLib import *
from .TLib import *

from ClusterShell.CLI.Clush import set_fdlimit
from ClusterShell.CLI.Config import ClushConfig, ClushConfigError
Expand Down
2 changes: 1 addition & 1 deletion tests/CLINodesetTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from textwrap import dedent
import unittest

from TLib import *
from .TLib import *
from ClusterShell.CLI.Nodeset import main

from ClusterShell.NodeUtils import GroupResolverConfig
Expand Down
2 changes: 1 addition & 1 deletion tests/DefaultsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from textwrap import dedent
import unittest

from TLib import make_temp_file, make_temp_dir
from .TLib import make_temp_file, make_temp_dir

from ClusterShell.Defaults import Defaults, _task_print_debug

Expand Down
2 changes: 1 addition & 1 deletion tests/MisusageTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import unittest

from TLib import HOSTNAME
from .TLib import HOSTNAME
from ClusterShell.Event import EventHandler
from ClusterShell.Worker.Popen import WorkerPopen
from ClusterShell.Worker.Ssh import WorkerSsh
Expand Down
2 changes: 1 addition & 1 deletion tests/NodeSetGroupTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from textwrap import dedent
import unittest

from TLib import *
from .TLib import *

# Wildcard import for testing purpose
from ClusterShell.NodeSet import *
Expand Down
2 changes: 1 addition & 1 deletion tests/TaskDistantMixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import unittest
import warnings

from TLib import HOSTNAME, make_temp_filename, make_temp_dir
from .TLib import HOSTNAME, make_temp_filename, make_temp_dir
from ClusterShell.Event import EventHandler
from ClusterShell.Task import *
from ClusterShell.Worker.Ssh import WorkerSsh
Expand Down
2 changes: 1 addition & 1 deletion tests/TaskDistantPdshMixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"""Unit test for ClusterShell Task (distant, pdsh worker)"""

from TLib import HOSTNAME, make_temp_filename, make_temp_dir
from .TLib import HOSTNAME, make_temp_filename, make_temp_dir
from ClusterShell.Event import EventHandler
from ClusterShell.Task import *
from ClusterShell.Worker.Worker import WorkerBadArgumentError
Expand Down
2 changes: 1 addition & 1 deletion tests/TaskDistantPdshTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ClusterShell.Engine.EPoll import EngineEPoll
from ClusterShell.Task import *

from TaskDistantPdshMixin import TaskDistantPdshMixin
from .TaskDistantPdshMixin import TaskDistantPdshMixin

ENGINE_SELECT_ID = EngineSelect.identifier
ENGINE_POLL_ID = EnginePoll.identifier
Expand Down
2 changes: 1 addition & 1 deletion tests/TaskDistantTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ClusterShell.Engine.EPoll import EngineEPoll
from ClusterShell.Task import *

from TaskDistantMixin import TaskDistantMixin
from .TaskDistantMixin import TaskDistantMixin

ENGINE_SELECT_ID = EngineSelect.identifier
ENGINE_POLL_ID = EnginePoll.identifier
Expand Down
2 changes: 1 addition & 1 deletion tests/TaskLocalTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ClusterShell.Engine.EPoll import EngineEPoll
from ClusterShell.Task import *

from TaskLocalMixin import TaskLocalMixin
from .TaskLocalMixin import TaskLocalMixin

ENGINE_SELECT_ID = EngineSelect.identifier
ENGINE_POLL_ID = EnginePoll.identifier
Expand Down
2 changes: 1 addition & 1 deletion tests/TaskRLimitsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import resource
import unittest

from TLib import HOSTNAME
from .TLib import HOSTNAME
from ClusterShell.Task import *
from ClusterShell.Worker.Pdsh import WorkerPdsh

Expand Down
2 changes: 1 addition & 1 deletion tests/TaskTimerTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from time import sleep, time
import unittest

from TLib import HOSTNAME
from .TLib import HOSTNAME
from ClusterShell.Engine.Engine import EngineTimer, EngineIllegalOperationError
from ClusterShell.Event import EventHandler
from ClusterShell.Task import *
Expand Down
2 changes: 1 addition & 1 deletion tests/TreeGatewayTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from ClusterShell.Worker.Tree import TreeWorker
from ClusterShell.Worker.Worker import StreamWorker

from TLib import HOSTNAME
from .TLib import HOSTNAME

# live logging with nosetests --nologcapture
logging.basicConfig(level=logging.DEBUG)
Expand Down
2 changes: 1 addition & 1 deletion tests/TreeTaskTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ClusterShell.Task import task_self
from ClusterShell.Topology import TopologyError

from TLib import HOSTNAME, make_temp_file
from .TLib import HOSTNAME, make_temp_file

# live logging with nosetests --nologcapture
logging.basicConfig(level=logging.DEBUG)
Expand Down
2 changes: 1 addition & 1 deletion tests/TreeTopologyTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ClusterShell.NodeSet import NodeSet, set_std_group_resolver
from ClusterShell.NodeSet import set_std_group_resolver_config
from ClusterShell.NodeUtils import GroupResolverConfig
from TLib import make_temp_file
from .TLib import make_temp_file


class TopologyTest(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/TreeWorkerTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from ClusterShell.Topology import TopologyGraph
from ClusterShell.Worker.Tree import TreeWorker, WorkerTree

from TLib import HOSTNAME, make_temp_dir, make_temp_file, make_temp_filename
from .TLib import HOSTNAME, make_temp_dir, make_temp_file, make_temp_filename


NODE_HEAD = HOSTNAME
Expand Down
2 changes: 1 addition & 1 deletion tests/WorkerExecTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import unittest

from TLib import HOSTNAME, make_temp_file, make_temp_filename, make_temp_dir
from .TLib import HOSTNAME, make_temp_file, make_temp_filename, make_temp_dir

from ClusterShell.Event import EventHandler
from ClusterShell.Worker.Exec import ExecWorker, WorkerError
Expand Down
Empty file added tests/__init__.py
Empty file.
Loading