Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integration_tests: improve cloud-init.log assertions #593

Merged
merged 2 commits into from Oct 6, 2020

Conversation

OddBloke
Copy link
Collaborator

@OddBloke OddBloke commented Oct 1, 2020

Proposed Commit Message

integration_tests: improve cloud-init.log assertions

Test Steps

With #592 also in tree, CLOUD_INIT_OS_IMAGE=ubuntu:09768724e1c1 pytest -s tests/integration_tests/bugs will demonstrate the assertion output this modifies. Before this change:

>       assert "WARNING" not in log_content
E       AssertionError: assert 'WARNING' not in '2020-10-01 ...atasources\n'
E         'WARNING' is contained here:
E           2020-10-01 20:49:47,402 - util.py[DEBUG]: Cloud-init v. 20.1-10-g71af48df-0ubuntu5 running 'init-local' at Thu, 01 Oct 2020 20:49:47 +0000. Up 2.06 seconds.
E           2020-10-01 20:49:47,402 - main.py[DEBUG]: No kernel command line url found.
E           2020-10-01 20:49:47,402 - main.py[DEBUG]: Closing stdin.
E           2020-10-01 20:49:47,407 - util.py[DEBUG]: Writing to /var/log/cloud-init.log - ab: [644] 0 bytes
E           2020-10-01 20:49:47,408 - util.py[DEBUG]: Changing the ownership of /var/log/cloud-init.log to 104:4
E           2020-10-01 20:49:47,409 - util.py[DEBUG]: Attempting to remove /var/lib/...
E         
E         ...Full output truncated (439 lines hidden), use '-vv' to show

tests/integration_tests/bugs/test_lp1886531.py:27: AssertionError

whereas after this change:

E       assert "WARNING" not in cloud-init.log string; unexpectedly found on these lines:
E         2020-10-01 20:48:59,040 - util.py[WARNING]: Running module mounts (<module 'cloudinit.config.cc_mounts' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_mounts.py'>) failed

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

Copy link
Member

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

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

Woah...didn't even know this is something you could override. Nice!

@OddBloke
Copy link
Collaborator Author

OddBloke commented Oct 2, 2020

Woah...didn't even know this is something you could override. Nice!

Yeah, I knew you could do waves hands custom assertions in pytest, but this is the first time I've actually looked into it at all. It's very neat!

Copy link
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.

that is so helpful. We could use the same in ua-client tests. Thanks for this!

@blackboxsw blackboxsw merged commit efa4d5b into canonical:master Oct 6, 2020
This was referenced May 12, 2023
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.

None yet

3 participants