Skip to content

Commit 11b7e65

Browse files
committed
skip tests that require passwordless sudo for local development
Only run them when ST2_CI==true to minimize requirements for local development. Also fix a typo in a comment.
1 parent 40cb317 commit 11b7e65

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

contrib/runners/local_runner/tests/integration/test_localrunner.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from __future__ import absolute_import
1717
import os
18+
import unittest
1819
import uuid
1920

2021
import mock
@@ -45,6 +46,8 @@
4546

4647
__all__ = ["LocalShellCommandRunnerTestCase", "LocalShellScriptRunnerTestCase"]
4748

49+
ST2_CI = os.environ.get("ST2_CI", "false").lower() == "true"
50+
4851
MOCK_EXECUTION = mock.Mock()
4952
MOCK_EXECUTION.id = "598dbf0c0640fd54bffc688b"
5053

@@ -141,8 +144,13 @@ def test_common_st2_env_vars_are_available_to_the_action(self):
141144
self.assertEqual(status, action_constants.LIVEACTION_STATUS_SUCCEEDED)
142145
self.assertEqual(result["stdout"].strip(), "mock-token")
143146

147+
# This test depends on passwordless sudo. Don't require that for local development.
148+
@unittest.skipIf(
149+
not ST2_CI,
150+
'Skipping tests because ST2_CI environment variable is not set to "true"',
151+
)
144152
def test_sudo_and_env_variable_preservation(self):
145-
# Verify that the environment environment are correctly preserved when running as a
153+
# Verify that the environment vars are correctly preserved when running as a
146154
# root / non-system user
147155
# Note: This test will fail if SETENV option is not present in the sudoers file
148156
models = self.fixtures_loader.load_models(
@@ -297,6 +305,11 @@ def test_action_stdout_and_stderr_is_stored_in_the_db_short_running_action(
297305
self.assertEqual(output_dbs[db_index_1].data, mock_stderr[0])
298306
self.assertEqual(output_dbs[db_index_2].data, mock_stderr[1])
299307

308+
# This test depends on passwordless sudo. Don't require that for local development.
309+
@unittest.skipIf(
310+
not ST2_CI,
311+
'Skipping tests because ST2_CI environment variable is not set to "true"',
312+
)
300313
def test_shell_command_sudo_password_is_passed_to_sudo_binary(self):
301314
# Verify that sudo password is correctly passed to sudo binary via stdin
302315
models = self.fixtures_loader.load_models(

0 commit comments

Comments
 (0)