-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ActionTest.test_mix_errors_timeout: Fix timeout test
ActionTest.test_mix_errors_timeout may fail depending on the local sshd version. The magic trick to trigger a sleep was a bit weak... To avoid this uncontroled behaviour, we add a temporary ssh configuration to trigger the timeout. We add globally this ssh configuration to be independent regarding the user configuration. Change-Id: I394e2087a58345b151d9ceb5eda5e7d7f517057e
- Loading branch information
Showing
4 changed files
with
75 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright CEA (2011-2019) | ||
# Contributor: CEDEYN Aurelien | ||
# | ||
""" | ||
Define common function for MilkCheck tests | ||
""" | ||
|
||
import tempfile | ||
import textwrap | ||
from ClusterShell.Task import task_self | ||
|
||
def setup_sshconfig(): | ||
""" Generate a custom ssh configuration for tests """ | ||
ssh_cfg = tempfile.NamedTemporaryFile() | ||
# Create a ssh_config file to manage timeout | ||
# Get first default configuration | ||
with (open('/etc/ssh/ssh_config', 'r')) as dflt_ssh_cfg: | ||
ssh_cfg.write(dflt_ssh_cfg.read()) | ||
dflt_ssh_cfg.close() | ||
# Add custom configuration | ||
ssh_cfg.write(textwrap.dedent(""" | ||
Host * | ||
UserKnownHostsFile /dev/null | ||
StrictHostKeyChecking no | ||
CheckHostIP no | ||
LogLevel ERROR | ||
Host timeout | ||
proxycommand sleep 3 | ||
""")) | ||
ssh_cfg.flush() | ||
task = task_self() | ||
task.set_info('ssh_options', '-F {0}'.format(ssh_cfg.name)) | ||
return ssh_cfg | ||
|
||
|
||
def cleanup_sshconfig(ssh_cfg): | ||
""" Remove ssh configuration file and restore task options """ | ||
ssh_cfg.close() | ||
task = task_self() | ||
task.set_info('ssh_options', '') |