diff --git a/.builder/actions/aws_crt_java_test.py b/.builder/actions/aws_crt_java_test.py index f1d308d19..239096928 100644 --- a/.builder/actions/aws_crt_java_test.py +++ b/.builder/actions/aws_crt_java_test.py @@ -11,6 +11,8 @@ def _run_java_tests(self, *extra_args): os.remove('log.txt') profiles = 'continuous-integration' + if os.getenv("AWS_GRAALVM_CI") is not None: + profiles = 'graalvm-native' cmd_args = [ "mvn", "-B", @@ -20,7 +22,7 @@ def _run_java_tests(self, *extra_args): "-Daws.crt.memory.tracing=2", "-Daws.crt.debugnative=true", "-Daws.crt.aws_trace_log_per_test", - "-Daws.crt.ci=true", + "-Daws.crt.ci=true" ] cmd_args.extend(extra_args) cmd_args.append("test") @@ -40,18 +42,25 @@ def start_maven_tests(self, env): self._run_java_tests("-DrerunFailingTestsCount=5") - # run the ShutdownTest by itself - env.shell.setenv('AWS_CRT_SHUTDOWN_TESTING', '1') - self._run_java_tests("-Dtest=ShutdownTest") + if os.getenv("AWS_GRAALVM_CI") is None: + # not running separate test for GraalVM, because GraalVM needs + # rebuild to have separate test to run and rebuild will fail the MQTT tests. + # because currently builder will pull the MQTT related cert/private to the + # `cmake-build` directory and it will be removed after rebuild :) + # also those tests mostly for JVM, which is not very meaning for GraalVM, skip them. - # run the InitTest by itself. This creates an environment where the test itself is the one that - # causes the CRT to be loaded and initialized. - self._run_java_tests("-Dtest=InitTest") + # run the ShutdownTest by itself + env.shell.setenv('AWS_CRT_SHUTDOWN_TESTING', '1') + self._run_java_tests("-Dtest=ShutdownTest") - # run the elasticurl integration tests - python = sys.executable - env.shell.exec(python, 'crt/aws-c-http/integration-testing/http_client_test.py', - python, 'integration-testing/java_elasticurl_runner.py', check=True) + # run the InitTest by itself. This creates an environment where the test itself is the one that + # causes the CRT to be loaded and initialized. + self._run_java_tests("-Dtest=InitTest") + + # run the elasticurl integration tests + python = sys.executable + env.shell.exec(python, 'crt/aws-c-http/integration-testing/http_client_test.py', + python, 'integration-testing/java_elasticurl_runner.py', check=True) def run(self, env): self.env = env diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f445bdfd..e211e92e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -364,3 +364,27 @@ jobs: Start-Process -NoNewWindow python .\non_tls_server.py python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" python builder.pyz localhost-test -p ${{ env.PACKAGE_NAME }} downstream + + + GraalVM: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + java-version: ['22', '21', '17'] + steps: + - name: Checkout Sources + uses: actions/checkout@v2 + with: + submodules: true + - name: Setup GraalVM + uses: graalvm/setup-graalvm@v1 + with: + java-version: ${{ matrix.java-version }} + distribution: 'graalvm' + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Build ${{ env.PACKAGE_NAME }} + consumers + run: | + python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" + python builder.pyz build -p ${{ env.PACKAGE_NAME }} --variant=graalvm downstream diff --git a/.gitignore b/.gitignore index e8e8aef6e..253b8e165 100644 --- a/.gitignore +++ b/.gitignore @@ -31,7 +31,6 @@ Vagrantfile doxygen/html/ doxygen/latex/ - #cmake artifacts dependencies _build @@ -96,3 +95,5 @@ log.txt # docs are updated automatically by .github/workflows/docs.yml docs/ +# graalvm manually generated config files +graalvm-configuration diff --git a/builder.json b/builder.json index 92b5e126b..2f205dd9f 100644 --- a/builder.json +++ b/builder.json @@ -142,5 +142,16 @@ "mvn -B test -DrerunFailingTestsCount=5" ] } + }, + "variants":{ + "graalvm": { + "!packages": [], + "!imports": [ + ], + "!test_env": { + "AWS_GRAALVM_CI": true + }, + "!build_env": {} + } } } diff --git a/pom.xml b/pom.xml index 3178ba924..a9742f0c4 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,7 @@ -DOSX_ARCH_DUMMY=1 -DOSX_DEPLOYMENT_TARGET_DUMMY=1 OFF + 2.21.0 @@ -214,6 +215,42 @@ + + graalvm-native + + + + org.graalvm.buildtools + native-maven-plugin + 0.10.2 + true + + + test-native + + test + + test + + + + + true + + aws-crt-java + + --no-fallback + --initialize-at-build-time=org.junit.Ignore,java.lang.annotation.Annotation,org.junit.runners.model.FrameworkField + --verbose + + + + + + + 3.2.3 + + release @@ -292,7 +329,14 @@ junit junit - 4.13.1 + 4.13.2 + test + + + + org.junit.vintage + junit-vintage-engine + 5.10.2 test @@ -320,6 +364,10 @@ **/*.a + + + src/main/resources + @@ -410,7 +458,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.21.0 + ${maven-surefire-plugin.version} ${crt.classifier} diff --git a/src/main/resources/META-INF/native-image/software.amazon.awssdk/crt/aws-crt/jni-config.json b/src/main/resources/META-INF/native-image/software.amazon.awssdk/crt/aws-crt/jni-config.json new file mode 100644 index 000000000..d69cb7f3c --- /dev/null +++ b/src/main/resources/META-INF/native-image/software.amazon.awssdk/crt/aws-crt/jni-config.json @@ -0,0 +1,2125 @@ +[ + { + "name": "[Lsoftware.amazon.awssdk.crt.SystemInfo$CpuInfo;" + }, + { + "name": "java.lang.Boolean", + "methods": [ + { + "name": "", + "parameterTypes": [ + "boolean" + ] + }, + { + "name": "booleanValue", + "parameterTypes": [] + }, + { + "name": "getBoolean", + "parameterTypes": [ + "java.lang.String" + ] + } + ] + }, + { + "name": "java.lang.Integer", + "methods": [ + { + "name": "", + "parameterTypes": [ + "int" + ] + }, + { + "name": "intValue", + "parameterTypes": [] + } + ] + }, + { + "name": "java.lang.Long", + "methods": [ + { + "name": "", + "parameterTypes": [ + "long" + ] + }, + { + "name": "longValue", + "parameterTypes": [] + } + ] + }, + { + "name": "java.lang.NullPointerException", + "methods": [ + { + "name": "", + "parameterTypes": [ + "java.lang.String" + ] + } + ] + }, + { + "name": "java.lang.String", + "methods": [ + { + "name": "lastIndexOf", + "parameterTypes": [ + "int" + ] + }, + { + "name": "substring", + "parameterTypes": [ + "int" + ] + } + ] + }, + { + "name": "java.lang.System", + "methods": [ + { + "name": "getProperty", + "parameterTypes": [ + "java.lang.String" + ] + }, + { + "name": "setProperty", + "parameterTypes": [ + "java.lang.String", + "java.lang.String" + ] + } + ] + }, + { + "name": "java.nio.Buffer", + "methods": [ + { + "name": "capacity", + "parameterTypes": [] + }, + { + "name": "limit", + "parameterTypes": [] + }, + { + "name": "position", + "parameterTypes": [] + }, + { + "name": "remaining", + "parameterTypes": [] + } + ] + }, + { + "name": "java.nio.ByteBuffer", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "java.util.ArrayList", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "java.util.List", + "methods": [ + { + "name": "add", + "parameterTypes": [ + "java.lang.Object" + ] + }, + { + "name": "get", + "parameterTypes": [ + "int" + ] + }, + { + "name": "size", + "parameterTypes": [] + } + ] + }, + { + "name": "java.util.concurrent.CompletableFuture", + "methods": [ + { + "name": "complete", + "parameterTypes": [ + "java.lang.Object" + ] + }, + { + "name": "completeExceptionally", + "parameterTypes": [ + "java.lang.Throwable" + ] + } + ] + }, + { + "name": "java.util.function.Predicate", + "methods": [ + { + "name": "test", + "parameterTypes": [ + "java.lang.Object" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.AsyncCallback", + "methods": [ + { + "name": "onFailure", + "parameterTypes": [ + "java.lang.Throwable" + ] + }, + { + "name": "onSuccess", + "parameterTypes": [] + }, + { + "name": "onSuccess", + "parameterTypes": [ + "java.lang.Object" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.CRT", + "methods": [ + { + "name": "testJniException", + "parameterTypes": [ + "boolean" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.CrtResource", + "methods": [ + { + "name": "addRef", + "parameterTypes": [] + }, + { + "name": "close", + "parameterTypes": [] + }, + { + "name": "getNativeHandle", + "parameterTypes": [] + }, + { + "name": "releaseReferences", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.CrtRuntimeException", + "fields": [ + { + "name": "errorCode" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [ + "int" + ] + }, + { + "name": "", + "parameterTypes": [ + "java.lang.String" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.SystemInfo$CpuInfo", + "methods": [ + { + "name": "", + "parameterTypes": [ + "int", + "boolean" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.auth.credentials.Credentials", + "fields": [ + { + "name": "accessKeyId" + }, + { + "name": "expirationTimePointSecs" + }, + { + "name": "secretAccessKey" + }, + { + "name": "sessionToken" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.auth.credentials.CredentialsProvider", + "methods": [ + { + "name": "onGetCredentialsComplete", + "parameterTypes": [ + "java.util.concurrent.CompletableFuture", + "software.amazon.awssdk.crt.auth.credentials.Credentials" + ] + }, + { + "name": "onShutdownComplete", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.auth.credentials.DelegateCredentialsHandler", + "methods": [ + { + "name": "getCredentials", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.auth.signing.AwsSigningConfig", + "fields": [ + { + "name": "algorithm" + }, + { + "name": "credentials" + }, + { + "name": "credentialsProvider" + }, + { + "name": "expirationInSeconds" + }, + { + "name": "omitSessionToken" + }, + { + "name": "region" + }, + { + "name": "service" + }, + { + "name": "shouldNormalizeUriPath" + }, + { + "name": "shouldSignHeader" + }, + { + "name": "signatureType" + }, + { + "name": "signedBodyHeader" + }, + { + "name": "signedBodyValue" + }, + { + "name": "time" + }, + { + "name": "useDoubleUriEncode" + } + ] + }, + { + "name": "software.amazon.awssdk.crt.auth.signing.AwsSigningResult", + "fields": [ + { + "name": "signature" + }, + { + "name": "signedRequest" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.cal.EccKeyPair", + "methods": [ + { + "name": "", + "parameterTypes": [ + "long" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.eventstream.ClientConnectionContinuationHandler", + "methods": [ + { + "name": "onContinuationClosedShim", + "parameterTypes": [] + }, + { + "name": "onContinuationMessageShim", + "parameterTypes": [ + "byte[]", + "byte[]", + "int", + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.eventstream.ClientConnectionHandler", + "methods": [ + { + "name": "onConnectionClosedShim", + "parameterTypes": [ + "int" + ] + }, + { + "name": "onConnectionSetupShim", + "parameterTypes": [ + "long", + "int" + ] + }, + { + "name": "onProtocolMessage", + "parameterTypes": [ + "byte[]", + "byte[]", + "int", + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.eventstream.MessageFlushCallback", + "methods": [ + { + "name": "onCallbackInvoked", + "parameterTypes": [ + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.eventstream.ServerConnection", + "methods": [ + { + "name": "", + "parameterTypes": [ + "long" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.eventstream.ServerConnectionContinuation", + "methods": [ + { + "name": "", + "parameterTypes": [ + "long" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.eventstream.ServerConnectionContinuationHandler", + "methods": [ + { + "name": "onContinuationClosedShim", + "parameterTypes": [] + }, + { + "name": "onContinuationMessageShim", + "parameterTypes": [ + "byte[]", + "byte[]", + "int", + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.eventstream.ServerConnectionHandler", + "methods": [ + { + "name": "onIncomingStream", + "parameterTypes": [ + "software.amazon.awssdk.crt.eventstream.ServerConnectionContinuation", + "byte[]" + ] + }, + { + "name": "onProtocolMessage", + "parameterTypes": [ + "byte[]", + "byte[]", + "int", + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.eventstream.ServerListener", + "methods": [ + { + "name": "onShutdownComplete", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.eventstream.ServerListenerHandler", + "methods": [ + { + "name": "onConnectionShutdownShim", + "parameterTypes": [ + "software.amazon.awssdk.crt.eventstream.ServerConnection", + "int" + ] + }, + { + "name": "onNewConnection", + "parameterTypes": [ + "software.amazon.awssdk.crt.eventstream.ServerConnection", + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.Http2Stream", + "methods": [ + { + "name": "", + "parameterTypes": [ + "long" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.Http2StreamManager", + "methods": [ + { + "name": "onShutdownComplete", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.HttpClientConnection", + "methods": [ + { + "name": "onConnectionAcquired", + "parameterTypes": [ + "java.util.concurrent.CompletableFuture", + "long", + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.HttpClientConnectionManager", + "methods": [ + { + "name": "onShutdownComplete", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.HttpHeader", + "methods": [ + { + "name": "", + "parameterTypes": [ + "byte[]", + "byte[]" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.HttpManagerMetrics", + "methods": [ + { + "name": "", + "parameterTypes": [ + "long", + "long", + "long" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.HttpProxyOptions", + "methods": [ + { + "name": "getAuthorizationPassword", + "parameterTypes": [] + }, + { + "name": "getAuthorizationType", + "parameterTypes": [] + }, + { + "name": "getAuthorizationUsername", + "parameterTypes": [] + }, + { + "name": "getConnectionType", + "parameterTypes": [] + }, + { + "name": "getHost", + "parameterTypes": [] + }, + { + "name": "getPort", + "parameterTypes": [] + }, + { + "name": "getTlsContext", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.HttpProxyOptions$HttpProxyConnectionType", + "methods": [ + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.HttpRequest", + "methods": [ + { + "name": "", + "parameterTypes": [ + "java.nio.ByteBuffer", + "software.amazon.awssdk.crt.http.HttpRequestBodyStream" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.HttpRequestBase", + "fields": [ + { + "name": "bodyStream" + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.HttpRequestBodyStream", + "methods": [ + { + "name": "getLength", + "parameterTypes": [] + }, + { + "name": "resetPosition", + "parameterTypes": [] + }, + { + "name": "sendRequestBody", + "parameterTypes": [ + "java.nio.ByteBuffer" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.HttpStream", + "methods": [ + { + "name": "", + "parameterTypes": [ + "long" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.HttpStream$HttpStreamWriteChunkCompletionCallback", + "methods": [ + { + "name": "onChunkCompleted", + "parameterTypes": [ + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.HttpStreamMetrics", + "methods": [ + { + "name": "", + "parameterTypes": [ + "long", + "long", + "long", + "long", + "long", + "long", + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.HttpStreamResponseHandlerNativeAdapter", + "methods": [ + { + "name": "onMetrics", + "parameterTypes": [ + "software.amazon.awssdk.crt.http.HttpStreamBase", + "software.amazon.awssdk.crt.http.HttpStreamMetrics" + ] + }, + { + "name": "onResponseBody", + "parameterTypes": [ + "software.amazon.awssdk.crt.http.HttpStreamBase", + "java.nio.ByteBuffer" + ] + }, + { + "name": "onResponseComplete", + "parameterTypes": [ + "software.amazon.awssdk.crt.http.HttpStreamBase", + "int" + ] + }, + { + "name": "onResponseHeaders", + "parameterTypes": [ + "software.amazon.awssdk.crt.http.HttpStreamBase", + "int", + "int", + "java.nio.ByteBuffer" + ] + }, + { + "name": "onResponseHeadersDone", + "parameterTypes": [ + "software.amazon.awssdk.crt.http.HttpStreamBase", + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.io.ClientBootstrap", + "methods": [ + { + "name": "onShutdownComplete", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.io.DirectoryEntry", + "fields": [ + { + "name": "fileSize" + }, + { + "name": "isDirectory" + }, + { + "name": "isFile" + }, + { + "name": "isSymLink" + }, + { + "name": "path" + }, + { + "name": "relativePath" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.io.DirectoryTraversalHandler", + "methods": [ + { + "name": "onDirectoryEntry", + "parameterTypes": [ + "software.amazon.awssdk.crt.io.DirectoryEntry" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.io.EventLoopGroup", + "methods": [ + { + "name": "onCleanupComplete", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.io.ExponentialBackoffRetryOptions", + "fields": [ + { + "name": "backoffScaleFactorMS" + }, + { + "name": "eventLoopGroup" + }, + { + "name": "jitterMode" + }, + { + "name": "maxRetries" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.io.ExponentialBackoffRetryOptions$JitterMode", + "fields": [ + { + "name": "value" + } + ], + "methods": [ + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.io.StandardRetryOptions", + "fields": [ + { + "name": "backoffRetryOptions" + }, + { + "name": "initialBucketCapacity" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.io.TlsContextCustomKeyOperationOptions", + "fields": [ + { + "name": "certificateFileContents" + }, + { + "name": "certificateFilePath" + }, + { + "name": "operationHandler" + } + ] + }, + { + "name": "software.amazon.awssdk.crt.io.TlsContextPkcs11Options", + "fields": [ + { + "name": "certificateFileContents" + }, + { + "name": "certificateFilePath" + }, + { + "name": "pkcs11Lib" + }, + { + "name": "privateKeyObjectLabel" + }, + { + "name": "slotId" + }, + { + "name": "tokenLabel" + }, + { + "name": "userPin" + } + ] + }, + { + "name": "software.amazon.awssdk.crt.io.TlsKeyOperation", + "methods": [ + { + "name": "", + "parameterTypes": [ + "long", + "byte[]", + "int", + "int", + "int" + ] + }, + { + "name": "invokePerformOperation", + "parameterTypes": [ + "software.amazon.awssdk.crt.io.TlsKeyOperationHandler", + "software.amazon.awssdk.crt.io.TlsKeyOperation" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.io.TlsKeyOperationHandler", + "methods": [ + { + "name": "performOperation", + "parameterTypes": [ + "software.amazon.awssdk.crt.io.TlsKeyOperation" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt.MqttClientConnection", + "methods": [ + { + "name": "onConnectionClosed", + "parameterTypes": [] + }, + { + "name": "onConnectionComplete", + "parameterTypes": [ + "int", + "boolean" + ] + }, + { + "name": "onConnectionFailure", + "parameterTypes": [ + "int" + ] + }, + { + "name": "onConnectionInterrupted", + "parameterTypes": [ + "int", + "software.amazon.awssdk.crt.AsyncCallback" + ] + }, + { + "name": "onConnectionResumed", + "parameterTypes": [ + "boolean" + ] + }, + { + "name": "onConnectionSuccess", + "parameterTypes": [ + "boolean" + ] + }, + { + "name": "onWebsocketHandshake", + "parameterTypes": [ + "software.amazon.awssdk.crt.http.HttpRequest", + "long" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt.MqttClientConnection$MessageHandler", + "methods": [ + { + "name": "deliver", + "parameterTypes": [ + "java.lang.String", + "byte[]", + "boolean", + "int", + "boolean" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt.MqttClientConnectionOperationStatistics", + "fields": [ + { + "name": "incompleteOperationCount" + }, + { + "name": "incompleteOperationSize" + }, + { + "name": "unackedOperationCount" + }, + { + "name": "unackedOperationSize" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt.MqttException", + "methods": [ + { + "name": "", + "parameterTypes": [ + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.Mqtt5Client", + "fields": [ + { + "name": "websocketHandshakeTransform" + } + ], + "methods": [ + { + "name": "onWebsocketHandshake", + "parameterTypes": [ + "software.amazon.awssdk.crt.http.HttpRequest", + "long" + ] + }, + { + "name": "setIsConnected", + "parameterTypes": [ + "boolean" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.Mqtt5ClientOperationStatistics", + "fields": [ + { + "name": "incompleteOperationCount" + }, + { + "name": "incompleteOperationSize" + }, + { + "name": "unackedOperationCount" + }, + { + "name": "unackedOperationSize" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.Mqtt5ClientOptions", + "fields": [ + { + "name": "ackTimeoutSeconds" + }, + { + "name": "connackTimeoutMs" + }, + { + "name": "extendedValidationAndFlowControlOptions" + }, + { + "name": "hostName" + }, + { + "name": "httpProxyOptions" + }, + { + "name": "lifecycleEvents" + }, + { + "name": "maxReconnectDelayMs" + }, + { + "name": "minConnectedTimeToResetReconnectDelayMs" + }, + { + "name": "minReconnectDelayMs" + }, + { + "name": "offlineQueueBehavior" + }, + { + "name": "pingTimeoutMs" + }, + { + "name": "port" + }, + { + "name": "publishEvents" + }, + { + "name": "retryJitterMode" + }, + { + "name": "sessionBehavior" + }, + { + "name": "topicAliasingOptions" + } + ], + "methods": [ + { + "name": "getBootstrap", + "parameterTypes": [] + }, + { + "name": "getExtendedValidationAndFlowControlOptions", + "parameterTypes": [] + }, + { + "name": "getOfflineQueueBehavior", + "parameterTypes": [] + }, + { + "name": "getRetryJitterMode", + "parameterTypes": [] + }, + { + "name": "getSessionBehavior", + "parameterTypes": [] + }, + { + "name": "getSocketOptions", + "parameterTypes": [] + }, + { + "name": "getTlsContext", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.Mqtt5ClientOptions$ClientOfflineQueueBehavior", + "methods": [ + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.Mqtt5ClientOptions$ClientSessionBehavior", + "methods": [ + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.Mqtt5ClientOptions$ExtendedValidationAndFlowControlOptions", + "methods": [ + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.Mqtt5ClientOptions$LifecycleEvents", + "methods": [ + { + "name": "onAttemptingConnect", + "parameterTypes": [ + "software.amazon.awssdk.crt.mqtt5.Mqtt5Client", + "software.amazon.awssdk.crt.mqtt5.OnAttemptingConnectReturn" + ] + }, + { + "name": "onConnectionFailure", + "parameterTypes": [ + "software.amazon.awssdk.crt.mqtt5.Mqtt5Client", + "software.amazon.awssdk.crt.mqtt5.OnConnectionFailureReturn" + ] + }, + { + "name": "onConnectionSuccess", + "parameterTypes": [ + "software.amazon.awssdk.crt.mqtt5.Mqtt5Client", + "software.amazon.awssdk.crt.mqtt5.OnConnectionSuccessReturn" + ] + }, + { + "name": "onDisconnection", + "parameterTypes": [ + "software.amazon.awssdk.crt.mqtt5.Mqtt5Client", + "software.amazon.awssdk.crt.mqtt5.OnDisconnectionReturn" + ] + }, + { + "name": "onStopped", + "parameterTypes": [ + "software.amazon.awssdk.crt.mqtt5.Mqtt5Client", + "software.amazon.awssdk.crt.mqtt5.OnStoppedReturn" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.Mqtt5ClientOptions$PublishEvents", + "methods": [ + { + "name": "onMessageReceived", + "parameterTypes": [ + "software.amazon.awssdk.crt.mqtt5.Mqtt5Client", + "software.amazon.awssdk.crt.mqtt5.PublishReturn" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.NegotiatedSettings", + "fields": [ + { + "name": "assignedClientID" + }, + { + "name": "maximumPacketSizeToServer" + }, + { + "name": "maximumQOS" + }, + { + "name": "receiveMaximumFromServer" + }, + { + "name": "rejoinedSession" + }, + { + "name": "retainAvailable" + }, + { + "name": "serverKeepAlive" + }, + { + "name": "sessionExpiryInterval" + }, + { + "name": "sharedSubscriptionsAvailable" + }, + { + "name": "subscriptionIdentifiersAvailable" + }, + { + "name": "topicAliasMaximumToClient" + }, + { + "name": "topicAliasMaximumToServer" + }, + { + "name": "wildcardSubscriptionsAvailable" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + }, + { + "name": "nativeSetQOS", + "parameterTypes": [ + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.OnAttemptingConnectReturn", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.OnConnectionFailureReturn", + "methods": [ + { + "name": "", + "parameterTypes": [ + "int", + "software.amazon.awssdk.crt.mqtt5.packets.ConnAckPacket" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.OnConnectionSuccessReturn", + "methods": [ + { + "name": "", + "parameterTypes": [ + "software.amazon.awssdk.crt.mqtt5.packets.ConnAckPacket", + "software.amazon.awssdk.crt.mqtt5.NegotiatedSettings" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.OnDisconnectionReturn", + "methods": [ + { + "name": "", + "parameterTypes": [ + "int", + "software.amazon.awssdk.crt.mqtt5.packets.DisconnectPacket" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.OnStoppedReturn", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.PublishResult", + "methods": [ + { + "name": "", + "parameterTypes": [] + }, + { + "name": "", + "parameterTypes": [ + "software.amazon.awssdk.crt.mqtt5.packets.PubAckPacket" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.PublishReturn", + "methods": [ + { + "name": "", + "parameterTypes": [ + "software.amazon.awssdk.crt.mqtt5.packets.PublishPacket" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.QOS", + "methods": [ + { + "name": "getEnumValueFromInteger", + "parameterTypes": [ + "int" + ] + }, + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.TopicAliasingOptions", + "fields": [ + { + "name": "inboundBehavior" + }, + { + "name": "inboundCacheMaxSize" + }, + { + "name": "outboundBehavior" + }, + { + "name": "outboundCacheMaxSize" + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.TopicAliasingOptions$InboundTopicAliasBehaviorType", + "methods": [ + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.TopicAliasingOptions$OutboundTopicAliasBehaviorType", + "methods": [ + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.ConnAckPacket", + "fields": [ + { + "name": "assignedClientIdentifier" + }, + { + "name": "maximumPacketSize" + }, + { + "name": "maximumQOS" + }, + { + "name": "reasonCode" + }, + { + "name": "reasonString" + }, + { + "name": "receiveMaximum" + }, + { + "name": "responseInformation" + }, + { + "name": "retainAvailable" + }, + { + "name": "serverKeepAlive" + }, + { + "name": "serverReference" + }, + { + "name": "sessionExpiryIntervalSeconds" + }, + { + "name": "sessionPresent" + }, + { + "name": "sharedSubscriptionsAvailable" + }, + { + "name": "subscriptionIdentifiersAvailable" + }, + { + "name": "topicAliasMaximum" + }, + { + "name": "userProperties" + }, + { + "name": "wildcardSubscriptionsAvailable" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + }, + { + "name": "nativeAddMaximumQOS", + "parameterTypes": [ + "int" + ] + }, + { + "name": "nativeAddReasonCode", + "parameterTypes": [ + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.ConnAckPacket$ConnectReasonCode", + "methods": [ + { + "name": "getEnumValueFromInteger", + "parameterTypes": [ + "int" + ] + }, + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.ConnectPacket", + "fields": [ + { + "name": "clientId" + }, + { + "name": "keepAliveIntervalSeconds" + }, + { + "name": "maximumPacketSizeBytes" + }, + { + "name": "password" + }, + { + "name": "receiveMaximum" + }, + { + "name": "requestProblemInformation" + }, + { + "name": "requestResponseInformation" + }, + { + "name": "sessionExpiryIntervalSeconds" + }, + { + "name": "userProperties" + }, + { + "name": "username" + }, + { + "name": "will" + }, + { + "name": "willDelayIntervalSeconds" + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.DisconnectPacket", + "fields": [ + { + "name": "reasonCode" + }, + { + "name": "reasonString" + }, + { + "name": "serverReference" + }, + { + "name": "sessionExpiryIntervalSeconds" + }, + { + "name": "userProperties" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + }, + { + "name": "getReasonCode", + "parameterTypes": [] + }, + { + "name": "nativeAddDisconnectReasonCode", + "parameterTypes": [ + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.DisconnectPacket$DisconnectReasonCode", + "methods": [ + { + "name": "getEnumValueFromInteger", + "parameterTypes": [ + "int" + ] + }, + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.PubAckPacket", + "fields": [ + { + "name": "reasonCode" + }, + { + "name": "reasonString" + }, + { + "name": "userProperties" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + }, + { + "name": "nativeAddReasonCode", + "parameterTypes": [ + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.PubAckPacket$PubAckReasonCode", + "methods": [ + { + "name": "getEnumValueFromInteger", + "parameterTypes": [ + "int" + ] + }, + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.PublishPacket", + "fields": [ + { + "name": "contentType" + }, + { + "name": "correlationData" + }, + { + "name": "messageExpiryIntervalSeconds" + }, + { + "name": "packetQOS" + }, + { + "name": "payload" + }, + { + "name": "payloadFormat" + }, + { + "name": "responseTopic" + }, + { + "name": "retain" + }, + { + "name": "subscriptionIdentifiers" + }, + { + "name": "topic" + }, + { + "name": "topicAlias" + }, + { + "name": "userProperties" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + }, + { + "name": "getPayloadFormat", + "parameterTypes": [] + }, + { + "name": "getQOS", + "parameterTypes": [] + }, + { + "name": "nativeSetPayloadFormatIndicator", + "parameterTypes": [ + "int" + ] + }, + { + "name": "nativeSetQOS", + "parameterTypes": [ + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.PublishPacket$PayloadFormatIndicator", + "methods": [ + { + "name": "getEnumValueFromInteger", + "parameterTypes": [ + "int" + ] + }, + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.SubAckPacket", + "fields": [ + { + "name": "reasonCodes" + }, + { + "name": "reasonString" + }, + { + "name": "userProperties" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + }, + { + "name": "nativeAddSubackCode", + "parameterTypes": [ + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.SubAckPacket$SubAckReasonCode", + "methods": [ + { + "name": "getEnumValueFromInteger", + "parameterTypes": [ + "int" + ] + }, + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.SubscribePacket", + "fields": [ + { + "name": "subscriptionIdentifier" + }, + { + "name": "subscriptions" + }, + { + "name": "userProperties" + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.SubscribePacket$RetainHandlingType", + "methods": [ + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.SubscribePacket$Subscription", + "fields": [ + { + "name": "noLocal" + }, + { + "name": "retainAsPublished" + } + ], + "methods": [ + { + "name": "getNoLocal", + "parameterTypes": [] + }, + { + "name": "getQOS", + "parameterTypes": [] + }, + { + "name": "getRetainAsPublished", + "parameterTypes": [] + }, + { + "name": "getRetainHandlingType", + "parameterTypes": [] + }, + { + "name": "getTopicFilter", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.UnsubAckPacket", + "fields": [ + { + "name": "reasonCodes" + }, + { + "name": "reasonString" + }, + { + "name": "userProperties" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + }, + { + "name": "nativeAddUnsubackCode", + "parameterTypes": [ + "int" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.UnsubAckPacket$UnsubAckReasonCode", + "methods": [ + { + "name": "getEnumValueFromInteger", + "parameterTypes": [ + "int" + ] + }, + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.UnsubscribePacket", + "fields": [ + { + "name": "subscriptions" + }, + { + "name": "userProperties" + } + ] + }, + { + "name": "software.amazon.awssdk.crt.mqtt5.packets.UserProperty", + "fields": [ + { + "name": "key" + }, + { + "name": "value" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [ + "java.lang.String", + "java.lang.String" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.s3.ResumeToken", + "fields": [ + { + "name": "nativeType" + }, + { + "name": "numPartsCompleted" + }, + { + "name": "partSize" + }, + { + "name": "totalNumParts" + }, + { + "name": "uploadId" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.s3.S3Client", + "methods": [ + { + "name": "onShutdownComplete", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.s3.S3ExpressCredentialsProperties", + "fields": [ + { + "name": "hostValue" + }, + { + "name": "region" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.s3.S3ExpressCredentialsProvider", + "methods": [ + { + "name": "destroyProvider", + "parameterTypes": [] + }, + { + "name": "getS3ExpressCredentials", + "parameterTypes": [ + "software.amazon.awssdk.crt.s3.S3ExpressCredentialsProperties", + "software.amazon.awssdk.crt.auth.credentials.Credentials", + "long" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.s3.S3ExpressCredentialsProviderFactory", + "methods": [ + { + "name": "createS3ExpressCredentialsProvider", + "parameterTypes": [ + "software.amazon.awssdk.crt.s3.S3Client" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.s3.S3MetaRequest", + "methods": [ + { + "name": "onShutdownComplete", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.s3.S3MetaRequestProgress", + "fields": [ + { + "name": "bytesTransferred" + }, + { + "name": "contentLength" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.http.HttpProxyOptions$HttpProxyAuthorizationType", + "methods": [ + { + "name": "getValue", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.s3.S3MetaRequestResponseHandlerNativeAdapter", + "methods": [ + { + "name": "onFinished", + "parameterTypes": [ + "int", + "int", + "byte[]", + "int", + "boolean", + "java.lang.Throwable", + "java.nio.ByteBuffer" + ] + }, + { + "name": "onProgress", + "parameterTypes": [ + "software.amazon.awssdk.crt.s3.S3MetaRequestProgress" + ] + }, + { + "name": "onResponseBody", + "parameterTypes": [ + "byte[]", + "long", + "long" + ] + }, + { + "name": "onResponseHeaders", + "parameterTypes": [ + "int", + "java.nio.ByteBuffer" + ] + } + ] + }, + { + "name": "software.amazon.awssdk.crt.s3.S3TcpKeepAliveOptions", + "fields": [ + { + "name": "keepAliveIntervalSec" + }, + { + "name": "keepAliveMaxFailedProbes" + }, + { + "name": "keepAliveTimeoutSec" + } + ], + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "sun.management.VMManagementImpl", + "fields": [ + { + "name": "compTimeMonitoringSupport" + }, + { + "name": "currentThreadCpuTimeSupport" + }, + { + "name": "objectMonitorUsageSupport" + }, + { + "name": "otherThreadCpuTimeSupport" + }, + { + "name": "remoteDiagnosticCommandsSupport" + }, + { + "name": "synchronizerUsageSupport" + }, + { + "name": "threadAllocatedMemorySupport" + }, + { + "name": "threadContentionMonitoringSupport" + } + ] + } +] \ No newline at end of file diff --git a/src/main/resources/META-INF/native-image/software.amazon.awssdk/crt/aws-crt/reflect-config.json b/src/main/resources/META-INF/native-image/software.amazon.awssdk/crt/aws-crt/reflect-config.json new file mode 100644 index 000000000..5a5cc188f --- /dev/null +++ b/src/main/resources/META-INF/native-image/software.amazon.awssdk/crt/aws-crt/reflect-config.json @@ -0,0 +1,9 @@ +[ + { + "condition": { + "typeReachable": "org.junit.Assume" + }, + "name": "org.hamcrest.core.Every", + "queryAllDeclaredMethods": true + } +] \ No newline at end of file diff --git a/src/main/resources/META-INF/native-image/software.amazon.awssdk/crt/aws-crt/resource-config.json b/src/main/resources/META-INF/native-image/software.amazon.awssdk/crt/aws-crt/resource-config.json new file mode 100644 index 000000000..7fefd172c --- /dev/null +++ b/src/main/resources/META-INF/native-image/software.amazon.awssdk/crt/aws-crt/resource-config.json @@ -0,0 +1,16 @@ +{ + "resources": { + "includes": [ + { + "pattern": ".*libaws-crt-jni.dylib" + }, + { + "pattern": ".*libaws-crt-jni.so" + }, + { + "pattern": ".*aws-crt-jni.dll" + } + ] + }, + "bundles": [] +} \ No newline at end of file diff --git a/src/test/android/testapp/src/androidTest/java/software/amazon/awssdk/crt/test/android/CrtPlatformImpl.java b/src/test/android/testapp/src/androidTest/java/software/amazon/awssdk/crt/test/android/CrtPlatformImpl.java index 2cced91bb..33a09d538 100644 --- a/src/test/android/testapp/src/androidTest/java/software/amazon/awssdk/crt/test/android/CrtPlatformImpl.java +++ b/src/test/android/testapp/src/androidTest/java/software/amazon/awssdk/crt/test/android/CrtPlatformImpl.java @@ -90,6 +90,7 @@ public void setupOnce(){ // Indicate system properties are already set for future tests System.setProperty("are.test.properties.setup", "true"); + System.setProperty("AWS_GRAALVM_CI", "True"); System.setProperty("AWS_TEST_IS_CI", "True"); SetPropertyFromFile("AWS_TEST_MQTT5_IOT_CORE_HOST", "AWS_TEST_MQTT5_IOT_CORE_HOST.txt"); @@ -141,4 +142,3 @@ public void testSetup(Object context) { public void testTearDown(Object context) { } } - diff --git a/src/test/java/software/amazon/awssdk/crt/test/CrtTestFixture.java b/src/test/java/software/amazon/awssdk/crt/test/CrtTestFixture.java index 0e49c8643..2e503fc5c 100644 --- a/src/test/java/software/amazon/awssdk/crt/test/CrtTestFixture.java +++ b/src/test/java/software/amazon/awssdk/crt/test/CrtTestFixture.java @@ -44,6 +44,7 @@ private static void SetPropertyFromEnv(String name) { // Setup System properties from environment variables set by builder for use by // unit tests. private static void SetupTestProperties() { + SetPropertyFromEnv("AWS_GRAALVM_CI"); SetPropertyFromEnv("AWS_TEST_IS_CI"); SetPropertyFromEnv("AWS_TEST_MQTT311_ROOT_CA"); SetPropertyFromEnv("ENDPOINT"); diff --git a/src/test/java/software/amazon/awssdk/crt/test/Http2StreamManagerTest.java b/src/test/java/software/amazon/awssdk/crt/test/Http2StreamManagerTest.java index e030d4d08..866ff866f 100644 --- a/src/test/java/software/amazon/awssdk/crt/test/Http2StreamManagerTest.java +++ b/src/test/java/software/amazon/awssdk/crt/test/Http2StreamManagerTest.java @@ -4,6 +4,14 @@ */ package software.amazon.awssdk.crt.test; +import org.junit.Assert; +import org.junit.Test; +import software.amazon.awssdk.crt.CRT; +import software.amazon.awssdk.crt.CrtResource; +import software.amazon.awssdk.crt.Log; +import software.amazon.awssdk.crt.http.*; +import software.amazon.awssdk.crt.io.*; + import java.net.URI; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; @@ -11,28 +19,12 @@ import java.util.List; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Test; -import software.amazon.awssdk.crt.CRT; -import software.amazon.awssdk.crt.CrtResource; -import software.amazon.awssdk.crt.CrtRuntimeException; -import software.amazon.awssdk.crt.http.*; -import software.amazon.awssdk.crt.io.ClientBootstrap; -import software.amazon.awssdk.crt.io.EventLoopGroup; -import software.amazon.awssdk.crt.io.HostResolver; -import software.amazon.awssdk.crt.io.SocketOptions; -import software.amazon.awssdk.crt.io.TlsContext; -import software.amazon.awssdk.crt.io.TlsContextOptions; -import software.amazon.awssdk.crt.Log; public class Http2StreamManagerTest extends HttpClientTestFixture { private final static Charset UTF8 = StandardCharsets.UTF_8; private final static int NUM_THREADS = 10; private final static int NUM_CONNECTIONS = 20; private final static int NUM_REQUESTS = 60; - private final static int NUM_ITERATIONS = 10; - private final static int GROWTH_PER_THREAD = 0; // expected VM footprint growth per thread private final static int EXPECTED_HTTP_STATUS = 200; private final static String endpoint = "https://d1cz66xoahf9cl.cloudfront.net/"; // Use cloudfront for HTTP/2 private final static String path = "/random_32_byte.data"; @@ -140,6 +132,7 @@ public void onResponseComplete(HttpStreamBase stream, int errorCode) { Assert.assertTrue(numStreamsFailures.get() <= allowedFailures); } + @Override public void testParallelRequests(int numThreads, int numRequests) throws Exception { skipIfNetworkUnavailable(); @@ -154,32 +147,6 @@ public void testParallelRequests(int numThreads, int numRequests) throws Excepti CrtResource.waitForNoResources(); } - public void testParallelRequestsWithLeakCheck(int numThreads, int numRequests) throws Exception { - skipIfNetworkUnavailable(); - Callable fn = () -> { - testParallelRequests(numThreads, numRequests); - return null; - }; - - // Dalvik is SUPER STOCHASTIC about when it frees JVM memory, it has no - // observable correlation - // to when System.gc() is called. Therefore, we cannot reliably sample it, so we - // don't bother. - // If we have a leak, we should have it on all platforms, and we'll catch it - // elsewhere. - if (CRT.getOSIdentifier() != "android") { - int fixedGrowth = CrtMemoryLeakDetector.expectedFixedGrowth(); - fixedGrowth += (numThreads * GROWTH_PER_THREAD); - // On Mac, JVM seems to expand by about 4K no matter how careful we are. With - // the workload - // we're running, 8K worth of growth (an additional 4K for an increased healthy - // margin) - // in the JVM only is acceptable. - fixedGrowth = Math.max(fixedGrowth, 8192); - CrtMemoryLeakDetector.leakCheck(NUM_ITERATIONS, fixedGrowth, fn); - } - } - @Test public void testSanitizer() throws Exception { skipIfAndroid(); diff --git a/src/test/java/software/amazon/awssdk/crt/test/HttpClientConnectionManagerTest.java b/src/test/java/software/amazon/awssdk/crt/test/HttpClientConnectionManagerTest.java index c7cf98c84..2c958d0f2 100644 --- a/src/test/java/software/amazon/awssdk/crt/test/HttpClientConnectionManagerTest.java +++ b/src/test/java/software/amazon/awssdk/crt/test/HttpClientConnectionManagerTest.java @@ -1,12 +1,10 @@ package software.amazon.awssdk.crt.test; import java.net.URI; -import java.net.URISyntaxException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; @@ -14,7 +12,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import org.junit.Assert; -import org.junit.Assume; import org.junit.Test; import software.amazon.awssdk.crt.CRT; import software.amazon.awssdk.crt.CrtResource; @@ -27,15 +24,12 @@ import software.amazon.awssdk.crt.io.TlsContext; import software.amazon.awssdk.crt.io.TlsConnectionOptions; import software.amazon.awssdk.crt.Log; -import software.amazon.awssdk.crt.io.TlsContextOptions; public class HttpClientConnectionManagerTest extends HttpClientTestFixture { private final static Charset UTF8 = StandardCharsets.UTF_8; private final static int NUM_THREADS = 10; private final static int NUM_CONNECTIONS = 20; private final static int NUM_REQUESTS = 60; - private final static int NUM_ITERATIONS = 10; - private final static int GROWTH_PER_THREAD = 0; // expected VM footprint growth per thread private final static int EXPECTED_HTTP_STATUS = 200; private final static String endpoint = "https://aws-crt-test-stuff.s3.amazonaws.com"; private final static String path = "/random_32_byte.data"; @@ -79,12 +73,12 @@ private void testParallelConnections(HttpClientConnectionManager connPool, HttpR final AtomicInteger numErrorCode = new AtomicInteger(0); final ExecutorService threadPool = Executors.newFixedThreadPool(numThreads); - List requestCompleteFutures = new ArrayList<>(); + List> requestCompleteFutures = new ArrayList<>(); for (int i = 0; i < numRequests; i++) { Log.log(Log.LogLevel.Trace, Log.LogSubject.HttpConnectionManager, String.format("Starting request %d", i)); - CompletableFuture requestCompleteFuture = new CompletableFuture(); + CompletableFuture requestCompleteFuture = new CompletableFuture(); requestCompleteFutures.add(requestCompleteFuture); threadPool.execute(() -> { @@ -130,7 +124,7 @@ public void onResponseComplete(HttpStream stream, int errorCode) { } // Wait for all Requests to complete - for (CompletableFuture f : requestCompleteFutures) { + for (CompletableFuture f : requestCompleteFutures) { f.join(); } @@ -144,6 +138,7 @@ public void onResponseComplete(HttpStream stream, int errorCode) { Assert.assertTrue(numConnectionFailures.get() <= allowedFailures); } + @Override public void testParallelRequests(int numThreads, int numRequests) throws Exception { skipIfNetworkUnavailable(); @@ -158,27 +153,6 @@ public void testParallelRequests(int numThreads, int numRequests) throws Excepti CrtResource.waitForNoResources(); } - public void testParallelRequestsWithLeakCheck(int numThreads, int numRequests) throws Exception { - skipIfNetworkUnavailable(); - Callable fn = () -> { - testParallelRequests(numThreads, numRequests); - return null; - }; - - // Dalvik is SUPER STOCHASTIC about when it frees JVM memory, it has no observable correlation - // to when System.gc() is called. Therefore, we cannot reliably sample it, so we don't bother. - // If we have a leak, we should have it on all platforms, and we'll catch it elsewhere. - if (CRT.getOSIdentifier() != "android") { - int fixedGrowth = CrtMemoryLeakDetector.expectedFixedGrowth(); - fixedGrowth += (numThreads * GROWTH_PER_THREAD); - // On Mac, JVM seems to expand by about 4K no matter how careful we are. With the workload - // we're running, 8K worth of growth (an additional 4K for an increased healthy margin) - // in the JVM only is acceptable. - fixedGrowth = Math.max(fixedGrowth, 8192); - CrtMemoryLeakDetector.leakCheck(NUM_ITERATIONS, fixedGrowth, fn); - } - } - @Test public void testSerialRequests() throws Exception { skipIfAndroid(); diff --git a/src/test/java/software/amazon/awssdk/crt/test/HttpClientTestFixture.java b/src/test/java/software/amazon/awssdk/crt/test/HttpClientTestFixture.java index 784ebad64..4013291ed 100644 --- a/src/test/java/software/amazon/awssdk/crt/test/HttpClientTestFixture.java +++ b/src/test/java/software/amazon/awssdk/crt/test/HttpClientTestFixture.java @@ -5,6 +5,7 @@ package software.amazon.awssdk.crt.test; +import software.amazon.awssdk.crt.CRT; import software.amazon.awssdk.crt.http.HttpClientConnectionManager; import software.amazon.awssdk.crt.http.HttpClientConnectionManagerOptions; import software.amazon.awssdk.crt.http.HttpVersion; @@ -16,8 +17,11 @@ import software.amazon.awssdk.crt.io.TlsContextOptions; import java.net.URI; +import java.util.concurrent.Callable; public class HttpClientTestFixture extends CrtTestFixture { + private final static int NUM_ITERATIONS = 10; + private final static int GROWTH_PER_THREAD = 0; // expected VM footprint growth per thread private HttpClientConnectionManager createHTTP2ConnectionPoolManager(URI uri) { try (EventLoopGroup eventLoopGroup = new EventLoopGroup(1); @@ -66,4 +70,36 @@ public HttpClientConnectionManager createConnectionPoolManager(URI uri, } } + + public void testParallelRequests(int numThreads, int numRequests) throws Exception { + throw new UnsupportedOperationException("Only supported from override"); + } + + + protected void testParallelRequestsWithLeakCheck(int numThreads, int numRequests) throws Exception { + skipIfNetworkUnavailable(); + Callable fn = () -> { + testParallelRequests(numThreads, numRequests); + return null; + }; + + // For Android: Dalvik is SUPER STOCHASTIC about when it frees JVM memory, it has no + // observable correlation to when System.gc() is called. Therefore, we cannot reliably + // sample it, so we don't bother. + // For GraalVM: It's not using JVM, there is no reason to check the JVM memory. + // If we have a leak, we should have it on all platforms, and we'll catch it + // elsewhere. + if (CRT.getOSIdentifier() != "android" && System.getProperty("org.graalvm.nativeimage.imagecode") == null) { + int fixedGrowth = CrtMemoryLeakDetector.expectedFixedGrowth(); + fixedGrowth += (numThreads * GROWTH_PER_THREAD); + // On Mac, JVM seems to expand by about 4K no matter how careful we are. With + // the workload + // we're running, 8K worth of growth (an additional 4K for an increased healthy + // margin) + // in the JVM only is acceptable. + fixedGrowth = Math.max(fixedGrowth, 8192); + CrtMemoryLeakDetector.leakCheck(NUM_ITERATIONS, fixedGrowth, fn); + } + } + } diff --git a/src/test/java/software/amazon/awssdk/crt/test/IotServiceTest.java b/src/test/java/software/amazon/awssdk/crt/test/IotServiceTest.java index 4796972f7..4aa9b3bfa 100644 --- a/src/test/java/software/amazon/awssdk/crt/test/IotServiceTest.java +++ b/src/test/java/software/amazon/awssdk/crt/test/IotServiceTest.java @@ -60,7 +60,6 @@ public void testIotService() { unsubscribed.get(); assertEquals("No Subscriptions", 0, subsAcked); - disconnect(); close(); } @@ -68,6 +67,7 @@ public void testIotService() { { fail(ex.getMessage()); } + } } }; diff --git a/src/test/java/software/amazon/awssdk/crt/test/Mqtt5ClientTestFixture.java b/src/test/java/software/amazon/awssdk/crt/test/Mqtt5ClientTestFixture.java index 3c1a08b94..073445737 100644 --- a/src/test/java/software/amazon/awssdk/crt/test/Mqtt5ClientTestFixture.java +++ b/src/test/java/software/amazon/awssdk/crt/test/Mqtt5ClientTestFixture.java @@ -18,9 +18,12 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import org.junit.Assume; + /* For environment variable setup, see SetupCrossCICrtEnvironment in the CRT builder */ public class Mqtt5ClientTestFixture extends CrtTestFixture { + static final boolean AWS_GRAALVM_CI = System.getProperty("AWS_GRAALVM_CI") != null; // MQTT5 Codebuild/Direct connections data static final String AWS_TEST_MQTT5_DIRECT_MQTT_HOST = System.getProperty("AWS_TEST_MQTT5_DIRECT_MQTT_HOST"); static final String AWS_TEST_MQTT5_DIRECT_MQTT_PORT = System.getProperty("AWS_TEST_MQTT5_DIRECT_MQTT_PORT"); @@ -83,6 +86,17 @@ public class Mqtt5ClientTestFixture extends CrtTestFixture { protected int OPERATION_TIMEOUT_TIME = 30; public Mqtt5ClientTestFixture() { + /** + * Disable test for native image, because: + * - On MacOS, when cert and private key used for TLS, it will be imported to KeyChain, + * and KeyChain will restrict other application to use the private key + * - For GraalVM test, Java will run the tests firstly, and import the mTLS private key. + * After that, when native test runs, it's a different application than Java, + * which will use the same key, and MacOS blocks the usage and result in hanging. + * - Locally, you can either put in your password to allow the usage, or delete the key from the KeyChain, + * But, in CI, it's very complicated, and decided to not support MQTT tests for now. + */ + Assume.assumeFalse(AWS_GRAALVM_CI && CRT.getOSIdentifier() == "osx"); } /** diff --git a/src/test/java/software/amazon/awssdk/crt/test/MqttClientConnectionFixture.java b/src/test/java/software/amazon/awssdk/crt/test/MqttClientConnectionFixture.java index 70034169e..034ed8b1e 100644 --- a/src/test/java/software/amazon/awssdk/crt/test/MqttClientConnectionFixture.java +++ b/src/test/java/software/amazon/awssdk/crt/test/MqttClientConnectionFixture.java @@ -24,6 +24,8 @@ import java.util.function.Consumer; import org.junit.After; +import org.junit.Assume; + class MissingCredentialsException extends RuntimeException { MissingCredentialsException(String message) { super(message); @@ -39,6 +41,7 @@ public class MqttClientConnectionFixture extends CrtTestFixture { private CompletableFuture onConnectionFailureFuture = new CompletableFuture(); private CompletableFuture onConnectionClosedFuture = new CompletableFuture(); + static final boolean AWS_GRAALVM_CI = System.getProperty("AWS_GRAALVM_CI") != null; static final boolean AWS_TEST_IS_CI = System.getProperty("AWS_TEST_IS_CI") != null; static final String AWS_TEST_MQTT311_ROOTCA = System.getProperty("AWS_TEST_MQTT311_ROOT_CA"); // Static credential related @@ -151,6 +154,17 @@ public void tearDown() { } MqttClientConnectionFixture() { + /** + * Disable test for native image, because: + * - On MacOS, when cert and private key used for TLS, it will be imported to KeyChain, + * and KeyChain will restrict other application to use the private key + * - For GraalVM test, Java will run the tests firstly, and import the mTLS private key. + * After that, when native test runs, it's a different application than Java, + * which will use the same key, and MacOS blocks the usage and result in hanging. + * - Locally, you can either put in your password to allow the usage, or delete the key from the KeyChain, + * But, in CI, it's very complicated, and decided to not support MQTT tests for now. + */ + Assume.assumeFalse(AWS_GRAALVM_CI && CRT.getOSIdentifier() == "osx"); } boolean connectDirectWithConfig(TlsContext tlsContext, String endpoint, int port, String username, String password, HttpProxyOptions httpProxyOptions)