Skip to content

Commit

Permalink
only run a subset of integration tests in CI (#672)
Browse files Browse the repository at this point in the history
This introduces the "ci" mark, used to indicate a test which should run
as part of our CI integration testing run and the integration-tests-ci
tox environment, which runs only those tests. Travis has been adjusted
to use this tox environment.

(All current module tests have been marked with the "ci" mark, but the
one bug test that we have has not.)
  • Loading branch information
OddBloke committed Nov 18, 2020
1 parent f680114 commit cd752df
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ matrix:
fi
# Use sudo to get a new shell where we're in the sbuild group
- sudo -E su $USER -c 'sbuild --nolog --no-run-lintian --verbose --dist=xenial cloud-init_*.dsc'
- sg lxd -c 'CLOUD_INIT_IMAGE_SOURCE="$(ls *.deb)" tox -e integration-tests' &
- sg lxd -c 'CLOUD_INIT_IMAGE_SOURCE="$(ls *.deb)" tox -e integration-tests-ci' &
- |
SECONDS=0
while [ -e /proc/$! ]; do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
]


@pytest.mark.ci
class TestAptConfigureSourcesList:

@pytest.mark.user_data(USER_DATA)
Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/modules/test_ntp_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
EXPECTED_SERVERS = yaml.safe_load(USER_DATA)["ntp"]["servers"]


@pytest.mark.ci
@pytest.mark.user_data(USER_DATA)
class TestNtpServers:

Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/modules/test_runcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"""


@pytest.mark.ci
class TestRuncmd:

@pytest.mark.user_data(USER_DATA)
Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/modules/test_seed_random_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""


@pytest.mark.ci
class TestSeedRandomData:

@pytest.mark.user_data(USER_DATA)
Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/modules/test_set_hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"""


@pytest.mark.ci
class TestHostname:

@pytest.mark.user_data(USER_DATA_HOSTNAME)
Expand Down
2 changes: 2 additions & 0 deletions tests/integration_tests/modules/test_set_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,13 @@ def test_sshd_config(self, class_client):
assert "PasswordAuthentication yes" in sshd_config.splitlines()


@pytest.mark.ci
@pytest.mark.user_data(LIST_USER_DATA)
class TestPasswordList(Mixin):
"""Launch an instance with LIST_USER_DATA, ensure Mixin tests pass."""


@pytest.mark.ci
@pytest.mark.user_data(STRING_USER_DATA)
class TestPasswordListString(Mixin):
"""Launch an instance with STRING_USER_DATA, ensure Mixin tests pass."""
1 change: 1 addition & 0 deletions tests/integration_tests/modules/test_snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""


@pytest.mark.ci
class TestSnap:

@pytest.mark.user_data(USER_DATA)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
""" # noqa


@pytest.mark.ci
class TestSshAuthkeyFingerprints:

@pytest.mark.user_data(USER_DATA_SSH_AUTHKEY_DISABLE)
Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/modules/test_ssh_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"""


@pytest.mark.ci
@pytest.mark.user_data(USER_DATA)
class TestSshKeysGenerate:

Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/modules/test_ssh_import_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""


@pytest.mark.ci
class TestSshImportId:

@pytest.mark.user_data(USER_DATA)
Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/modules/test_ssh_keys_provided.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
""" # noqa


@pytest.mark.ci
@pytest.mark.user_data(USER_DATA)
class TestSshKeysProvided:

Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/modules/test_timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""


@pytest.mark.ci
class TestTimezone:

@pytest.mark.user_data(USER_DATA)
Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/modules/test_users_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"""


@pytest.mark.ci
@pytest.mark.user_data(USER_DATA)
class TestUsersGroups:
@pytest.mark.parametrize(
Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/modules/test_write_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
""".format(B64_CONTENT.decode("ascii"))


@pytest.mark.ci
@pytest.mark.user_data(USER_DATA)
class TestWriteFiles:

Expand Down
8 changes: 8 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,21 @@ passenv = CLOUD_INIT_*
deps =
-r{toxinidir}/integration-requirements.txt

[testenv:integration-tests-ci]
commands = {[testenv:integration-tests]commands}
passenv = {[testenv:integration-tests]passenv}
deps = {[testenv:integration-tests]deps}
setenv =
PYTEST_ADDOPTS="-k ci"

[pytest]
# TODO: s/--strict/--strict-markers/ once xenial support is dropped
testpaths = cloudinit tests/unittests
addopts = --strict
markers =
allow_subp_for: allow subp usage for the given commands (disable_subp_usage)
allow_all_subp: allow all subp usage (disable_subp_usage)
ci: run this integration test as part of CI test runs
ds_sys_cfg: a sys_cfg dict to be used by datasource fixtures
ec2: test will only run on EC2 platform
gce: test will only run on GCE platform
Expand Down

0 comments on commit cd752df

Please sign in to comment.