Skip to content

tests: do not assert instance.pull_file().ok()#1246

Merged
TheRealFalcon merged 1 commit into
canonical:mainfrom
blackboxsw:tests-no-pull-file-ok
Feb 7, 2022
Merged

tests: do not assert instance.pull_file().ok()#1246
TheRealFalcon merged 1 commit into
canonical:mainfrom
blackboxsw:tests-no-pull-file-ok

Conversation

@blackboxsw
Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw commented Feb 4, 2022

Test pycloudlib's BaseInstance.pull_file doesn't return a Result
object. So we can't call ok() on the None response in integration tests.

When an integration test failes, this error results in _collect_logs incorrectly reporting that a pull_file has failed
leaving an uncompressed tarfile which was correctly downloaded.

Leave the try/except handling as pull_file will raise an
IOError if there is an error connecting via paramiko's sftp.get.

Proposed Commit Message

Test pycloudlib's BaseInstance.pull_file doesn't return a Result
object. So we can't call ok() on the response in integration tests.

Leave the try/except handling as pull_file will raise an
IOError if there is an error connecting via paramiko's sftp.get.

Additional Context

Test Steps

Run the following failing test locally on main and notice that the generated logs in /tmp/cloud_init_test_logs/ are still compressed and that we receive an ERROR logged to the console incorrectly saying
2022-02-04 21:47:56 ERROR integration_testing:conftest.py:212 Failed to pull logs: 'NoneType' object has no attribute 'ok'

# create a failing integration test
$ sed -i 's/X11/XBOGUS/' tests/integration_tests/modules/test_keyboard.py
$ CLOUD_INIT_PLATFORM=lxd_container CLOUD_INIT_KEEP_INSTANCE=false CLOUD_INIT_SOURCE=ppa:cloud-init-dev/daily CLOUD_INIT_OS_IMAGE=jammy .tox/integration-tests/bin/pytest tests/integration_tests/modules/test_keyboard.py

# Before this fix: Expect "Failed to pull logs: 'NoneType' object has no attribute 'ok'"  ERROR log to console
#  and expect compressed cloud-init.tar.gz 
$ find /tmp/cloud_init_test_logs/last/
/tmp/cloud_init_test_logs/last/
/tmp/cloud_init_test_logs/last/test_keyboard
/tmp/cloud_init_test_logs/last/test_keyboard/cloud-init.tar.gz

# After fix: no "Failed to pull logs" and uncompressed log results
$ find /tmp/cloud_init_test_logs/last/ | wc -l
25

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

Test pycloudlib's BaseInstance.pull_file doesn't return a Result
object. So we can't call ok() on the response in integration tests.

Leave the try/except handling as pull_file will raise an
IOError if there is an error connecting via paramiko's sftp.get.
@TheRealFalcon TheRealFalcon merged commit a804c10 into canonical:main Feb 7, 2022
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.

2 participants