From e200bcbaab789de693fa06c7615671035a7f8ac6 Mon Sep 17 00:00:00 2001 From: Michael Basnight Date: Tue, 15 Jan 2013 14:52:27 -0600 Subject: [PATCH] Adding flags to ssh cmd to bypass host checking * Moved the ssh command to a central spot fixes bug 1100001 Change-Id: Ic055fe065a5d6ca8023bd15c4ef2a17e25970e50 --- reddwarf/tests/__init__.py | 1 + reddwarf/tests/api/instances_actions.py | 10 ++++++---- reddwarf/tests/util/__init__.py | 5 +++-- reddwarf/tests/util/mysql.py | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/reddwarf/tests/__init__.py b/reddwarf/tests/__init__.py index 50274c26ee..57a16a2a6b 100644 --- a/reddwarf/tests/__init__.py +++ b/reddwarf/tests/__init__.py @@ -2,3 +2,4 @@ DBAAS_API = "dbaas.api" PRE_INSTANCES = "dbaas.api.pre_instances" INSTANCES = "dbaas.api.instances" POST_INSTANCES = "dbaas.api.post_instances" +SSH_CMD = 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' diff --git a/reddwarf/tests/api/instances_actions.py b/reddwarf/tests/api/instances_actions.py index 47227c59f5..546b51255a 100644 --- a/reddwarf/tests/api/instances_actions.py +++ b/reddwarf/tests/api/instances_actions.py @@ -216,18 +216,20 @@ class RebootTestBase(ActionTestBase): def mess_up_mysql(self): """Ruin MySQL's ability to restart.""" self.fix_mysql() # kill files - cmd = """ssh %s 'sudo cp /dev/null /var/lib/mysql/ib_logfile%d'""" + cmd = """%s %s 'sudo cp /dev/null /var/lib/mysql/ib_logfile%d'""" for index in range(2): - full_cmd = cmd % (self.instance_address, index) + full_cmd = cmd % (tests.SSH_CMD, self.instance_address, index) print("RUNNING COMMAND: %s" % full_cmd) util.process(full_cmd) def fix_mysql(self): """Fix MySQL's ability to restart.""" if not FAKE_MODE: - cmd = "ssh %s 'sudo rm /var/lib/mysql/ib_logfile%d'" + cmd = "%s %s 'sudo rm /var/lib/mysql/ib_logfile%d'" for index in range(2): - util.process(cmd % (self.instance_address, index)) + util.process(cmd % (tests.SSH_CMD, + self.instance_address, + index)) def wait_for_failure_status(self): """Wait until status becomes running.""" diff --git a/reddwarf/tests/util/__init__.py b/reddwarf/tests/util/__init__.py index 394d69b5e6..6da8dda2f3 100644 --- a/reddwarf/tests/util/__init__.py +++ b/reddwarf/tests/util/__init__.py @@ -55,6 +55,7 @@ from proboscis.asserts import ASSERTION_ERROR from proboscis import SkipTest from reddwarfclient import Dbaas from reddwarfclient.client import ReddwarfHTTPClient +from reddwarf import tests from reddwarf.tests.util import test_config as CONFIG from reddwarf.tests.util.client import TestClient as TestClient from reddwarf.tests.util.users import Requirements @@ -232,8 +233,8 @@ def mysql_connection(): def find_mysql_procid_on_instance(ip_address): """Returns the process id of MySql on an instance if running, or None.""" - cmd = "ssh %s ps aux | grep /usr/sbin/mysqld " \ - "| awk '{print $2}'" % ip_address + cmd = "%s %s ps aux | grep /usr/sbin/mysqld " \ + "| awk '{print $2}'" % (tests.SSH_CMD, ip_address) stdout, stderr = process(cmd) try: return int(stdout) diff --git a/reddwarf/tests/util/mysql.py b/reddwarf/tests/util/mysql.py index 2a304cfe33..b6d6333912 100644 --- a/reddwarf/tests/util/mysql.py +++ b/reddwarf/tests/util/mysql.py @@ -1,6 +1,7 @@ import pexpect import re from sqlalchemy import create_engine +from reddwarf import tests from reddwarf.tests.config import CONFIG from sqlalchemy.exc import OperationalError try: @@ -105,7 +106,7 @@ class PexpectMySqlConnection(object): self.host = host self.user = user self.password = password - cmd = 'ssh %s' % ssh_args + cmd = '%s %s' % (tests.SSH_CMD, ssh_args) self.proc = pexpect.spawn(cmd) print(cmd) self.proc.expect(":~\$", timeout=self.TIME_OUT)