Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests for 1.9.2 #531

Merged
merged 8 commits into from
Sep 18, 2023
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
14 changes: 6 additions & 8 deletions .github/workflows/nosetests.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
name: ClusterShell nosetests

on: [push, pull_request]
on: [push, pull_request, merge_group]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [ '3.7', '3.8', '3.9']
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11']
include:
- os: ubuntu-20.04
python-version: '2.7'
- os: ubuntu-20.04
python-version: '3.6'
name: Tests with Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install coverage
pip install nose
pip install nose-py3
pip install .
- name: Allow us to SSH passwordless to localhost
run: |
Expand Down Expand Up @@ -53,7 +51,7 @@ jobs:
- name: Post to Slack
if: always() # could be changed to failure() if too verbose
id: slack
uses: slackapi/slack-github-action@v1.15.0
uses: slackapi/slack-github-action@v1.23
with:
channel-id: 'C07GRMDK3'
slack-message: "${{ github.workflow }} by ${{ github.actor }} on ${{ github.ref }} for Python ${{ matrix.python-version }}: ${{ job.status }}"
Expand Down
26 changes: 13 additions & 13 deletions tests/CLIClushTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,10 @@ def run(self):
def test_027_warn_shell_globbing_nodes(self):
"""test clush warning on shell globbing (-w)"""
tdir = make_temp_dir()
tfile = open(os.path.join(tdir, HOSTNAME), "w")
tfile = open(os.path.join(tdir.name, HOSTNAME), "w")
curdir = os.getcwd()
try:
os.chdir(tdir)
os.chdir(tdir.name)
s = "Warning: using '-w %s' and local path '%s' exists, was it " \
"expanded by the shell?\n" % (HOSTNAME, HOSTNAME)
self._clush_t(["-w", HOSTNAME, "echo", "ok"], None,
Expand All @@ -415,15 +415,15 @@ def test_027_warn_shell_globbing_nodes(self):
os.chdir(curdir)
tfile.close()
os.unlink(tfile.name)
os.rmdir(tdir)
tdir.cleanup()

def test_028_warn_shell_globbing_exclude(self):
"""test clush warning on shell globbing (-x)"""
tdir = make_temp_dir()
tfile = open(os.path.join(tdir, HOSTNAME), "wb")
tfile = open(os.path.join(tdir.name, HOSTNAME), "wb")
curdir = os.getcwd()
try:
os.chdir(tdir)
os.chdir(tdir.name)
rxs = r"^Warning: using '-x %s' and local path " \
r"'%s' exists, was it expanded by the shell\?\n" \
% (HOSTNAME, HOSTNAME)
Expand All @@ -434,7 +434,7 @@ def test_028_warn_shell_globbing_exclude(self):
os.chdir(curdir)
tfile.close()
os.unlink(tfile.name)
os.rmdir(tdir)
tdir.cleanup()

def test_029_hostfile(self):
"""test clush --hostfile"""
Expand Down Expand Up @@ -629,18 +629,18 @@ def test_041_outdir_errdir(self):
"""test clush --outdir and --errdir"""
odir = make_temp_dir()
edir = make_temp_dir()
tofilepath = os.path.join(odir, HOSTNAME)
tefilepath = os.path.join(edir, HOSTNAME)
tofilepath = os.path.join(odir.name, HOSTNAME)
tefilepath = os.path.join(edir.name, HOSTNAME)
try:
self._clush_t(["-w", HOSTNAME, "--outdir", odir, "echo", "ok"],
self._clush_t(["-w", HOSTNAME, "--outdir", odir.name, "echo", "ok"],
None, self.output_ok)
self.assertTrue(os.path.isfile(tofilepath))
with open(tofilepath, "r") as f:
self.assertEqual(f.read(), "ok\n")
finally:
os.unlink(tofilepath)
try:
self._clush_t(["-w", HOSTNAME, "--errdir", edir, "echo", "ok", ">&2"],
self._clush_t(["-w", HOSTNAME, "--errdir", edir.name, "echo", "ok", ">&2"],
None, None, 0, self.output_ok)
self.assertTrue(os.path.isfile(tefilepath))
with open(tefilepath, "r") as f:
Expand All @@ -649,7 +649,7 @@ def test_041_outdir_errdir(self):
os.unlink(tefilepath)
try:
serr = "%s: err\n" % HOSTNAME
self._clush_t(["-w", HOSTNAME, "--outdir", odir, "--errdir", edir,
self._clush_t(["-w", HOSTNAME, "--outdir", odir.name, "--errdir", edir.name,
"echo", "ok", ";", "echo", "err", ">&2"], None,
self.output_ok, 0, serr.encode())
self.assertTrue(os.path.isfile(tofilepath))
Expand All @@ -661,8 +661,8 @@ def test_041_outdir_errdir(self):
finally:
os.unlink(tofilepath)
os.unlink(tefilepath)
os.rmdir(odir)
os.rmdir(edir)
odir.cleanup()
edir.cleanup()

def test_042_command_prefix(self):
"""test clush -O command_prefix"""
Expand Down
34 changes: 19 additions & 15 deletions tests/CLIConfigTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ def testClushConfigCustomGlobal(self):
custom_cfg_dir = make_temp_dir()

try:
os.environ['CLUSTERSHELL_CFGDIR'] = custom_cfg_dir
os.environ['CLUSTERSHELL_CFGDIR'] = custom_cfg_dir.name

cfgfile = open(os.path.join(custom_cfg_dir, 'clush.conf'), 'w')
cfgfile = open(os.path.join(custom_cfg_dir.name, 'clush.conf'), 'w')
cfgfile.write(dedent("""
[Main]
fanout: 42
Expand Down Expand Up @@ -368,7 +368,7 @@ def testClushConfigCustomGlobal(self):
os.environ['CLUSTERSHELL_CFGDIR'] = custom_config_save
else:
del os.environ['CLUSTERSHELL_CFGDIR']
shutil.rmtree(custom_cfg_dir, ignore_errors=True)
custom_cfg_dir.cleanup()


def testClushConfigUserOverride(self):
Expand All @@ -377,12 +377,12 @@ def testClushConfigUserOverride(self):
xdg_config_home_save = os.environ.get('XDG_CONFIG_HOME')

# Create fake XDG_CONFIG_HOME
dname = make_temp_dir()
tdir = make_temp_dir()
try:
os.environ['XDG_CONFIG_HOME'] = dname
os.environ['XDG_CONFIG_HOME'] = tdir.name

# create $XDG_CONFIG_HOME/clustershell/clush.conf
usercfgdir = os.path.join(dname, 'clustershell')
usercfgdir = os.path.join(tdir.name, 'clustershell')
os.mkdir(usercfgdir)
cfgfile = open(os.path.join(usercfgdir, 'clush.conf'), 'w')
cfgfile.write(dedent("""
Expand Down Expand Up @@ -420,12 +420,14 @@ def testClushConfigUserOverride(self):
os.environ['XDG_CONFIG_HOME'] = xdg_config_home_save
else:
del os.environ['XDG_CONFIG_HOME']
shutil.rmtree(dname, ignore_errors=True)
tdir.cleanup()

def testClushConfigConfDirModesEmpty(self):
"""test CLI.Config.ClushConfig (confdir with no modes)"""
dname1 = make_temp_dir()
dname2 = make_temp_dir()
tdir1 = make_temp_dir()
dname1 = tdir1.name
tdir2 = make_temp_dir()
dname2 = tdir2.name
f = make_temp_file(dedent("""
[Main]
fanout: 42
Expand Down Expand Up @@ -465,14 +467,16 @@ def testClushConfigConfDirModesEmpty(self):
self.assertRaises(ClushConfigError, config.set_mode, "sshpass")
finally:
f.close()
os.rmdir(dname2)
os.rmdir(dname1)
tdir2.cleanup()
tdir1.cleanup()


def testClushConfigConfDirModes(self):
"""test CLI.Config.ClushConfig (confdir and modes)"""
dname1 = make_temp_dir()
dname2 = make_temp_dir()
tdir1 = make_temp_dir()
dname1 = tdir1.name
tdir2 = make_temp_dir()
dname2 = tdir2.name
# Notes:
# - use dname1 two times to check dup checking code
# - use quotes on one of the directory path
Expand Down Expand Up @@ -594,5 +598,5 @@ def testClushConfigConfDirModes(self):
f2.close()
f1.close()
f.close()
os.rmdir(dname2)
os.rmdir(dname1)
tdir2.cleanup()
tdir1.cleanup()
12 changes: 6 additions & 6 deletions tests/CLINodesetTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,25 +797,25 @@ class CLINodesetGroupResolverConfigErrorTest(CLINodesetTestBase):
"""Unit test class for testing GroupResolverConfigError"""

def setUp(self):
self.dname = make_temp_dir()
self.tdir = make_temp_dir()
self.gconff = make_temp_file(dedent("""
[Main]
default: default
autodir: %s
""" % self.dname).encode('ascii'))
""" % self.tdir.name).encode('ascii'))
self.yamlf = make_temp_file(dedent("""
default:
compute: 'foo'
broken: i am not a dict
""").encode('ascii'), suffix=".yaml", dir=self.dname)
""").encode('ascii'), suffix=".yaml", dir=self.tdir.name)

set_std_group_resolver(GroupResolverConfig(self.gconff.name))

def tearDown(self):
set_std_group_resolver(None)
self.gconff = None
self.yamlf = None
os.rmdir(self.dname)
self.yamlf.close()
self.gconff.close()
self.tdir.cleanup()

def test_bad_yaml_config(self):
"""test nodeset with bad yaml config"""
Expand Down
8 changes: 4 additions & 4 deletions tests/DefaultsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,20 @@ def test_004_workerclass(self):
self.assertTrue(task.default("distant_worker") is WorkerSsh)
task_terminate()

dname = make_temp_dir()
modfile = open(os.path.join(dname, 'OutOfTree.py'), 'w')
tdir = make_temp_dir()
modfile = open(os.path.join(tdir.name, 'OutOfTree.py'), 'w')
modfile.write(dedent("""
class OutOfTreeWorker(object):
pass
WORKER_CLASS = OutOfTreeWorker"""))
modfile.flush()
modfile.close()
sys.path.append(dname)
sys.path.append(tdir.name)
self.defaults.distant_workername = 'OutOfTree'
task = task_self(self.defaults)
self.assertEqual(task.default("distant_worker").__name__, 'OutOfTreeWorker')
task_terminate()
shutil.rmtree(dname, ignore_errors=True)
tdir.cleanup()

def test_005_misc_value_errors(self):
"""test Defaults misc value errors"""
Expand Down
Loading