Any implementation claiming Microprofile Metrics 5.0 compatibility must pass this test suite.
The TCK uses junit
.
If an implementation supports non-mandatory features defined in the specification then the optional TCK must be executed to validate compliance.
The optional TCK currently validates the following non-mandatory features:
-
REST stat metrics
-
Base metrics
To enable the tests in your Arquillian based test project you need to add the following dependencies:
<dependencies>
<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api</artifactId>
<version>${version.microprofile.metrics}</version>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-rest-tck</artifactId>
<version>${version.microprofile.metrics}</version>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api-tck</artifactId>
<version>${version.microprofile.metrics}</version>
</dependency>
<!-- version.jakartaee.coreprofile should correspond to the value
specified in the MicroProfile Parent pom.xml used by the specified
version of MicroProfile Metrics -->
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-core-api</artifactId>
<version>${version.jakartaee.coreprofile}</version>
<scope>provided</scope>
</dependency>
<!-- version.junit should correspond to the value specified in the
MicroProfile Parent TCK-bom pom.xml used by the specified version of
MicroProfile Metrics -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>
<!-- version.hamcrest should correspond to the value specified in the
MicroProfile Parent TCK-bom pom.xml used by the specified version of
MicroProfile Metrics -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>${version.hamcrest}</version>
<scope>test</scope>
</dependency>
<!-- version.arquillian should correspond to the value specified in the
MicroProfile Parent TCK-bom pom.xml used by the specified version of
MicroProfile Metrics -->
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>${version.arquillian}</version>
<scope>test</scope>
</dependency>
<!-- You can replace this with your choice of container -->
<dependency>
<groupId>io.openliberty.arquillian</groupId>
<artifactId>arquillian-liberty-managed-jakarta</artifactId>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
If running the optional TCK module you will need the below additional dependencies:
<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-optional-tck</artifactId>
<version>${version.microprofile.metrics}</version>
</dependency>
If you use Apache Maven, then the tests are run via the maven-surefire-plugin
by adding the following in your pom.xml.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<dependenciesToScan>
<dependency>org.eclipse.microprofile.metrics:microprofile-metrics-api-tck</dependency>
<dependency>org.eclipse.microprofile.metrics:microprofile-metrics-rest-tck</dependency>
</dependenciesToScan>
<environmentVariables>
<MP_METRICS_TAGS>tier=integration</MP_METRICS_TAGS>
</environmentVariables>
</configuration>
</plugin>
</plugins>
</build>
Note: Be sure to set up your Arquillian.xml as required for your server under test.
If the implementation does not support all base metrics as described in the specification because
they are not available in the used JVM, it is possible to skip the tests related to base metrics
by adding the system property skip.base.metric.tests=true
to the surefire process.
Add the <dependency>org.eclipse.microprofile.metrics:microprofile-metrics-optional-tck</dependency>
element to the <dependenciesToScan>
element:
<dependenciesToScan>
<dependency>org.eclipse.microprofile.metrics:microprofile-metrics-optional-tck</dependency>
<dependency>org.eclipse.microprofile.metrics:microprofile-metrics-api-tck</dependency>
<dependency>org.eclipse.microprofile.metrics:microprofile-metrics-rest-tck</dependency>
</dependenciesToScan>
To run the TCK, ensure that the above dependencies are installed, and run the following command:
# Modify the test.url variable to point to your server under test mvn test -Dtest.url=http://localhost:9080
If your server under test has basic authentication enabled, run the following command:
# Modify the test.url variable to point to your server under test. Modify the test.user and test.pwd variables to appropriate values for your server under test. mvn test -Dtest.url=https://localhost:9443 -Dtest.user=someUser -Dtest.pwd=somePassword
If you are testing with the Optional TCK module it will require the tests to send requests to the application deployed on your server. By default the tests will use the port defined in test.url
as your application port. You can configure a separate application port by defining the application.port
property.
# Modify the application.port with your server's defined application port mvn test -Dtest.url=https://localhost:9443 -Dtest.user=someUser -Dtest.pwd=somePassword -Dapplication.port=8080