Skip to content

integration_tests: introduce lxd_use_exec mark#802

Merged
OddBloke merged 2 commits into
canonical:masterfrom
OddBloke:tests
Feb 22, 2021
Merged

integration_tests: introduce lxd_use_exec mark#802
OddBloke merged 2 commits into
canonical:masterfrom
OddBloke:tests

Conversation

@OddBloke
Copy link
Copy Markdown
Collaborator

@OddBloke OddBloke commented Feb 5, 2021

Proposed Commit Message

integration_tests: introduce lxd_use_exec mark

pycloudlib has modified the way LXD executes tests
(https://github.com/canonical/pycloudlib/pull/114): it will always use
SSH to access them by default, instead of using `lxc exec`.  This
behaviour is transparent for the majority of cloud-init's integration
tests, but some currently depend on using `lxc exec` to access instances
with (intentionally) broken networking: obviously these are not
accessible via SSH.

pycloudlib retains support for switching an instance to use `lxc exec`.
This commit introduces the `lxd_use_exec` mark, which tests can use to
indicate to the integration testing framework that they should be so
switched, and applies it to all applicable tests.

Additional Context

See canonical/pycloudlib#114

Test Steps

CI tests will indicate that LXD containers work, a manual run is required for LXD VMs.

Checklist:

  • My code follows the process laid out in the documentation
  • I have updated or added any unit tests accordingly
  • I have updated or added any documentation accordingly

pycloudlib has modified the way LXD executes tests
(canonical/pycloudlib#114): it will always use
SSH to access them by default, instead of using `lxc exec`.  This
behaviour is transparent for them majority of cloud-init's integration
tests, but some currently depend on using `lxc exec` to access instances
with (intentionally) broken networking: obviously these are not
accessible via SSH.

pycloudlib retains support for switching an instance to use `lxc exec`.
This commit introduces the `lxd_use_exec` mark, which tests can use to
indicate to the integration testing framework that they should be so
switched, and applies it to all applicable tests.
@OddBloke OddBloke changed the title WIP: integration_tests: introduce lxd_use_exec mark integration_tests: introduce lxd_use_exec mark Feb 18, 2021
@OddBloke OddBloke marked this pull request as ready for review February 18, 2021 17:52
Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As written this assumes the a test will always interact using lxc exec instead of ssh. Do you see any use-cases that we want to plan for where we really only want lxc exec for some commands and ssh for others?

@OddBloke
Copy link
Copy Markdown
Collaborator Author

Do you see any use-cases that we want to plan for where we really only want lxc exec for some commands and ssh for others?

None immediately present themselves to me. Such cases can be handled today, something like:

@pytest.mark.lxc_use_exec
def test_example(client):
    client.execute("unbreak-ssh-access-somehow")
    client.instance.execute_via_ssh = True
    client.execute("echo ssh works")

If we see more than one or two such cases, we should look at improving the API.

Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks LGTM

@OddBloke OddBloke merged commit 38aee6e into canonical:master Feb 22, 2021
@OddBloke OddBloke deleted the tests branch February 22, 2021 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants