Skip to content

Commit 01cbb8a

Browse files
Moving the cloud and HTTP tests outside of Base_Tests (#13857)
- to unlock #13570 - I'd like to move cloud related tests outside of `Base_Tests` - they are [accessing internals](#13570 (comment)) of `Standard.Base` (caches, keys, etc.) - they would have to be significantly rewritten to run the the "dual JVM" mode - easier to split them out and run them with [special options](#13857 (comment))
1 parent 54a5efd commit 01cbb8a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1785
-150
lines changed

test/AWS_Tests/src/Inter_Backend_File_Operations_Spec.enso

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
1414

1515
from Standard.Test import all
1616

17-
import enso_dev.Base_Tests.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup
17+
import enso_dev.Cloud_Tests.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup
1818

1919
from project.S3_Spec import api_pending, writable_root, with_default_credentials
2020

test/AWS_Tests/src/S3_Spec.enso

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import enso_dev.Table_Tests.Util
1919
from Standard.Test import all
2020

2121
import enso_dev.Base_Tests.Data.Data_Spec
22-
import enso_dev.Base_Tests.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup
23-
import enso_dev.Base_Tests.Network.Enso_Cloud.Cloud_Tests_Setup.Temporary_Directory
22+
import enso_dev.Cloud_Tests.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup
23+
import enso_dev.Cloud_Tests.Network.Enso_Cloud.Cloud_Tests_Setup.Temporary_Directory
2424
import enso_dev.Base_Tests.System.File_Spec as Local_File_Spec
25-
from enso_dev.Base_Tests.Network.Enso_Cloud.Cloud_Data_Link_Spec import Symlink_Test_Setup, create_data_link_to_cloud, add_symlink_spec
25+
from enso_dev.Cloud_Tests.Network.Enso_Cloud.Cloud_Data_Link_Spec import Symlink_Test_Setup, create_data_link_to_cloud, add_symlink_spec
2626

2727
test_credentials -> AWS_Credential ! Illegal_State =
2828
access_key_id = Environment.get "ENSO_LIB_S3_AWS_ACCESS_KEY_ID" ""

test/Base_Internal_Tests/src/Cloud_Credentials_Spec.enso

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ from Standard.Base import all
22

33
from Standard.Test import all
44

5-
import enso_dev.Base_Tests.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup
6-
import enso_dev.Base_Tests.Network.Enso_Cloud.Cloud_Tests_Setup.Temporary_Directory
5+
import enso_dev.Cloud_Tests.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup
6+
import enso_dev.Cloud_Tests.Network.Enso_Cloud.Cloud_Tests_Setup.Temporary_Directory
77

88
from project.Cloud_Helpers.Credentials import create_example_credential
99

test/Base_Tests/README.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,6 @@ You can stop the server via Ctrl-C.
2424
See [the server's documentation](../../tools/http-test-helper/README.md) for
2525
more information.
2626

27-
## Cloud tests
28-
29-
By default, a subset of cloud tests runs whenever the
30-
`ENSO_HTTP_TEST_HTTPBIN_URL` environment variable is set, using a mock of parts
31-
of the cloud logic running on the helper server.
32-
33-
To run a full set of cloud tests against a real deployment, you need to set the
34-
following 3 environment variables:
35-
36-
- `ENSO_CLOUD_API_URL` to point to the root of the cloud API,
37-
- `ENSO_CLOUD_CREDENTIALS_FILE` to be a path to a file containing the
38-
credentials to use, e.g. `~/.enso/credentials`,
39-
- `ENSO_RUN_REAL_CLOUD_TEST=1` to tell the test suite to run against a real
40-
cloud deployment.
41-
42-
Note that some cloud tests (e.g. testing secrets in HTTP requests) still require
43-
the `ENSO_HTTP_TEST_HTTPBIN_URL` setup, even if running against a real cloud
44-
deployment.
45-
4627
### Testing audit log batching
4728

4829
Currently, we only have a manual scenario for testing that log messages are

test/Base_Tests/src/Main.enso

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ import project.Data.XML.XML_Spec
6363

6464
import project.Data.Vector.Slicing_Helpers_Spec
6565

66-
import project.Network.Enso_Cloud.Main as Enso_Cloud_Main
67-
6866
import project.Network.Http.Header_Spec as Http_Header_Spec
6967
import project.Network.Http.Request_Spec as Http_Request_Spec
7068
import project.Network.Http.Http_Auto_Parse_Spec
@@ -126,7 +124,6 @@ main filter=Nothing =
126124
Http_Spec.add_specs suite_builder
127125
Http_Auto_Parse_Spec.add_specs suite_builder
128126
Http_Data_Link_Spec.add_specs suite_builder
129-
Enso_Cloud_Main.add_specs suite_builder
130127
Import_Loop_Spec.add_specs suite_builder
131128
Interval_Spec.add_specs suite_builder
132129
Java_Interop_Spec.add_specs suite_builder

test/Base_Tests/src/Network/URI_Spec.enso

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
from Standard.Base import all
2-
import Standard.Base.Enso_Cloud.Enso_Secret.Enso_Secret_Error
32
import Standard.Base.Errors.Common.Syntax_Error
43
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
5-
import Standard.Base.Network.HTTP.Request.Request
64
import Standard.Base.Network.URI.Invalid_Query_String
75

86
from Standard.Test import all
97

10-
import project.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup
11-
12-
polyglot java import org.enso.base.enso_cloud.EnsoSecretHelper
13-
148
add_specs suite_builder =
159
## To run this test locally:
1610
$ sbt 'http-test-helper/run localhost 8080'
@@ -308,73 +302,6 @@ add_specs suite_builder =
308302
uri2.fragment . should_equal "FRAG"
309303
uri2.to_text . should_equal "https://example.com/path#FRAG"
310304

311-
cloud_setup = Cloud_Tests_Setup.prepare
312-
313-
group_builder.specify "will not convert back to URI if secrets are present in the query arguments" pending=cloud_setup.pending <| Test.with_retries <|
314-
cloud_setup.with_prepared_environment <|
315-
secret1 = Enso_Secret.create "my_test_secret-uri-1-"+Random.uuid "My Value"
316-
secret1.should_succeed
317-
Panic.with_finalizer secret1.delete <|
318-
uri = URI.from "https://example.com/"
319-
. add_query_argument "arg1" secret1
320-
. add_query_argument "arg2" "plain value"
321-
322-
uri.to_text . should_equal ("https://example.com/?arg1=__SECRET__&arg2=plain+value")
323-
uri.to_java_uri . should_fail_with Enso_Secret_Error
324-
uri.raw_query . should_fail_with Enso_Secret_Error
325-
326-
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 <|
327-
cloud_setup.with_prepared_environment <|
328-
secret1 = Enso_Secret.create "my_test_secret-uri-4-"+Random.uuid "My Very Secret Value"
329-
secret1.should_succeed
330-
Panic.with_finalizer secret1.delete <|
331-
s2 = "Another Secret Value containing Emoji 😊❤️ and ąęś AND [a=b]:[b=c][d=e]++++!?&->#...__(){}@///\\\|%%%100*^, ]]] ==> <br>a"
332-
secret2 = Enso_Secret.create "my_test_secret-uri-5"+Random.uuid s2
333-
secret2.should_succeed
334-
Panic.with_finalizer secret2.delete <|
335-
uri = (cloud_setup.httpbin_secure_uri / "get")
336-
. add_query_argument "arg1" secret1
337-
. add_query_argument "arg2" "plain value"
338-
. add_query_argument "arg3" secret2
339-
340-
uri.to_text . should_equal (cloud_setup.httpbin_secure_uri.to_text + "get?arg1=__SECRET__&arg2=plain+value&arg3=__SECRET__")
341-
uri.raw_query . should_fail_with Enso_Secret_Error
342-
343-
response = cloud_setup.httpbin_secure_client.request (Request.get uri)
344-
decode_query_params response.decode_as_json . should_equal [["arg1", "My Very Secret Value"], ["arg2", "plain value"], ["arg3", s2]]
345-
346-
group_builder.specify "does not allow secrets in non-https requests" pending=cloud_setup.pending <| Test.with_retries <|
347-
cloud_setup.with_prepared_environment <|
348-
secret1 = Enso_Secret.create "my_test_secret-uri-8-"+Random.uuid "My Value"
349-
secret1.should_succeed
350-
Panic.with_finalizer secret1.delete <|
351-
uri1 = URI.from "http://example.com/"
352-
. add_query_argument "arg1" secret1
353-
. add_query_argument "arg2" "plain value"
354-
355-
uri1.to_text . should_equal ("http://example.com/?arg1=__SECRET__&arg2=plain+value")
356-
r1 = uri1.fetch
357-
r1.should_fail_with Illegal_Argument
358-
r1.catch.to_display_text . should_contain "Secrets are not allowed in HTTP connections, use HTTPS instead."
359-
360-
with_secret ~action =
361-
secret = Enso_Secret.create "my_test_secret-clear-cache-1-"+Random.uuid "My Value"
362-
secret.should_succeed
363-
Panic.with_finalizer secret.delete (action secret)
364-
365-
group_builder.specify "EnsoSecreetReader cache should be cleared when a reload is detected" pending=cloud_setup.pending <| Test.with_retries <|
366-
cloud_setup.with_prepared_environment <|
367-
with_secret secret1-> with_secret secret2->
368-
base_uri = URI.from 'https://httpbin.org/bytes/50'
369-
uri1 = base_uri . add_query_argument "arg1" secret1
370-
uri2 = base_uri . add_query_argument "arg1" secret2
371-
uri1.fetch . should_succeed
372-
uri2.fetch . should_succeed
373-
(EnsoSecretHelper.getEnsoSecretReaderCacheSize >= 2) . should_be_true
374-
EnsoSecretHelper.simulateEnsoSecretReaderReload
375-
uri1.fetch . should_succeed
376-
(EnsoSecretHelper.getEnsoSecretReaderCacheSize == 1) . should_be_true
377-
378305
main filter=Nothing =
379306
suite = Test.build suite_builder->
380307
add_specs suite_builder

test/Base_Tests/src/System/File_Spec.enso

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ from Standard.Test import all
1616
import Standard.Test.Test_Environment
1717

1818
import project.Data.Data_Spec
19-
import project.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup
2019

2120
## We rely on a less strict equality for `File` as it is fine if a relative file gets resolved to absolute.
2221
File.should_equal self other = Frame_Hider.hide <|
@@ -392,37 +391,6 @@ add_specs suite_builder =
392391
f.read_text . should_equal txt
393392
Data.read "abc/def.txt" . should_equal txt
394393

395-
cloud_setup = Cloud_Tests_Setup.prepare
396-
with_temporary_cloud_root ~action =
397-
subdir = (Enso_File.home / ("my_test_CWD-" + Random.uuid.take 5)).create_directory
398-
subdir.should_succeed
399-
cleanup =
400-
Enso_User.flush_caches
401-
subdir.delete recursive=True
402-
Panic.with_finalizer cleanup <|
403-
Test_Environment.unsafe_with_environment_override "ENSO_CLOUD_PROJECT_DIRECTORY_PATH" subdir.path <|
404-
# Flush caches to ensure fresh dir is used
405-
Enso_User.flush_caches
406-
Test.with_clue "(running with ENSO_CLOUD_PROJECT_DIRECTORY_PATH set to "+subdir.path+") " <|
407-
action
408-
409-
group_builder.specify "will resolve relative paths as Cloud paths if running in the Cloud" pending=cloud_setup.real_cloud_pending <|
410-
with_temporary_cloud_root <|
411-
root = File.new "."
412-
root.should_be_a Enso_File
413-
root.should_equal Enso_File.current_working_directory
414-
415-
f = File.new "abc/def.txt"
416-
f.should_be_a Enso_File
417-
f.should_equal (Enso_File.current_working_directory / "abc" / "def.txt")
418-
419-
# Data.read should be consistent too
420-
txt = "test-content"+Random.uuid
421-
(File.new "abc").create_directory . should_succeed
422-
txt.write f . should_succeed
423-
Panic.with_finalizer f.delete_if_exists <|
424-
Data.read "abc/def.txt" . should_equal txt
425-
426394
group_builder.specify "will resolve empty path to the current working directory" <|
427395
File.new "" . should_equal File.current_directory
428396

test/Cloud_Tests/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
This is a set of tests for the Enso Cloud functionality of the `Standard.Base`
2+
library of Enso.
3+
4+
## HTTP tests
5+
6+
The run test suite for the HTTP component requires an active helper server on
7+
the localhost. If it is present, the port it listens to should be provided by
8+
setting the `ENSO_HTTP_TEST_HTTPBIN_URL` environment variable to a value like
9+
`http://localhost:8080`. The URL may contain a trailing slash.
10+
11+
To run the test server, you may use the following command:
12+
13+
```bash
14+
sbt 'http-test-helper/run localhost 8080'
15+
```
16+
17+
Then execute the tests in another terminal as
18+
19+
```bash
20+
sbt 'runEngineDistribution --env ENSO_HTTP_TEST_HTTPBIN_URL=http://localhost:8080 --run test/Cloud_Tests'
21+
```
22+
23+
You can stop the server via Ctrl-C.
24+
25+
See [the server's documentation](../../tools/http-test-helper/README.md) for
26+
more information.
27+
28+
## Cloud tests
29+
30+
By default, a subset of cloud tests runs whenever the
31+
`ENSO_HTTP_TEST_HTTPBIN_URL` environment variable is set, using a mock of parts
32+
of the cloud logic running on the helper server.
33+
34+
To run a full set of cloud tests against a real deployment, you need to set the
35+
following 3 environment variables:
36+
37+
- `ENSO_CLOUD_API_URL` to point to the root of the cloud API,
38+
- `ENSO_CLOUD_CREDENTIALS_FILE` to be a path to a file containing the
39+
credentials to use, e.g. `~/.enso/credentials`,
40+
- `ENSO_RUN_REAL_CLOUD_TEST=1` to tell the test suite to run against a real
41+
cloud deployment.
42+
43+
Note that some cloud tests (e.g. testing secrets in HTTP requests) still require
44+
the `ENSO_HTTP_TEST_HTTPBIN_URL` setup, even if running against a real cloud
45+
deployment.
46+
47+
### Testing audit log batching
48+
49+
Currently, we only have a manual scenario for testing that log messages are
50+
actually batched.
51+
52+
To test it, launch the `http-test-helper` with additional
53+
`--enable-manual-log-batching-test` flag. For more information, see the comment
54+
on `batchingTestModeEnabled` in
55+
[PostLogHandler.java](../../tools/http-test-helper/src/main/java/org/enso/shttp/cloud_mock/PostLogHandler.java).

test/Cloud_Tests/data/books.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[
2+
{
3+
"title": "Lord of the Rings",
4+
"author": {
5+
"name": "J. R. R. Tolkien",
6+
"year_of_birth": 1892
7+
}
8+
},
9+
{
10+
"title": "The Little Prince",
11+
"author": {
12+
"name": "Antoine de Saint-Exupéry",
13+
"year_of_birth": 1900
14+
}
15+
},
16+
{
17+
"title": "And Then There Were None",
18+
"author": {
19+
"name": "Agatha Christie",
20+
"year_of_birth": 1890
21+
}
22+
}
23+
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "Enso_File",
3+
"libraryName": "Standard.Base",
4+
"path": "enso://Teams/PLACEHOLDER_TEAM_NAME/PLACEHOLDER_PATH"
5+
}

0 commit comments

Comments
 (0)