-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f212829
commit fe6e10f
Showing
13 changed files
with
888 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// | ||
// Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information regarding copyright ownership. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
= MicroProfile Telemetry logs TCK | ||
Any MicroProfile Telemetry implementation must pass this test suite. | ||
The TCK uses `TestNG` and `Arquillian`. | ||
|
||
== Hardware Requirements | ||
All systems should meet the following recommended hardware requirements: | ||
|
||
* CPU running at 2.0 GHz or higher | ||
* 4 GB of RAM or more | ||
* Network access to the Internet | ||
|
||
== Software Requirements | ||
You can run this TCK on platforms running the Solaris, Linux, Windows, and Mac OS with the following software installed: | ||
|
||
* Maven | ||
* JDK11+ | ||
|
||
== Dependencies | ||
To enable the tests in your project you need to add the following dependency to your build: | ||
|
||
[source, xml] | ||
---- | ||
<dependency> | ||
<groupId>org.eclipse.microprofile.telemetry</groupId> | ||
<artifactId>microprofile-telemetry-logs-tck</artifactId> | ||
<version>1.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
---- | ||
|
||
If you want to run the logs tests, you can specify all tests in the `tck-suite.xml`. E.g. | ||
|
||
[source, xml] | ||
---- | ||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > | ||
<suite name="microprofile-telemetry-logs-TCK" verbose="2" configfailurepolicy="continue" > | ||
<test name="telemetry-logs-tests" verbose="10"> | ||
<packages> | ||
<package name="org.eclipse.microprofile.telemetry.logs.tck.*" /> | ||
</packages> | ||
</test> | ||
</suite> | ||
---- | ||
|
||
== Configuration in Apache Maven pom.xml | ||
If you use Apache Maven then the tests are run via the `maven-surefire-plugin` | ||
|
||
[source, xml] | ||
---- | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.2</version> | ||
<configuration> | ||
<suiteXmlFiles> | ||
<suiteXmlFile>tck-suite.xml</suiteXmlFile> | ||
</suiteXmlFiles> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
---- | ||
|
||
== Running as a Scanned Dependency | ||
You can also run the TCK as a scanned dependency. | ||
|
||
=== Surefire Configuration in your pom.xml | ||
Once you've added the dependency, you don't need a `tck-suite.xml` you can just scan the dependency for tests. | ||
|
||
[source, xml] | ||
---- | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.2</version> | ||
<configuration> | ||
<dependenciesToScan> | ||
<dependency>org.eclipse.microprofile.telemetry:microprofile-telemetry-logs-tck</dependency> | ||
</dependenciesToScan> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.eclipse.microprofile.telemetry</groupId> | ||
<artifactId>microprofile-telemetry-tck-parent</artifactId> | ||
<version>1.2-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>microprofile-telemetry-logs-tck</artifactId> | ||
<name>MicroProfile Telemetry logs TCK</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.eclipse.microprofile.config</groupId> | ||
<artifactId>microprofile-config-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.microprofile.rest.client</groupId> | ||
<artifactId>microprofile-rest-client-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.enterprise</groupId> | ||
<artifactId>jakarta.enterprise.cdi-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.ws.rs</groupId> | ||
<artifactId>jakarta.ws.rs-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-sdk</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.enterprise.concurrent</groupId> | ||
<artifactId>jakarta.enterprise.concurrent-api</artifactId> | ||
<version>3.0.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry.instrumentation</groupId> | ||
<artifactId>opentelemetry-instrumentation-annotations</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry.semconv</groupId> | ||
<artifactId>opentelemetry-semconv</artifactId> | ||
<version>${version.otel.semconv}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.testng</groupId> | ||
<artifactId>arquillian-testng-container</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shrinkwrap</groupId> | ||
<artifactId>shrinkwrap-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shrinkwrap.resolver</groupId> | ||
<artifactId>shrinkwrap-resolver-impl-maven</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shrinkwrap.resolver</groupId> | ||
<artifactId>shrinkwrap-resolver-api-maven</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.awaitility</groupId> | ||
<artifactId>awaitility</artifactId> | ||
<version>${version.awaitility}</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.coderplus.maven.plugins</groupId> | ||
<artifactId>copy-rename-maven-plugin</artifactId> | ||
<version>${version.plugin.copy.rename}</version> | ||
<executions> | ||
<execution> | ||
<id>copy-readme</id> | ||
<phase>prepare-package</phase> | ||
<goals> | ||
<goal>copy</goal> | ||
</goals> | ||
<configuration> | ||
<sourceFile>../README.adoc</sourceFile> | ||
<destinationFile>target/classes/README.adoc</destinationFile> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
111 changes: 111 additions & 0 deletions
111
tck/logs/src/main/java/org/eclipse/microprofile/telemetry/logs/tck/BasicHttpClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package org.eclipse.microprofile.telemetry.logs.tck; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.InputStreamReader; | ||
import java.net.HttpURLConnection; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
|
||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
|
||
/** | ||
* A really basic client for doing Http requests | ||
* <p> | ||
* For use when we don't want to use JAX-RS client or something else which has integration with telemetry | ||
*/ | ||
public class BasicHttpClient { | ||
|
||
private URI baseUri; | ||
|
||
/** | ||
* @param baseUrl | ||
* The base URL. Any path requested through this client will be appended to this URL. This should usually | ||
* be a URL injected using {@link ArquillianResource} | ||
*/ | ||
public BasicHttpClient(URL baseUrl) { | ||
try { | ||
baseUri = baseUrl.toURI(); | ||
} catch (URISyntaxException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
/** | ||
* Makes a GET request to a path and returns the response code | ||
* | ||
* @param path | ||
* the path to request, relative to the baseUrl | ||
* @return the response code | ||
*/ | ||
public int get(String path) { | ||
if (path.startsWith("/")) { | ||
path = path.substring(1); | ||
} | ||
try { | ||
URL spanUrl = baseUri.resolve(path).toURL(); | ||
HttpURLConnection connection = (HttpURLConnection) spanUrl.openConnection(); | ||
try { | ||
return connection.getResponseCode(); | ||
} catch (Exception e) { | ||
throw new RuntimeException("Exception retrieving " + spanUrl, e); | ||
} finally { | ||
connection.disconnect(); | ||
} | ||
} catch (Exception e) { | ||
throw new RuntimeException("Exception retrieving path " + path, e); | ||
} | ||
} | ||
|
||
/** | ||
* Makes a GET request to a path and returns the response code | ||
* | ||
* @param path | ||
* the path to request, relative to the baseUrl | ||
* @return the response message | ||
*/ | ||
public String getResponseMessage(String path) { | ||
if (path.startsWith("/")) { | ||
path = path.substring(1); | ||
} | ||
try { | ||
URL spanUrl = baseUri.resolve(path).toURL(); | ||
HttpURLConnection connection = (HttpURLConnection) spanUrl.openConnection(); | ||
try (BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { | ||
String inputLine; | ||
StringBuilder response = new StringBuilder(); | ||
|
||
while ((inputLine = in.readLine()) != null) { | ||
response.append(inputLine); | ||
} | ||
return response.toString(); | ||
} catch (Exception e) { | ||
throw new RuntimeException("Exception retrieving " + spanUrl, e); | ||
} finally { | ||
connection.disconnect(); | ||
} | ||
} catch (Exception e) { | ||
throw new RuntimeException("Exception retrieving path " + path, e); | ||
} | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
tck/logs/src/main/java/org/eclipse/microprofile/telemetry/logs/tck/ConfigAsset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package org.eclipse.microprofile.telemetry.logs.tck; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Properties; | ||
|
||
import org.jboss.shrinkwrap.api.asset.Asset; | ||
|
||
public class ConfigAsset implements Asset { | ||
|
||
public static final String SDK_DISABLED = "otel.sdk.disabled"; | ||
|
||
private Properties properties = new Properties(); | ||
|
||
@Override | ||
public InputStream openStream() { | ||
try { | ||
ByteArrayOutputStream os = new ByteArrayOutputStream(); | ||
properties.store(os, null); | ||
return new ByteArrayInputStream(os.toByteArray()); | ||
} catch (IOException e) { | ||
// Shouldn't happen since we're only using in memory streams | ||
throw new RuntimeException("Unexpected error saving properties", e); | ||
} | ||
} | ||
|
||
public ConfigAsset add(String key, String value) { | ||
properties.put(key, value); | ||
return this; | ||
} | ||
|
||
} |
Oops, something went wrong.