diff --git a/.github/workflows/webserver.yml b/.github/workflows/webserver.yml index 5cf6746f1..6aa2af8b6 100644 --- a/.github/workflows/webserver.yml +++ b/.github/workflows/webserver.yml @@ -114,6 +114,14 @@ jobs: with: name: opentelemetry-webserver-sdk-x64-linux.tgz path: /tmp/apache_centos7/opentelemetry-webserver-sdk-x64-linux.tgz + - name: run integrationtest + run: | + docker rm -f apache_centos7_container + cd instrumentation/otel-webserver-module + docker-compose --profile centos7 up -d + docker ps -a + sleep 30 + ./gradlew :test:integration:integrationTests -i webserver-build-test-centos6: name: webserver-centos6-build diff --git a/instrumentation/otel-webserver-module/docker-compose.yml b/instrumentation/otel-webserver-module/docker-compose.yml index 8b2e431bf..6c35ac6ac 100644 --- a/instrumentation/otel-webserver-module/docker-compose.yml +++ b/instrumentation/otel-webserver-module/docker-compose.yml @@ -98,7 +98,7 @@ services: - centos_nginx - centos7_nginx - ubuntu20.04_nginx - command: ["--config=/etc/otel-config.yml", "${OTELCOL_ARGS}"] + command: ["--config=/etc/otel-config.yml"] volumes: - ./otel-config.yml:/etc/otel-config.yml ports: diff --git a/instrumentation/otel-webserver-module/opentelemetry_module.conf b/instrumentation/otel-webserver-module/opentelemetry_module.conf index b2b62ca22..efdc21d5d 100755 --- a/instrumentation/otel-webserver-module/opentelemetry_module.conf +++ b/instrumentation/otel-webserver-module/opentelemetry_module.conf @@ -13,7 +13,7 @@ ApacheModuleEnabled ON #ApacheModule Otel Exporter details ApacheModuleOtelSpanExporter otlp -ApacheModuleOtelExporterEndpoint docker.for.mac.localhost:4317 +ApacheModuleOtelExporterEndpoint collector:4317 # SSL Certificates #ApacheModuleOtelSslEnabled ON diff --git a/instrumentation/otel-webserver-module/settings.gradle b/instrumentation/otel-webserver-module/settings.gradle new file mode 100644 index 000000000..f71d3691d --- /dev/null +++ b/instrumentation/otel-webserver-module/settings.gradle @@ -0,0 +1,5 @@ +rootProject.name = 'otel-webserver-module' + +include 'test:integration' +findProject(':test:integration')?.name = 'integration' + diff --git a/instrumentation/otel-webserver-module/test/integration/build.gradle b/instrumentation/otel-webserver-module/test/integration/build.gradle new file mode 100644 index 000000000..b992de609 --- /dev/null +++ b/instrumentation/otel-webserver-module/test/integration/build.gradle @@ -0,0 +1,34 @@ +plugins { + id 'java' +} + +version '1.0' + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.projectlombok:lombok:1.18.16' + implementation 'org.testng:testng:7.1.0' + annotationProcessor 'org.projectlombok:lombok:1.18.16' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0' + implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13' + implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.36' + implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5' + implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.13.2' + implementation group: 'javax.ws.rs', name: 'javax.ws.rs-api', version: '2.1.1' + testImplementation group: 'io.rest-assured', name: 'rest-assured', version: '4.5.1' + testImplementation group: 'org.testng', name: 'testng', version: '6.14.3' + testImplementation group: 'io.rest-assured', name: 'json-schema-validator', version: '4.3.0' + implementation group: 'org.json', name: 'json', version: '20160810' + +} + +task integrationTests(type: Test) { + useTestNG() { + useDefaultListeners = true + suites 'src/test/resources/testngsuites/testng.xml' + } +} diff --git a/instrumentation/otel-webserver-module/test/integration/src/test/java/restutils/BaseTest.java b/instrumentation/otel-webserver-module/test/integration/src/test/java/restutils/BaseTest.java new file mode 100644 index 000000000..7d04a1967 --- /dev/null +++ b/instrumentation/otel-webserver-module/test/integration/src/test/java/restutils/BaseTest.java @@ -0,0 +1,24 @@ +package restutils; + +import io.restassured.RestAssured; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeSuite; + +import static utils.Constants.WEBSERVER_URL; +import static utils.Constants.ZIPKIN_URL; + +public class BaseTest { + + private String ZIPKIN_SERVICE_NAME = "zipkin"; + private LoadGenUtils loadGenUtils = new LoadGenUtils(); + + @BeforeSuite + public void setup() { + RestAssured.baseURI = ZIPKIN_URL; + } + + @BeforeClass + public void generateLoad(){ + loadGenUtils.generateLoad(WEBSERVER_URL, 90); + } +} diff --git a/instrumentation/otel-webserver-module/test/integration/src/test/java/restutils/LoadGenUtils.java b/instrumentation/otel-webserver-module/test/integration/src/test/java/restutils/LoadGenUtils.java new file mode 100644 index 000000000..281b5755a --- /dev/null +++ b/instrumentation/otel-webserver-module/test/integration/src/test/java/restutils/LoadGenUtils.java @@ -0,0 +1,19 @@ +package restutils; + +import io.restassured.RestAssured; + +public class LoadGenUtils { + + public void generateLoad(String Uri, int count) { + while(count > 0){ + RestAssured.given().get(Uri); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + count --; + } + + } +} diff --git a/instrumentation/otel-webserver-module/test/integration/src/test/java/restutils/RestClient.java b/instrumentation/otel-webserver-module/test/integration/src/test/java/restutils/RestClient.java new file mode 100644 index 000000000..bb4cc7337 --- /dev/null +++ b/instrumentation/otel-webserver-module/test/integration/src/test/java/restutils/RestClient.java @@ -0,0 +1,17 @@ +package restutils; + +import io.restassured.RestAssured; +import io.restassured.response.Response; +import static io.restassured.RestAssured.given; + +public class RestClient { + + public static Response getResponse(String Uri){ + given().when().get(Uri).then().log() + .all() + .assertThat() + .statusCode(200); + + return RestAssured.given().get(Uri); + } +} \ No newline at end of file diff --git a/instrumentation/otel-webserver-module/test/integration/src/test/java/restutils/ValidationUtils.java b/instrumentation/otel-webserver-module/test/integration/src/test/java/restutils/ValidationUtils.java new file mode 100644 index 000000000..24020d64d --- /dev/null +++ b/instrumentation/otel-webserver-module/test/integration/src/test/java/restutils/ValidationUtils.java @@ -0,0 +1,70 @@ +package restutils; + +import io.restassured.response.Response; +import org.json.JSONArray; +import org.json.JSONObject; +import org.testng.Assert; +import java.util.logging.Logger; +import static utils.Constants.*; + + +public class ValidationUtils extends BaseTest{ + + private static final Logger LOGGER = Logger.getLogger(ValidationUtils.class.getName()); + public RestClient restClient = new RestClient(); + public Response response; + + public void valiateResponseWithKey(Response response, String key) { + + } + + public void verifyAllTraces() { + response = restClient.getResponse(ZIPKIN_URL + TRACES); + LOGGER.info(response.body().asString()); + JSONArray jsonArray = new JSONArray(response.getBody().asString()); + for(int i=0; i keys; + String nextKeys; + + if(!exists) { + keys = json.keys(); + while(keys.hasNext()){ + nextKeys = (String)keys.next(); + try{ + if(json.get(nextKeys) instanceof JSONObject) { + if(!exists) { + validateComplexJson(json.getJSONObject(nextKeys), key); + } else if (json.get(nextKeys) instanceof JsonArray) { + JSONArray jsonArray = json.getJSONArray(nextKeys); + for(int i=0; i + + + + + + + +