summaryrefslogtreecommitdiff
path: root/tests/cloud_tests/platforms/ec2/instance.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2018-01-19 09:43:55 -0500
committerScott Moser <smoser@ubuntu.com>2018-01-23 21:05:21 -0500
commit32a6a1764e902c31dd3af9b674cea14cd6501187 (patch)
tree86c84dab8cb09f0bc45d01df2a810fdcf30f7bab /tests/cloud_tests/platforms/ec2/instance.py
parentccbe7f6e53eb243b5c869d4f927b93b47e5cb8cd (diff)
downloadvyos-cloud-init-32a6a1764e902c31dd3af9b674cea14cd6501187.tar.gz
vyos-cloud-init-32a6a1764e902c31dd3af9b674cea14cd6501187.zip
tests: Fix EC2 Platform to return console output as bytes.
The EC2 test platform uses boto, and boto decodes console output with decode('utf-8', 'replace). It is known that Ubuntu consoles contain non-utf8 characters, making this call lossy. The change here is to patch the boto session to include a OutputBytes entry in the console_output response, and then to utilize that in console_log. More information on problem and solution at: https://github.com/boto/botocore/issues/1351
Diffstat (limited to 'tests/cloud_tests/platforms/ec2/instance.py')
-rw-r--r--tests/cloud_tests/platforms/ec2/instance.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/cloud_tests/platforms/ec2/instance.py b/tests/cloud_tests/platforms/ec2/instance.py
index 4ba737ab..ab6037b1 100644
--- a/tests/cloud_tests/platforms/ec2/instance.py
+++ b/tests/cloud_tests/platforms/ec2/instance.py
@@ -46,9 +46,15 @@ class EC2Instance(Instance):
may return empty string.
"""
try:
- return self.instance.console_output()['Output'].encode()
+ # OutputBytes comes from platform._decode_console_output_as_bytes
+ response = self.instance.console_output()
+ return response['OutputBytes']
except KeyError:
- return b''
+ if 'Output' in response:
+ msg = ("'OutputBytes' did not exist in console_output() but "
+ "'Output' did: %s..." % response['Output'][0:128])
+ raise util.PlatformError('console_log', msg)
+ return ('No Console Output [%s]' % self.instance).encode()
def destroy(self):
"""Clean up instance."""