Skip to content

Commit

Permalink
Use 127.0.0.1 instead of localhost in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
armab committed Feb 9, 2016
1 parent d8bf920 commit 733b960
Show file tree
Hide file tree
Showing 33 changed files with 103 additions and 103 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ compile:
@echo "----- Dropping all Mistral MYSQL databases -----"
@mysql -uroot -pStackStorm -e "DROP DATABASE IF EXISTS mistral"
@mysql -uroot -pStackStorm -e "CREATE DATABASE mistral"
@mysql -uroot -pStackStorm -e "GRANT ALL PRIVILEGES ON mistral.* TO 'mistral'@'localhost' IDENTIFIED BY 'StackStorm'"
@mysql -uroot -pStackStorm -e "GRANT ALL PRIVILEGES ON mistral.* TO 'mistral'@'127.0.0.1' IDENTIFIED BY 'StackStorm'"
@mysql -uroot -pStackStorm -e "FLUSH PRIVILEGES"
@/opt/openstack/mistral/.venv/bin/python /opt/openstack/mistral/tools/sync_db.py --config-file /etc/mistral/mistral.conf

Expand Down Expand Up @@ -294,15 +294,15 @@ mistral-itests: requirements .mistral-itests
.mistral-itests:
@echo
@echo "==================== MISTRAL integration tests ===================="
@echo "The tests assume both st2 and mistral are running on localhost."
@echo "The tests assume both st2 and mistral are running on 127.0.0.1."
@echo
. $(VIRTUALENV_DIR)/bin/activate; nosetests -s -v st2tests/integration/mistral || exit 1;

.PHONY: .mistral-itests-coverage-html
.mistral-itests-coverage-html:
@echo
@echo "==================== MISTRAL integration tests with coverage (HTML reports) ===================="
@echo "The tests assume both st2 and mistral are running on localhost."
@echo "The tests assume both st2 and mistral are running on 127.0.0.1."
@echo
. $(VIRTUALENV_DIR)/bin/activate; nosetests -s -v --with-coverage \
--cover-inclusive --cover-html st2tests/integration/mistral || exit 1;
Expand Down
4 changes: 2 additions & 2 deletions conf/st2.dev.conf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ action_executions_ttl = 30
trigger_instances_ttl = 30

[syslog]
host = localhost
host = 127.0.0.1
port = 514
facility = local7
protocol = udp
Expand All @@ -61,7 +61,7 @@ user = stanley
ssh_key_file = /home/vagrant/.ssh/stanley_rsa

[messaging]
url = amqp://guest:guest@localhost:5672/
url = amqp://guest:guest@127.0.0.1:5672/

[ssh_runner]
remote_dir = /tmp
Expand Down
4 changes: 2 additions & 2 deletions conf/st2.tests.conf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ system_packs_base_path =
packs_base_paths = st2tests/st2tests/fixtures/

[syslog]
host = localhost
host = 127.0.0.1
port = 514
facility = local7
protocol = udp
Expand All @@ -70,7 +70,7 @@ user = stanley
ssh_key_file = /home/vagrant/.ssh/stanley_rsa

[messaging]
url = amqp://guest:guest@localhost:5672/
url = amqp://guest:guest@127.0.0.1:5672/

[ssh_runner]
remote_dir = /tmp
Expand Down
4 changes: 2 additions & 2 deletions conf/st2.tests1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ system_packs_base_path =
packs_base_paths = st2tests/st2tests/fixtures/packs_1/

[syslog]
host = localhost
host = 127.0.0.1
port = 514
facility = local7
protocol = udp
Expand All @@ -59,7 +59,7 @@ user = stanley
ssh_key_file = /home/vagrant/.ssh/stanley_rsa

[messaging]
url = amqp://guest:guest@localhost:5672/
url = amqp://guest:guest@127.0.0.1:5672/

[ssh_runner]
remote_dir = /tmp
Expand Down
6 changes: 3 additions & 3 deletions conf/st2rc.sample.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Configuration file for the StackStorm CLI
[general]
base_url = http://localhost
base_url = http://127.0.0.1
api_version = v1
# Path to the CA cert bundle used to validate the SSL certificates
cacert =
Expand All @@ -18,7 +18,7 @@ username = test1
password = testpassword

[api]
url = http://localhost:9101/v1
url = http://127.0.0.1:9101/v1

[auth]
url = http://localhost:9100/
url = http://127.0.0.1:9100/
2 changes: 1 addition & 1 deletion scripts/travis/setup-mistral.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fi
touch $config
cat <<mistral_config >$config
[database]
connection=postgresql://mistral:StackStorm@localhost/mistral
connection=postgresql://mistral:StackStorm@127.0.0.1/mistral
max_pool_size=50
[pecan]
Expand Down
6 changes: 3 additions & 3 deletions st2actions/tests/unit/test_http_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setUpClass(cls):

@mock.patch('st2actions.runners.httprunner.requests')
def test_parse_response_body(self, mock_requests):
client = HTTPClient(url='http://localhost')
client = HTTPClient(url='http://127.0.0.1')
mock_result = MockResult()

# Unknown content type, body should be returned raw
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_parse_response_body(self, mock_requests):

@mock.patch('st2actions.runners.httprunner.requests')
def test_https_verify(self, mock_requests):
url = 'https://localhost:8888'
url = 'https://127.0.0.1:8888'
client = HTTPClient(url=url, verify=True)
mock_result = MockResult()

Expand All @@ -108,7 +108,7 @@ def test_https_verify(self, mock_requests):

@mock.patch('st2actions.runners.httprunner.requests')
def test_https_verify_false(self, mock_requests):
url = 'https://localhost:8888'
url = 'https://127.0.0.1:8888'
client = HTTPClient(url=url)
mock_result = MockResult()

Expand Down
6 changes: 3 additions & 3 deletions st2actions/tests/unit/test_mistral_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class MistralUtilityTest(unittest2.TestCase):
def test_get_action_execution_id_from_url(self):
self.assertEqual(
'12345',
get_action_execution_id_from_url('http://localhost:8989/v2/action_executions/12345'))
get_action_execution_id_from_url('http://127.0.0.1:8989/v2/action_executions/12345'))

self.assertRaises(
ValueError,
get_action_execution_id_from_url,
'http://localhost:8989/v2/action_executions')
'http://127.0.0.1:8989/v2/action_executions')

self.assertRaises(
ValueError,
Expand All @@ -43,4 +43,4 @@ def test_get_action_execution_id_from_url(self):
self.assertRaises(
ValueError,
get_action_execution_id_from_url,
'http://localhost:8989/v2/workflows/abcde')
'http://127.0.0.1:8989/v2/workflows/abcde')
20 changes: 10 additions & 10 deletions st2actions/tests/unit/test_mistral_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,39 +607,39 @@ def test_callback_handler_status_map(self):
action_executions.ActionExecutionManager, 'update',
mock.MagicMock(return_value=None))
def test_callback_handler_with_result_as_text(self):
MistralCallbackHandler.callback('http://localhost:8989/v2/action_executions/12345', {},
MistralCallbackHandler.callback('http://127.0.0.1:8989/v2/action_executions/12345', {},
action_constants.LIVEACTION_STATUS_SUCCEEDED,
'<html></html>')

@mock.patch.object(
action_executions.ActionExecutionManager, 'update',
mock.MagicMock(return_value=None))
def test_callback_handler_with_result_as_dict(self):
MistralCallbackHandler.callback('http://localhost:8989/v2/action_executions/12345', {},
MistralCallbackHandler.callback('http://127.0.0.1:8989/v2/action_executions/12345', {},
action_constants.LIVEACTION_STATUS_SUCCEEDED, {'a': 1})

@mock.patch.object(
action_executions.ActionExecutionManager, 'update',
mock.MagicMock(return_value=None))
def test_callback_handler_with_result_as_json_str(self):
MistralCallbackHandler.callback('http://localhost:8989/v2/action_executions/12345', {},
MistralCallbackHandler.callback('http://127.0.0.1:8989/v2/action_executions/12345', {},
action_constants.LIVEACTION_STATUS_SUCCEEDED, '{"a": 1}')
MistralCallbackHandler.callback('http://localhost:8989/v2/action_executions/12345', {},
MistralCallbackHandler.callback('http://127.0.0.1:8989/v2/action_executions/12345', {},
action_constants.LIVEACTION_STATUS_SUCCEEDED, "{'a': 1}")

@mock.patch.object(
action_executions.ActionExecutionManager, 'update',
mock.MagicMock(return_value=None))
def test_callback_handler_with_result_as_list(self):
MistralCallbackHandler.callback('http://localhost:8989/v2/action_executions/12345', {},
MistralCallbackHandler.callback('http://127.0.0.1:8989/v2/action_executions/12345', {},
action_constants.LIVEACTION_STATUS_SUCCEEDED,
["a", "b", "c"])

@mock.patch.object(
action_executions.ActionExecutionManager, 'update',
mock.MagicMock(return_value=None))
def test_callback_handler_with_result_as_list_str(self):
MistralCallbackHandler.callback('http://localhost:8989/v2/action_executions/12345', {},
MistralCallbackHandler.callback('http://127.0.0.1:8989/v2/action_executions/12345', {},
action_constants.LIVEACTION_STATUS_SUCCEEDED,
'["a", "b", "c"]')

Expand All @@ -651,7 +651,7 @@ def test_callback(self):
action='core.local', parameters={'cmd': 'uname -a'},
callback={
'source': 'mistral',
'url': 'http://localhost:8989/v2/action_executions/12345'
'url': 'http://127.0.0.1:8989/v2/action_executions/12345'
}
)

Expand All @@ -676,7 +676,7 @@ def test_callback_incomplete_state(self):
action='core.local', parameters={'cmd': 'uname -a'},
callback={
'source': 'mistral',
'url': 'http://localhost:8989/v2/action_executions/12345'
'url': 'http://127.0.0.1:8989/v2/action_executions/12345'
}
)

Expand All @@ -699,7 +699,7 @@ def test_callback_retry(self):
action='core.local', parameters={'cmd': 'uname -a'},
callback={
'source': 'mistral',
'url': 'http://localhost:8989/v2/action_executions/12345'
'url': 'http://127.0.0.1:8989/v2/action_executions/12345'
}
)

Expand Down Expand Up @@ -727,7 +727,7 @@ def test_callback_retry_exhausted(self):
action='core.local', parameters={'cmd': 'uname -a'},
callback={
'source': 'mistral',
'url': 'http://localhost:8989/v2/action_executions/12345'
'url': 'http://127.0.0.1:8989/v2/action_executions/12345'
}
)

Expand Down
2 changes: 1 addition & 1 deletion st2actions/tests/unit/test_mistral_v2_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def test_launch_workflow_with_mistral_auth(self):
cfg.CONF.set_default('keystone_username', 'foo', group='mistral')
cfg.CONF.set_default('keystone_password', 'bar', group='mistral')
cfg.CONF.set_default('keystone_project_name', 'admin', group='mistral')
cfg.CONF.set_default('keystone_auth_url', 'http://localhost:5000/v3', group='mistral')
cfg.CONF.set_default('keystone_auth_url', 'http://127.0.0.1:5000/v3', group='mistral')

MistralRunner.entry_point = mock.PropertyMock(return_value=WF1_YAML_FILE_PATH)
liveaction = LiveActionDB(action=WF1_NAME, parameters=ACTION_PARAMS)
Expand Down
6 changes: 3 additions & 3 deletions st2actions/tests/unit/test_parallel_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ def test_host_port_info(self):
return_value=(json.dumps({'foo': 'bar'}), '', 0))
)
def test_run_command_json_output_transformed_to_object(self):
hosts = ['localhost']
hosts = ['127.0.0.1']
client = ParallelSSHClient(hosts=hosts,
user='ubuntu',
pkey_file='~/.ssh/id_rsa',
connect=True)
results = client.run('stuff', timeout=60)
self.assertTrue('localhost' in results)
self.assertDictEqual(results['localhost']['stdout'], {'foo': 'bar'})
self.assertTrue('127.0.0.1' in results)
self.assertDictEqual(results['127.0.0.1']['stdout'], {'foo': 'bar'})
10 changes: 5 additions & 5 deletions st2actions/tests/unit/test_paramiko_remote_script_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ def test_cwd_used_correctly(self):
named_args={}, positional_args=['blank space'], env_vars={},
on_behalf_user='svetlana', user='stanley',
private_key='---SOME RSA KEY---',
remote_dir='/tmp', hosts=['localhost'], cwd='/test/cwd/'
remote_dir='/tmp', hosts=['127.0.0.1'], cwd='/test/cwd/'
)
paramiko_runner = ParamikoRemoteScriptRunner('runner_1')
paramiko_runner._parallel_ssh_client = ParallelSSHClient(['localhost'], 'stanley')
paramiko_runner._parallel_ssh_client = ParallelSSHClient(['127.0.0.1'], 'stanley')
paramiko_runner._run_script_on_remote_host(remote_action)
exp_cmd = "cd /test/cwd/ && /tmp/shiz_storm.py 'blank space'"
ParallelSSHClient.run.assert_called_with(exp_cmd,
Expand All @@ -73,15 +73,15 @@ def test_cwd_used_correctly(self):
def test_username_only_ssh(self):
paramiko_runner = ParamikoRemoteScriptRunner('runner_1')

paramiko_runner.runner_parameters = {'username': 'test_user', 'hosts': 'localhost'}
paramiko_runner.runner_parameters = {'username': 'test_user', 'hosts': '127.0.0.1'}
self.assertRaises(InvalidCredentialsException, paramiko_runner.pre_run)

def test_username_invalid_private_key(self):
paramiko_runner = ParamikoRemoteScriptRunner('runner_1')

paramiko_runner.runner_parameters = {
'username': 'test_user',
'hosts': 'localhost',
'hosts': '127.0.0.1',
'private_key': 'invalid private key',
}
paramiko_runner.context = {}
Expand All @@ -97,7 +97,7 @@ def test_top_level_error_is_correctly_reported(self):

paramiko_runner.runner_parameters = {
'username': 'test_user',
'hosts': 'localhost'
'hosts': '127.0.0.1'
}
paramiko_runner.action = ACTION_1
paramiko_runner.liveaction_id = 'foo'
Expand Down
6 changes: 3 additions & 3 deletions st2api/tests/unit/controllers/v1/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_defaults(self):
response = self.app.get('/')
self.assertEqual(response.status_int, 200)
self.assertEqual(response.headers['Access-Control-Allow-Origin'],
'http://localhost')
'http://127.0.0.1:3000')
self.assertEqual(response.headers['Access-Control-Allow-Methods'],
'GET,POST,PUT,DELETE,OPTIONS')
self.assertEqual(response.headers['Access-Control-Allow-Headers'],
Expand All @@ -32,11 +32,11 @@ def test_defaults(self):

def test_origin(self):
response = self.app.get('/', headers={
'origin': 'http://localhost:3000'
'origin': 'http://127.0.0.1:3000'
})
self.assertEqual(response.status_int, 200)
self.assertEqual(response.headers['Access-Control-Allow-Origin'],
'http://localhost:3000')
'http://127.0.0.1:3000')

def test_additional_origin(self):
response = self.app.get('/', headers={
Expand Down
4 changes: 2 additions & 2 deletions st2api/tests/unit/controllers/v1/test_executions_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,13 @@ def test_post_parameter_validation_failed(self):
self.assertEqual(post_resp.json['faultstring'], "'hosts' is a required property")

# Runner type expects parameters "cmd" to be str.
execution['parameters'] = {"hosts": "localhost", "cmd": 1000}
execution['parameters'] = {"hosts": "127.0.0.1", "cmd": 1000}
post_resp = self._do_post(execution, expect_errors=True)
self.assertEqual(post_resp.status_int, 400)
self.assertEqual(post_resp.json['faultstring'], "1000 is not of type 'string', 'null'")

# Runner type expects parameters "cmd" to be str.
execution['parameters'] = {"hosts": "localhost", "cmd": "1000", "c": 1}
execution['parameters'] = {"hosts": "127.0.0.1", "cmd": "1000", "c": 1}
post_resp = self._do_post(execution, expect_errors=True)
self.assertEqual(post_resp.status_int, 400)

Expand Down
6 changes: 3 additions & 3 deletions st2api/tests/unit/controllers/v1/test_kvps.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

KVP = {
'name': 'keystone_endpoint',
'value': 'http://localhost:5000/v3'
'value': 'http://127.0.0.1:5000/v3'
}

KVP_2 = {
Expand All @@ -27,7 +27,7 @@

KVP_WITH_TTL = {
'name': 'keystone_endpoint',
'value': 'http://localhost:5000/v3',
'value': 'http://127.0.0.1:5000/v3',
'ttl': 10
}

Expand Down Expand Up @@ -74,7 +74,7 @@ def test_get_one_fail(self):
def test_put(self):
put_resp = self.__do_put('key1', KVP)
update_input = put_resp.json
update_input['value'] = 'http://localhost:35357/v3'
update_input['value'] = 'http://127.0.0.1:35357/v3'
put_resp = self.__do_put(self.__get_kvp_id(put_resp), update_input)
self.assertEqual(put_resp.status_int, 200)
self.__do_delete(self.__get_kvp_id(put_resp))
Expand Down
2 changes: 1 addition & 1 deletion st2client/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

LOG = logging.getLogger(__name__)

FAKE_ENDPOINT = 'http://localhost:8268'
FAKE_ENDPOINT = 'http://127.0.0.1:8268'

RESOURCES = [
{
Expand Down
6 changes: 3 additions & 3 deletions st2client/tests/fixtures/st2rc.full.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[general]
base_url = http://localhost
base_url = http://127.0.0.1
api_version = v1
cacert = cacartpath

Expand All @@ -12,7 +12,7 @@ username = test1
password = test1

[api]
url = http://localhost:9101/v1
url = http://127.0.0.1:9101/v1

[auth]
url = http://localhost:9100/
url = http://127.0.0.1:9100/
Loading

0 comments on commit 733b960

Please sign in to comment.