diff --git a/roles/test-upload-logs-swift/library/test-fixtures/logs/Ꮓບບξ-unicode.txt b/roles/test-upload-logs-swift/library/test-fixtures/logs/Ꮓບບξ-unicode.txt new file mode 100644 index 000000000..fcd1f22b8 --- /dev/null +++ b/roles/test-upload-logs-swift/library/test-fixtures/logs/Ꮓບບξ-unicode.txt @@ -0,0 +1,5 @@ +The quick brown fox jumps over the lazy dog + +El veloz murciélago hindú comía feliz cardillo y kiwi. La cigüeña tocaba el saxofón detrás del palenque de paja. + +Съешь же ещё этих мягких французских булок, да выпей чаю diff --git a/roles/test-upload-logs-swift/library/test_zuul_swift_upload.py b/roles/test-upload-logs-swift/library/test_zuul_swift_upload.py index 6577c31cc..f7978b42d 100644 --- a/roles/test-upload-logs-swift/library/test_zuul_swift_upload.py +++ b/roles/test-upload-logs-swift/library/test_zuul_swift_upload.py @@ -19,6 +19,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type import os +import six import testtools import time import stat @@ -55,12 +56,15 @@ class TestFileList(testtools.TestCase): def assert_files(self, result, files): self.assertEqual(len(result), len(files)) for expected, received in zip(files, result): - self.assertEqual(expected[0], received.relative_path) - if expected[0] and expected[0][-1] == '/': + e = expected[0] + if six.PY2: + e = e.encode('utf-8') + self.assertEqual(e, received.relative_path) + if e and e[0][-1] == '/': efilename = os.path.split( - os.path.dirname(expected[0]))[1] + '/' + os.path.dirname(e))[1] + '/' else: - efilename = os.path.split(expected[0])[1] + efilename = os.path.split(e)[1] self.assertEqual(efilename, received.filename) if received.folder: if received.full_path is not None and expected[0] != '': @@ -85,6 +89,8 @@ class TestFileList(testtools.TestCase): ('controller', 'application/directory', None), ('zuul-info', 'application/directory', None), ('job-output.json', 'application/json', None), + (u'\u13c3\u0e9a\u0e9a\u03be-unicode.txt', + 'text/plain', None), ('controller/subdir', 'application/directory', None), ('controller/compressed.gz', 'text/plain', 'gzip'), ('controller/cpu-load.svg', 'image/svg+xml', None), @@ -107,6 +113,8 @@ class TestFileList(testtools.TestCase): ('logs/controller', 'application/directory', None), ('logs/zuul-info', 'application/directory', None), ('logs/job-output.json', 'application/json', None), + (u'logs/\u13c3\u0e9a\u0e9a\u03be-unicode.txt', + 'text/plain', None), ('logs/controller/subdir', 'application/directory', None), ('logs/controller/compressed.gz', 'text/plain', 'gzip'), ('logs/controller/cpu-load.svg', 'image/svg+xml', None), @@ -163,6 +171,8 @@ class TestFileList(testtools.TestCase): ('logs/controller', 'application/directory', None), ('logs/zuul-info', 'application/directory', None), ('logs/job-output.json', 'application/json', None), + (u'logs/\u13c3\u0e9a\u0e9a\u03be-unicode.txt', + 'text/plain', None), ('logs/index.html', 'text/html', None), ('logs/controller/subdir', 'application/directory', None), ('logs/controller/compressed.gz', 'text/plain', 'gzip'), @@ -217,6 +227,8 @@ class TestFileList(testtools.TestCase): ('controller', 'application/directory', None), ('zuul-info', 'application/directory', None), ('job-output.json', 'application/json', None), + (u'\u13c3\u0e9a\u0e9a\u03be-unicode.txt', + 'text/plain', None), ('index.html', 'text/html', None), ('controller/subdir', 'application/directory', None), ('controller/compressed.gz', 'text/plain', 'gzip'), @@ -238,7 +250,7 @@ class TestFileList(testtools.TestCase): page = BeautifulSoup(page, 'html.parser') rows = page.find_all('tr')[1:] - self.assertEqual(len(rows), 3) + self.assertEqual(len(rows), 4) self.assertEqual(rows[0].find('a').get('href'), 'controller/') self.assertEqual(rows[0].find('a').text, 'controller/') @@ -274,6 +286,8 @@ class TestFileList(testtools.TestCase): ('controller', 'application/directory', None), ('zuul-info', 'application/directory', None), ('job-output.json', 'application/json', None), + (u'\u13c3\u0e9a\u0e9a\u03be-unicode.txt', + 'text/plain', None), ('index.html', 'text/html', None), ('controller/subdir', 'application/directory', None), ('controller/compressed.gz', 'text/plain', 'gzip'), @@ -295,7 +309,7 @@ class TestFileList(testtools.TestCase): page = BeautifulSoup(page, 'html.parser') rows = page.find_all('tr')[1:] - self.assertEqual(len(rows), 4) + self.assertEqual(len(rows), 5) self.assertEqual(rows[0].find('a').get('href'), '../') self.assertEqual(rows[0].find('a').text, '../') @@ -334,6 +348,8 @@ class TestFileList(testtools.TestCase): ('controller', 'application/directory', None), ('zuul-info', 'application/directory', None), ('job-output.json', 'application/json', None), + (u'\u13c3\u0e9a\u0e9a\u03be-unicode.txt', + 'text/plain', None), ('index.html', 'text/html', None), ('controller/subdir', 'application/directory', None), ('controller/compressed.gz', 'text/plain', 'gzip'), @@ -355,7 +371,7 @@ class TestFileList(testtools.TestCase): page = BeautifulSoup(page, 'html.parser') rows = page.find_all('tr')[1:] - self.assertEqual(len(rows), 3) + self.assertEqual(len(rows), 4) self.assertEqual(rows[0].find('a').get('href'), 'controller/') self.assertEqual(rows[0].find('a').text, 'controller/') diff --git a/roles/upload-logs-swift/library/test-fixtures/download-logs-sample.sh b/roles/upload-logs-swift/library/test-fixtures/download-logs-sample.sh index 335d93936..c71763bc0 100644 --- a/roles/upload-logs-swift/library/test-fixtures/download-logs-sample.sh +++ b/roles/upload-logs-swift/library/test-fixtures/download-logs-sample.sh @@ -48,34 +48,37 @@ pushd "${DOWNLOAD_DIR}" > /dev/null -log "Getting ${BASE_URL}/job-output.json [ 0001 / 0010 ]" +log "Getting ${BASE_URL}/job-output.json [ 0001 / 0011 ]" save_file "job-output.json" -log "Getting ${BASE_URL}/controller/compressed.gz [ 0002 / 0010 ]" +log "Getting ${BASE_URL}/Ꮓບບξ-unicode.txt [ 0002 / 0011 ]" +save_file "Ꮓບບξ-unicode.txt" + +log "Getting ${BASE_URL}/controller/compressed.gz [ 0003 / 0011 ]" save_file "controller/compressed.gz" -log "Getting ${BASE_URL}/controller/cpu-load.svg [ 0003 / 0010 ]" +log "Getting ${BASE_URL}/controller/cpu-load.svg [ 0004 / 0011 ]" save_file "controller/cpu-load.svg" -log "Getting ${BASE_URL}/controller/journal.xz [ 0004 / 0010 ]" +log "Getting ${BASE_URL}/controller/journal.xz [ 0005 / 0011 ]" save_file "controller/journal.xz" -log "Getting ${BASE_URL}/controller/service_log.txt [ 0005 / 0010 ]" +log "Getting ${BASE_URL}/controller/service_log.txt [ 0006 / 0011 ]" save_file "controller/service_log.txt" -log "Getting ${BASE_URL}/controller/syslog [ 0006 / 0010 ]" +log "Getting ${BASE_URL}/controller/syslog [ 0007 / 0011 ]" save_file "controller/syslog" -log "Getting ${BASE_URL}/controller/subdir/foo::3.txt [ 0007 / 0010 ]" +log "Getting ${BASE_URL}/controller/subdir/foo::3.txt [ 0008 / 0011 ]" save_file "controller/subdir/foo::3.txt" -log "Getting ${BASE_URL}/controller/subdir/subdir.txt [ 0008 / 0010 ]" +log "Getting ${BASE_URL}/controller/subdir/subdir.txt [ 0009 / 0011 ]" save_file "controller/subdir/subdir.txt" -log "Getting ${BASE_URL}/zuul-info/inventory.yaml [ 0009 / 0010 ]" +log "Getting ${BASE_URL}/zuul-info/inventory.yaml [ 0010 / 0011 ]" save_file "zuul-info/inventory.yaml" -log "Getting ${BASE_URL}/zuul-info/zuul-info.controller.txt [ 0010 / 0010 ]" +log "Getting ${BASE_URL}/zuul-info/zuul-info.controller.txt [ 0011 / 0011 ]" save_file "zuul-info/zuul-info.controller.txt" diff --git a/roles/upload-logs-swift/library/test-fixtures/logs/Ꮓບບξ-unicode.txt b/roles/upload-logs-swift/library/test-fixtures/logs/Ꮓບບξ-unicode.txt new file mode 100644 index 000000000..fcd1f22b8 --- /dev/null +++ b/roles/upload-logs-swift/library/test-fixtures/logs/Ꮓບບξ-unicode.txt @@ -0,0 +1,5 @@ +The quick brown fox jumps over the lazy dog + +El veloz murciélago hindú comía feliz cardillo y kiwi. La cigüeña tocaba el saxofón detrás del palenque de paja. + +Съешь же ещё этих мягких французских булок, да выпей чаю diff --git a/roles/upload-logs-swift/library/test_zuul_swift_upload.py b/roles/upload-logs-swift/library/test_zuul_swift_upload.py index 6577c31cc..f7978b42d 100644 --- a/roles/upload-logs-swift/library/test_zuul_swift_upload.py +++ b/roles/upload-logs-swift/library/test_zuul_swift_upload.py @@ -19,6 +19,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type import os +import six import testtools import time import stat @@ -55,12 +56,15 @@ class TestFileList(testtools.TestCase): def assert_files(self, result, files): self.assertEqual(len(result), len(files)) for expected, received in zip(files, result): - self.assertEqual(expected[0], received.relative_path) - if expected[0] and expected[0][-1] == '/': + e = expected[0] + if six.PY2: + e = e.encode('utf-8') + self.assertEqual(e, received.relative_path) + if e and e[0][-1] == '/': efilename = os.path.split( - os.path.dirname(expected[0]))[1] + '/' + os.path.dirname(e))[1] + '/' else: - efilename = os.path.split(expected[0])[1] + efilename = os.path.split(e)[1] self.assertEqual(efilename, received.filename) if received.folder: if received.full_path is not None and expected[0] != '': @@ -85,6 +89,8 @@ class TestFileList(testtools.TestCase): ('controller', 'application/directory', None), ('zuul-info', 'application/directory', None), ('job-output.json', 'application/json', None), + (u'\u13c3\u0e9a\u0e9a\u03be-unicode.txt', + 'text/plain', None), ('controller/subdir', 'application/directory', None), ('controller/compressed.gz', 'text/plain', 'gzip'), ('controller/cpu-load.svg', 'image/svg+xml', None), @@ -107,6 +113,8 @@ class TestFileList(testtools.TestCase): ('logs/controller', 'application/directory', None), ('logs/zuul-info', 'application/directory', None), ('logs/job-output.json', 'application/json', None), + (u'logs/\u13c3\u0e9a\u0e9a\u03be-unicode.txt', + 'text/plain', None), ('logs/controller/subdir', 'application/directory', None), ('logs/controller/compressed.gz', 'text/plain', 'gzip'), ('logs/controller/cpu-load.svg', 'image/svg+xml', None), @@ -163,6 +171,8 @@ class TestFileList(testtools.TestCase): ('logs/controller', 'application/directory', None), ('logs/zuul-info', 'application/directory', None), ('logs/job-output.json', 'application/json', None), + (u'logs/\u13c3\u0e9a\u0e9a\u03be-unicode.txt', + 'text/plain', None), ('logs/index.html', 'text/html', None), ('logs/controller/subdir', 'application/directory', None), ('logs/controller/compressed.gz', 'text/plain', 'gzip'), @@ -217,6 +227,8 @@ class TestFileList(testtools.TestCase): ('controller', 'application/directory', None), ('zuul-info', 'application/directory', None), ('job-output.json', 'application/json', None), + (u'\u13c3\u0e9a\u0e9a\u03be-unicode.txt', + 'text/plain', None), ('index.html', 'text/html', None), ('controller/subdir', 'application/directory', None), ('controller/compressed.gz', 'text/plain', 'gzip'), @@ -238,7 +250,7 @@ class TestFileList(testtools.TestCase): page = BeautifulSoup(page, 'html.parser') rows = page.find_all('tr')[1:] - self.assertEqual(len(rows), 3) + self.assertEqual(len(rows), 4) self.assertEqual(rows[0].find('a').get('href'), 'controller/') self.assertEqual(rows[0].find('a').text, 'controller/') @@ -274,6 +286,8 @@ class TestFileList(testtools.TestCase): ('controller', 'application/directory', None), ('zuul-info', 'application/directory', None), ('job-output.json', 'application/json', None), + (u'\u13c3\u0e9a\u0e9a\u03be-unicode.txt', + 'text/plain', None), ('index.html', 'text/html', None), ('controller/subdir', 'application/directory', None), ('controller/compressed.gz', 'text/plain', 'gzip'), @@ -295,7 +309,7 @@ class TestFileList(testtools.TestCase): page = BeautifulSoup(page, 'html.parser') rows = page.find_all('tr')[1:] - self.assertEqual(len(rows), 4) + self.assertEqual(len(rows), 5) self.assertEqual(rows[0].find('a').get('href'), '../') self.assertEqual(rows[0].find('a').text, '../') @@ -334,6 +348,8 @@ class TestFileList(testtools.TestCase): ('controller', 'application/directory', None), ('zuul-info', 'application/directory', None), ('job-output.json', 'application/json', None), + (u'\u13c3\u0e9a\u0e9a\u03be-unicode.txt', + 'text/plain', None), ('index.html', 'text/html', None), ('controller/subdir', 'application/directory', None), ('controller/compressed.gz', 'text/plain', 'gzip'), @@ -355,7 +371,7 @@ class TestFileList(testtools.TestCase): page = BeautifulSoup(page, 'html.parser') rows = page.find_all('tr')[1:] - self.assertEqual(len(rows), 3) + self.assertEqual(len(rows), 4) self.assertEqual(rows[0].find('a').get('href'), 'controller/') self.assertEqual(rows[0].find('a').text, 'controller/')