From 62d55944086fedb0157179072a2cb22f8ed80f93 Mon Sep 17 00:00:00 2001 From: Justin Boswell Date: Thu, 2 May 2019 19:08:47 -0700 Subject: [PATCH 1/4] Made example.com a compliant URI --- integration-testing/http_client_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-testing/http_client_test.py b/integration-testing/http_client_test.py index 40d5428af..6676907f4 100644 --- a/integration-testing/http_client_test.py +++ b/integration-testing/http_client_test.py @@ -26,7 +26,7 @@ def run_command(args): subprocess.check_call(args, shell=shell) #make a simple GET request and make sure it succeeds -simple_get_args = [elasticurl_path, '-v', 'TRACE', 'example.com'] +simple_get_args = [elasticurl_path, '-v', 'TRACE', 'http://example.com'] run_command(simple_get_args) #make a simple POST request to make sure sending data succeeds From 8987835fbc5f70b59a5c1a04fa2d003a09840cff Mon Sep 17 00:00:00 2001 From: Justin Boswell Date: Fri, 3 May 2019 09:22:08 -0700 Subject: [PATCH 2/4] Upgraded http_client_test so we can jam more tests into it easily --- integration-testing/http_client_test.py | 49 ++++++++++++++++++++----- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/integration-testing/http_client_test.py b/integration-testing/http_client_test.py index 6676907f4..1ec5ce38a 100644 --- a/integration-testing/http_client_test.py +++ b/integration-testing/http_client_test.py @@ -25,20 +25,49 @@ def run_command(args): subprocess.check_call(args, shell=shell) +class Test(object): + def test(self): + raise NotImplementedError() + #make a simple GET request and make sure it succeeds -simple_get_args = [elasticurl_path, '-v', 'TRACE', 'http://example.com'] -run_command(simple_get_args) +class SimpleGet(Test): + def test(self): + simple_get_args = [elasticurl_path, '-v', 'TRACE', 'http://example.com'] + run_command(simple_get_args) #make a simple POST request to make sure sending data succeeds -simple_post_args = [elasticurl_path, '-v', 'TRACE', '-P', '-H', 'content-type: application/json', '-i', '-d', '\"{\'test\':\'testval\'}\"', 'http://httpbin.org/post'] -run_command(simple_post_args) +class SimplePost(Test): + def test(self): + simple_post_args = [elasticurl_path, '-v', 'TRACE', '-P', '-H', 'content-type: application/json', '-i', '-d', '\"{\'test\':\'testval\'}\"', 'http://httpbin.org/post'] + run_command(simple_post_args) #download a large file and compare the results with something we assume works (e.g. urllib) -elasticurl_download_args = [elasticurl_path, '-v', 'TRACE', '-o', 'elastigirl.png', 'https://s3.amazonaws.com/code-sharing-aws-crt/elastigirl.png'] -run_command(elasticurl_download_args) +class SimpleImageDownload(Test): + def test(self): + elasticurl_download_args = [elasticurl_path, '-v', 'TRACE', '-o', 'elastigirl.png', 'https://s3.amazonaws.com/code-sharing-aws-crt/elastigirl.png'] + run_command(elasticurl_download_args) -urllib.request.urlretrieve('https://s3.amazonaws.com/code-sharing-aws-crt/elastigirl.png', 'elastigirl_expected.png') + urllib.request.urlretrieve('https://s3.amazonaws.com/code-sharing-aws-crt/elastigirl.png', 'elastigirl_expected.png') -if not filecmp.cmp('elastigirl.png', 'elastigirl_expected.png'): - print('downloaded files do not match, exiting with error....') - sys.exit(-1) + if not filecmp.cmp('elastigirl.png', 'elastigirl_expected.png'): + raise RuntimeError('downloaded files do not match') + +if __name__ == '__main__': + tests = Test.__subclasses__() + passed = 0 + for test_type in tests: + print('##########################################################################') + print("TEST: {}".format(test_type.__name__)) + print('##########################################################################') + test = test_type() + try: + test.test() + passed = passed + 1 + except RuntimeError as re: + print(re) + print("TEST: {} FAILED".format(test_type.__name__)) + + print("") + print("{}/{} tests passed".format(passed, len(tests))) + if (passed != len(tests)): + sys.exit(-1) \ No newline at end of file From 07cabb926fcbb9b50a2a5faab4975fc4e6bfd8d0 Mon Sep 17 00:00:00 2001 From: Justin Boswell Date: Fri, 3 May 2019 10:24:15 -0700 Subject: [PATCH 3/4] Switched to using unittest --- integration-testing/http_client_test.py | 35 +++++-------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/integration-testing/http_client_test.py b/integration-testing/http_client_test.py index 1ec5ce38a..4c6904c3a 100644 --- a/integration-testing/http_client_test.py +++ b/integration-testing/http_client_test.py @@ -14,8 +14,9 @@ import subprocess import sys import urllib.request +import unittest -elasticurl_path = sys.argv[1] +elasticurl_path = sys.argv.pop() shell = sys.platform.startswith('win') if elasticurl_path == None: @@ -25,25 +26,20 @@ def run_command(args): subprocess.check_call(args, shell=shell) -class Test(object): - def test(self): - raise NotImplementedError() +class SimpleTests(unittest.TestCase): #make a simple GET request and make sure it succeeds -class SimpleGet(Test): - def test(self): + def test_simple_get(self): simple_get_args = [elasticurl_path, '-v', 'TRACE', 'http://example.com'] run_command(simple_get_args) #make a simple POST request to make sure sending data succeeds -class SimplePost(Test): - def test(self): + def test_simple_post(self): simple_post_args = [elasticurl_path, '-v', 'TRACE', '-P', '-H', 'content-type: application/json', '-i', '-d', '\"{\'test\':\'testval\'}\"', 'http://httpbin.org/post'] run_command(simple_post_args) #download a large file and compare the results with something we assume works (e.g. urllib) -class SimpleImageDownload(Test): - def test(self): + def test_simple_download(self): elasticurl_download_args = [elasticurl_path, '-v', 'TRACE', '-o', 'elastigirl.png', 'https://s3.amazonaws.com/code-sharing-aws-crt/elastigirl.png'] run_command(elasticurl_download_args) @@ -53,21 +49,4 @@ def test(self): raise RuntimeError('downloaded files do not match') if __name__ == '__main__': - tests = Test.__subclasses__() - passed = 0 - for test_type in tests: - print('##########################################################################') - print("TEST: {}".format(test_type.__name__)) - print('##########################################################################') - test = test_type() - try: - test.test() - passed = passed + 1 - except RuntimeError as re: - print(re) - print("TEST: {} FAILED".format(test_type.__name__)) - - print("") - print("{}/{} tests passed".format(passed, len(tests))) - if (passed != len(tests)): - sys.exit(-1) \ No newline at end of file + unittest.main() \ No newline at end of file From 59fda105d0b23a28f1eafd8819f7c77470c65237 Mon Sep 17 00:00:00 2001 From: Justin Boswell Date: Fri, 3 May 2019 12:28:22 -0700 Subject: [PATCH 4/4] shallow testing might fail if access/creation times are different --- integration-testing/http_client_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-testing/http_client_test.py b/integration-testing/http_client_test.py index 4c6904c3a..c818d16f5 100644 --- a/integration-testing/http_client_test.py +++ b/integration-testing/http_client_test.py @@ -45,7 +45,7 @@ def test_simple_download(self): urllib.request.urlretrieve('https://s3.amazonaws.com/code-sharing-aws-crt/elastigirl.png', 'elastigirl_expected.png') - if not filecmp.cmp('elastigirl.png', 'elastigirl_expected.png'): + if not filecmp.cmp('elastigirl.png', 'elastigirl_expected.png', shallow=False): raise RuntimeError('downloaded files do not match') if __name__ == '__main__':