From 09f3a0b5cc4639ba267fd3c2e3a0a6b0439aac6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Wed, 14 Aug 2024 13:55:54 +0200 Subject: [PATCH] Add retries to tests depending on HTTP (#10815) - Continuation of #9652 - apparently some tests that depend on HTTP requests were missed then. - Closes #10742 --- test/Base_Tests/src/Network/URI_Spec.enso | 25 +++++++++---------- .../src/Database/Postgres_Spec.enso | 2 +- .../src/IO/Data_Link_Formats_Spec.enso | 16 ++++++------ 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/test/Base_Tests/src/Network/URI_Spec.enso b/test/Base_Tests/src/Network/URI_Spec.enso index 732c04738931..8b0d4959dcdd 100644 --- a/test/Base_Tests/src/Network/URI_Spec.enso +++ b/test/Base_Tests/src/Network/URI_Spec.enso @@ -128,7 +128,7 @@ add_specs suite_builder = uri.fragment.should_equal Nothing # We rely on the http-test-helper for these tests, to ensure that the encoding is indeed correctly interpreted by a real-life server: - group_builder.specify "should correctly handle various characters within the key and value of arguments" pending=pending_has_url <| + group_builder.specify "should correctly handle various characters within the key and value of arguments" pending=pending_has_url <| Test.with_retries <| base_uri = URI.parse base_url+"get" uri1 = base_uri . add_query_argument "a" "b" @@ -166,7 +166,7 @@ add_specs suite_builder = r4 = uri4.fetch decode_query_params r4 . should_equal [["p+r", "b c"], ["p r", "b c"], ["🚀", "🚧"], ["śnieżnobiałą", "łąkę"], [s2, "zzz"]] - group_builder.specify "may allow duplicate keys in query parameters" pending=pending_has_url <| + group_builder.specify "may allow duplicate keys in query parameters" pending=pending_has_url <| Test.with_retries <| uri = URI.parse base_url+"get" . add_query_argument "a" "b" . add_query_argument "a" "c" @@ -220,7 +220,7 @@ add_specs suite_builder = uri5 = uri4 / "b" uri5.path . should_equal "/get/a//b" - group_builder.specify "should allow various characters in the path" pending=pending_has_url <| + group_builder.specify "should allow various characters in the path" pending=pending_has_url <| Test.with_retries <| uri0 = URI.parse base_url+"get" uri1 = uri0 / "a b c" / "d+e" / "f%20g" / "ś🚧:@" @@ -291,9 +291,9 @@ add_specs suite_builder = cloud_setup = Cloud_Tests_Setup.prepare - group_builder.specify "will not convert back to URI if secrets are present in the query arguments" pending=cloud_setup.pending <| + group_builder.specify "will not convert back to URI if secrets are present in the query arguments" pending=cloud_setup.pending <| Test.with_retries <| cloud_setup.with_prepared_environment <| - secret1 = Enso_Secret.create "my_test_secret-uri-1" "My Value" + secret1 = Enso_Secret.create "my_test_secret-uri-1-"+Random.uuid "My Value" secret1.should_succeed Panic.with_finalizer secret1.delete <| uri = URI.from "https://example.com/" @@ -304,13 +304,13 @@ add_specs suite_builder = uri.to_java_uri . should_fail_with Enso_Secret_Error uri.raw_query . should_fail_with Enso_Secret_Error - group_builder.specify "should allow to use secrets in query arguments, containing all kinds of various characters" pending=cloud_setup.httpbin_pending <| + group_builder.specify "should allow to use secrets in query arguments, containing all kinds of various characters" pending=cloud_setup.httpbin_pending <| Test.with_retries <| cloud_setup.with_prepared_environment <| - secret1 = Enso_Secret.create "my_test_secret-uri-4" "My Very Secret Value" + secret1 = Enso_Secret.create "my_test_secret-uri-4-"+Random.uuid "My Very Secret Value" secret1.should_succeed Panic.with_finalizer secret1.delete <| s2 = "Another Secret Value containing Emoji 😊❤️ and ąęś AND [a=b]:[b=c][d=e]++++!?&->#...__(){}@///\\\|%%%100*^, ]]] ==>
a" - secret2 = Enso_Secret.create "my_test_secret-uri-5" s2 + secret2 = Enso_Secret.create "my_test_secret-uri-5"+Random.uuid s2 secret2.should_succeed Panic.with_finalizer secret2.delete <| uri = (cloud_setup.httpbin_secure_uri / "get") @@ -321,13 +321,12 @@ add_specs suite_builder = uri.to_text . should_equal (cloud_setup.httpbin_secure_uri.to_text + "get?arg1=__SECRET__&arg2=plain+value&arg3=__SECRET__") uri.raw_query . should_fail_with Enso_Secret_Error - Test.with_retries <| - response = cloud_setup.httpbin_secure_client.request (Request.get uri) - decode_query_params response.decode_as_json . should_equal [["arg1", "My Very Secret Value"], ["arg2", "plain value"], ["arg3", s2]] + response = cloud_setup.httpbin_secure_client.request (Request.get uri) + decode_query_params response.decode_as_json . should_equal [["arg1", "My Very Secret Value"], ["arg2", "plain value"], ["arg3", s2]] - group_builder.specify "does not allow secrets in non-https requests" pending=cloud_setup.pending <| + group_builder.specify "does not allow secrets in non-https requests" pending=cloud_setup.pending <| Test.with_retries <| cloud_setup.with_prepared_environment <| - secret1 = Enso_Secret.create "my_test_secret-uri-8" "My Value" + secret1 = Enso_Secret.create "my_test_secret-uri-8-"+Random.uuid "My Value" secret1.should_succeed Panic.with_finalizer secret1.delete <| uri1 = URI.from "http://example.com/" diff --git a/test/Table_Tests/src/Database/Postgres_Spec.enso b/test/Table_Tests/src/Database/Postgres_Spec.enso index f211161c1d6d..6dea73da8d7d 100644 --- a/test/Table_Tests/src/Database/Postgres_Spec.enso +++ b/test/Table_Tests/src/Database/Postgres_Spec.enso @@ -994,7 +994,7 @@ add_data_link_specs suite_builder = r.should_fail_with Illegal_Argument r.catch.to_display_text . should_contain "The Postgres Data Link does not support writing" - group_builder.specify "will fail with a clear message if trying to download a Database data link" pending=Http_Test_Setup.pending_has_url <| + group_builder.specify "will fail with a clear message if trying to download a Database data link" pending=Http_Test_Setup.pending_has_url <| Test.with_retries <| url = Http_Test_Setup.base_url_with_slash+"testfiles/some-postgres.datalink" target_file = enso_project.data / "transient" / "some-postgres-target" target_file.delete_if_exists diff --git a/test/Table_Tests/src/IO/Data_Link_Formats_Spec.enso b/test/Table_Tests/src/IO/Data_Link_Formats_Spec.enso index 49cc388f4d95..834070ed1a57 100644 --- a/test/Table_Tests/src/IO/Data_Link_Formats_Spec.enso +++ b/test/Table_Tests/src/IO/Data_Link_Formats_Spec.enso @@ -19,25 +19,25 @@ main filter=Nothing = add_specs suite_builder = suite_builder.group "parsing Table formats in DataLinks" pending=pending_has_url group_builder-> data_link_root = enso_project.data / "datalinks" - group_builder.specify "parsing Delimited without quotes" <| + group_builder.specify "parsing Delimited without quotes" <| Test.with_retries <| data_link_file = replace_url_in_data_link (data_link_root / "example-http-format-delimited-ignore-quote.datalink") t = data_link_file.read t.should_equal (Table.from_rows ["Column 1", "Column 2"] [['{"hello":', '"world"}']]) - group_builder.specify "parsing Delimited with custom delimiter quotes" <| + group_builder.specify "parsing Delimited with custom delimiter quotes" <| Test.with_retries <| data_link_file = replace_url_in_data_link (data_link_root / "example-http-format-delimited-custom-quote.datalink") t = data_link_file.read weird_txt = "x'z" + '""w' # The A column remains a text column because of being quoted t.should_equal (Table.new [["A", ["1", "3"]], ["B", [weird_txt, "y"]]]) - group_builder.specify "overriding the custom format in Delimited datalink" <| + group_builder.specify "overriding the custom format in Delimited datalink" <| Test.with_retries <| data_link_file = replace_url_in_data_link (data_link_root / "example-http-format-delimited-ignore-quote.datalink") r = data_link_file.read ..Plain_Text r.should_be_a Text r.trim.should_equal '{"hello": "world"}' - group_builder.specify "parsing Excel_Format.Workbook" <| + group_builder.specify "parsing Excel_Format.Workbook" <| Test.with_retries <| data_link_file = replace_url_in_data_link (data_link_root / "example-http-format-excel-workbook.datalink") workbook = data_link_file.read @@ -45,19 +45,19 @@ add_specs suite_builder = suite_builder.group "parsing Table formats in DataLink workbook.should_be_a Excel_Workbook workbook.sheet_names . should_equal ["MyTestSheet"] - group_builder.specify "parsing Excel_Format.Sheet" <| + group_builder.specify "parsing Excel_Format.Sheet" <| Test.with_retries <| data_link_file = replace_url_in_data_link (data_link_root / "example-http-format-excel-sheet.datalink") table = data_link_file.read table . should_equal (Table.from_rows ["A", "B"] [[1, 'x'], [3, 'y']]) - group_builder.specify "parsing Excel_Format.Range" <| + group_builder.specify "parsing Excel_Format.Range" <| Test.with_retries <| data_link_file = replace_url_in_data_link (data_link_root / "example-http-format-excel-range.datalink") table = data_link_file.read table . should_equal (Table.from_rows ["A", "B"] [[3, 'y']]) - group_builder.specify "overriding Excel format" <| + group_builder.specify "overriding Excel format" <| Test.with_retries <| data_link_file = replace_url_in_data_link (data_link_root / "example-http-format-excel-workbook.datalink") table = data_link_file.read (..Range "MyTestSheet!A1:B1") @@ -66,7 +66,7 @@ add_specs suite_builder = suite_builder.group "parsing Table formats in DataLink bytes = data_link_file.read_bytes bytes.should_be_a Vector - group_builder.specify "reading a datalink as a stream" <| + group_builder.specify "reading a datalink as a stream" <| Test.with_retries <| data_link_file = replace_url_in_data_link (data_link_root / "example-http-format-excel-range.datalink") r1 = data_link_file.with_input_stream [File_Access.Read] input_stream->