aws-otel-java-instrumentation
aws-otel-java-instrumentation copied to clipboard
Add app signals contract test for postgres
Issue #, if available: N/A
Description of changes: Adding PostgreSQL contract tests for app signals to ensure that customer experience doesn't break with any change.
The new contract test follows the same structure as the current JDBC test and asserts on the same fields of the spans and attributes.
To reuse the same app as the current test, added the following environment variables which are changed by each test:
- DB_URL
- DB_DRIVER
- DB_USERNAME
- DB_PASSWORD
This will allow us to easily write tests for other kinds of databases in the future.
Notes
Had to change the fault query in the app because the previous query is valid in PostgresSQL. This change won't have any impact with H2 database because it is still an invalid query.
From:
select count(*) from user
To:
select count(*) from user
Contract tests running successfully
$ JAVA_HOME=/home/tdm/java17/amazon-corretto-17.0.11.9.1-linux-x64 ./gradlew :appsignals-tests:contract-tests:contractTests
> Configure project :awsagentprovider
Inferred project: aws-otel-java-instrumentation, version: 1.33.0-SNAPSHOT
> Task :appsignals-tests:images:http-servers:tomcat:jibDockerBuild
Containerizing application to Docker daemon as aws-appsignals-tests-http-server-tomcat...
Base image 'public.ecr.aws/docker/library/amazoncorretto:17-alpine' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for public.ecr.aws/docker/library/amazoncorretto:17-alpine...
Using base image with digest: sha256:2122cb140fa94053abce343fb854d24f4c62ba3c1ac701882dce12980396b477
Container entrypoint set to [java, -cp, @/app/jib-classpath-file, software.amazon.opentelemetry.appsignals.tests.images.httpservers.tomcat.Main]
Executing tasks:
[==============================] 99.3% complete
> loading to Docker daemon
> Task :appsignals-tests:images:http-servers:netty-server:jibDockerBuild
Containerizing application to Docker daemon as aws-appsignals-tests-http-server-netty-server...
Base image 'public.ecr.aws/docker/library/amazoncorretto:17-alpine' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for public.ecr.aws/docker/library/amazoncorretto:17-alpine...
Using base image with digest: sha256:2122cb140fa94053abce343fb854d24f4c62ba3c1ac701882dce12980396b477
Container entrypoint set to [java, -cp, @/app/jib-classpath-file, com.amazon.sampleapp.NettyServer]
Built image to Docker daemon as aws-appsignals-tests-http-server-netty-server
Executing tasks:
[==============================] 100.0% complete
> Task :appsignals-tests:images:http-clients:apache-http-client:jibDockerBuild
Containerizing application to Docker daemon as aws-appsignals-tests-apache-http-client-app...
Base image 'public.ecr.aws/docker/library/amazoncorretto:17-alpine' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for public.ecr.aws/docker/library/amazoncorretto:17-alpine...
Using base image with digest: sha256:2122cb140fa94053abce343fb854d24f4c62ba3c1ac701882dce12980396b477
Container entrypoint set to [java, -cp, @/app/jib-classpath-file, com.amazon.sampleapp.App]
Built image to Docker daemon as aws-appsignals-tests-apache-http-client-app
Executing tasks:
Built image to Docker daemon as aws-appsignals-tests-http-server-tomcat
Executing tasks:
[==============================] 100.0% complete
> Task :appsignals-tests:images:kafka:kafka-producers:jibDockerBuild
Containerizing application to Docker daemon as aws-appsignals-tests-kafka-kafka-producers...
Base image 'public.ecr.aws/docker/library/amazoncorretto:17-alpine' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for public.ecr.aws/docker/library/amazoncorretto:17-alpine...
Using base image with digest: sha256:2122cb140fa94053abce343fb854d24f4c62ba3c1ac701882dce12980396b477
Container entrypoint set to [java, -cp, @/app/jib-classpath-file, com.amazon.sampleapp.App]
Built image to Docker daemon as aws-appsignals-tests-kafka-kafka-producers
A new version of jib-gradle-plugin (3.4.2) is available (currently using 3.4.0). Update your build configuration to use the latest features and fixes!
https://github.com/GoogleContainerTools/jib/blob/master/jib-gradle-plugin/CHANGELOG.md
Please see https://github.com/GoogleContainerTools/jib/blob/master/docs/privacy.md for info on disabling this update check.
Executing tasks:
[==============================] 100.0% complete
> Task :appsignals-tests:images:http-clients:native-http-client:jibDockerBuild
Containerizing application to Docker daemon as aws-appsignals-tests-native-http-client-app...
Base image 'public.ecr.aws/docker/library/amazoncorretto:17-alpine' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for public.ecr.aws/docker/library/amazoncorretto:17-alpine...
Using base image with digest: sha256:2122cb140fa94053abce343fb854d24f4c62ba3c1ac701882dce12980396b477
Container entrypoint set to [java, -cp, @/app/jib-classpath-file, com.amazon.sampleapp.App]
Executing tasks:
[==============================] 99.1% complete
> loading to Docker daemon
> Task :appsignals-tests:images:kafka:kafka-consumers:jibDockerBuild
Containerizing application to Docker daemon as aws-appsignals-tests-kafka-kafka-consumers...
Base image 'public.ecr.aws/docker/library/amazoncorretto:17-alpine' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for public.ecr.aws/docker/library/amazoncorretto:17-alpine...
Using base image with digest: sha256:2122cb140fa94053abce343fb854d24f4c62ba3c1ac701882dce12980396b477
Container entrypoint set to [java, -cp, @/app/jib-classpath-file, App]
Built image to Docker daemon as aws-appsignals-tests-kafka-kafka-consumers
Executing tasks:
[==============================] 100.0% complete
> Task :appsignals-tests:images:http-servers:spring-mvc:jibDockerBuild
Containerizing application to Docker daemon as aws-appsignals-tests-http-server-spring-mvc...
Base image 'public.ecr.aws/docker/library/amazoncorretto:17-alpine' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for public.ecr.aws/docker/library/amazoncorretto:17-alpine...
Using base image with digest: sha256:2122cb140fa94053abce343fb854d24f4c62ba3c1ac701882dce12980396b477
Container entrypoint set to [java, -cp, @/app/jib-classpath-file, software.amazon.opentelemetry.appsignals.tests.images.httpservers.springmvc.Application]
Built image to Docker daemon as aws-appsignals-tests-http-server-spring-mvc
Executing tasks:
[==============================] 100.0% complete
> Task :appsignals-tests:images:http-clients:netty-http-client:jibDockerBuild
Containerizing application to Docker daemon as aws-appsignals-tests-netty-http-client-app...
Base image 'public.ecr.aws/docker/library/amazoncorretto:17-alpine' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for public.ecr.aws/docker/library/amazoncorretto:17-alpine...
Using base image with digest: sha256:2122cb140fa94053abce343fb854d24f4c62ba3c1ac701882dce12980396b477
Container entrypoint set to [java, -cp, @/app/jib-classpath-file, com.amazon.sampleapp.NettyClient]
Built image to Docker daemon as aws-appsignals-tests-netty-http-client-app
Executing tasks:
Built image to Docker daemon as aws-appsignals-tests-native-http-client-app
Executing tasks:
[==============================] 100.0% complete
> Task :appsignals-tests:images:mock-collector:jibDockerBuild
Containerizing application to Docker daemon as aws-appsignals-mock-collector...
Base image 'public.ecr.aws/docker/library/amazoncorretto:17-alpine' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for public.ecr.aws/docker/library/amazoncorretto:17-alpine...
Using base image with digest: sha256:2122cb140fa94053abce343fb854d24f4c62ba3c1ac701882dce12980396b477
Container entrypoint set to [java, -cp, @/app/jib-classpath-file, software.amazon.opentelemetry.appsignals.test.images.mockcollector.Main]
Built image to Docker daemon as aws-appsignals-mock-collector
Executing tasks:
[==============================] 100.0% complete
> Task :appsignals-tests:images:grpc:grpc-client:jibDockerBuild
Containerizing application to Docker daemon as grpc-client...
Base image 'public.ecr.aws/docker/library/amazoncorretto:17-alpine' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for public.ecr.aws/docker/library/amazoncorretto:17-alpine...
Using base image with digest: sha256:2122cb140fa94053abce343fb854d24f4c62ba3c1ac701882dce12980396b477
Container entrypoint set to [java, -cp, /app/resources:/app/classes:/app/libs/*, software.amazon.opentelemetry.Main]
Built image to Docker daemon as grpc-client
Executing tasks:
[==============================] 100.0% complete
> Task :appsignals-tests:images:aws-sdk:aws-sdk-v1:jibDockerBuild
Containerizing application to Docker daemon as aws-appsignals-tests-aws-sdk-v1...
Base image 'public.ecr.aws/docker/library/amazoncorretto:17-alpine' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for public.ecr.aws/docker/library/amazoncorretto:17-alpine...
Using base image with digest: sha256:2122cb140fa94053abce343fb854d24f4c62ba3c1ac701882dce12980396b477
Container entrypoint set to [java, -cp, @/app/jib-classpath-file, com.amazon.sampleapp.App]
Executing tasks:
[============================= ] 97.5% complete
> loading to Docker daemon
> Task :appsignals-tests:images:aws-sdk:aws-sdk-v2:jibDockerBuild
Containerizing application to Docker daemon as aws-appsignals-tests-aws-sdk-v2...
Base image 'public.ecr.aws/docker/library/amazoncorretto:17-alpine' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for public.ecr.aws/docker/library/amazoncorretto:17-alpine...
Using base image with digest: sha256:2122cb140fa94053abce343fb854d24f4c62ba3c1ac701882dce12980396b477
Container entrypoint set to [java, -cp, @/app/jib-classpath-file, com.amazon.sampleapp.App]
Built image to Docker daemon as aws-appsignals-tests-aws-sdk-v2
Executing tasks:
[==============================] 100.0% complete
> Task :appsignals-tests:images:grpc:grpc-server:jibDockerBuild
Containerizing application to Docker daemon as grpc-server...
Base image 'public.ecr.aws/docker/library/amazoncorretto:17-alpine' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for public.ecr.aws/docker/library/amazoncorretto:17-alpine...
Using base image with digest: sha256:2122cb140fa94053abce343fb854d24f4c62ba3c1ac701882dce12980396b477
Container entrypoint set to [java, -cp, /app/resources:/app/classes:/app/libs/*, software.amazon.opentelemetry.EchoerServer]
Built image to Docker daemon as grpc-server
Executing tasks:
[==============================] 100.0% complete
> Task :appsignals-tests:images:jdbc:jibDockerBuild
Containerizing application to Docker daemon as aws-appsignals-tests-jdbc-app...
Base image 'public.ecr.aws/docker/library/amazoncorretto:17-alpine' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for public.ecr.aws/docker/library/amazoncorretto:17-alpine...
Using base image with digest: sha256:2122cb140fa94053abce343fb854d24f4c62ba3c1ac701882dce12980396b477
Container entrypoint set to [java, -cp, @/app/jib-classpath-file, software.amazon.opentelemetry.Application]
Built image to Docker daemon as aws-appsignals-tests-jdbc-app
Executing tasks:
[==============================] 100.0% complete
> Task :appsignals-tests:images:http-clients:spring-mvc-client:jibDockerBuild
Containerizing application to Docker daemon as aws-appsignals-tests-spring-mvc-client-app...
Base image 'public.ecr.aws/docker/library/amazoncorretto:17-alpine' does not use a specific image digest - build may not be reproducible
The base image requires auth. Trying again for public.ecr.aws/docker/library/amazoncorretto:17-alpine...
Using base image with digest: sha256:2122cb140fa94053abce343fb854d24f4c62ba3c1ac701882dce12980396b477
Container entrypoint set to [java, -cp, @/app/jib-classpath-file, com.amazon.sampleapp.Application]
Built image to Docker daemon as aws-appsignals-tests-spring-mvc-client-app
Executing tasks:
Built image to Docker daemon as aws-appsignals-tests-aws-sdk-v1
Executing tasks:
[==============================] 100.0% complete
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.2.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD SUCCESSFUL in 13m 9s
56 actionable tasks: 19 executed, 37 up-to-date
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Not 100% sure the contract tests will run on forked repo PRs. If they can't, please include evidence of a successful test run.
Also please ensure spotless was run and applied.
@thpierce added a successful run of the tests to the PR description