Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time

Running the Microprofile Metrics TCK

Any implementation claiming Microprofile Metrics 2.3 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

Dependencies

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>2.3</version>
    </dependency>

    <dependency>
        <groupId>org.eclipse.microprofile.metrics</groupId>
        <artifactId>microprofile-metrics-rest-tck</artifactId>
        <version>2.3</version>
    </dependency>

    <dependency>
        <groupId>org.eclipse.microprofile.metrics</groupId>
        <artifactId>microprofile-metrics-api-tck</artifactId>
        <version>2.3</version>
    </dependency>

    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
        <version>1.2</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>1.3</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <version>1.1.8.Final</version>
        <scope>test</scope>
    </dependency>

    <!-- You can replace this with your choice of container -->
    <dependency>
        <groupId>org.jboss.arquillian.container</groupId>
        <artifactId>arquillian-wlp-managed-8.5</artifactId>
        <version>1.0.0.Final-SNAPSHOT</version>
        <scope>test</scope>
    </dependency>
</dependencies>

Additional dependencies for Optional TCK

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>2.3</version>
    </dependency>

    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>javax.ws.rs-api</artifactId>
        <version>2.0.1</version>
        <scope>provided</scope>
    </dependency>

Declaring the Tests to run in Apache Maven pom.xml

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.

Additional Configuration for Optional TCKs

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>

Running the TCK

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