Skip to content

Commit

Permalink
Add end to end tests (apache#2935)
Browse files Browse the repository at this point in the history
e2e test setup. cc @hanahmily @peng-yongsheng @IanCao @zhaoyuguang @JaredTan95 

# e2e test case
One single standalone Spring service, accessing H2 database. This service has been installed the agent. 
OAP runs in single mode with H2 storage too.

The e2e test will verify the results through GraphQL query
1. Traces exist.
2. Service/Service Instance/Endpoint exist and have expected metrics.
3. Topology exists and match expected.
  • Loading branch information
kezhenxu94 authored and wu-sheng committed Jun 30, 2019
1 parent 7f3ff15 commit d1a521b
Show file tree
Hide file tree
Showing 66 changed files with 4,146 additions and 4 deletions.
60 changes: 60 additions & 0 deletions Jenkinsfile-E2E
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/

pipeline {
agent {
label 'xenial'
}

tools {
jdk 'JDK 1.8 (latest)'
}

stages {
stage('Checkout Source Code') {
steps {
deleteDir()
checkout scm
sh 'git submodule update --init'
}
}

stage('Prepare Distribution Package') {
steps {
sh './mvnw -DskipTests clean package'
sh 'tar -zxf dist/apache-skywalking-apm-bin.tar.gz -C dist'
}
}

stage('Run End-to-End Tests') {
steps {
sh './mvnw -Dbuild.id=${BUILD_ID} -f test/e2e/pom.xml clean verify'
}
}
}

post {
always {
// "Abort old build on update" will interrupt the job completely,
// we need to clean up when there are containers started by the e2e tests
sh 'docker ps'
sh 'docker ps | grep -e "skywalking-e2e-container-${BUILD_ID}" | awk \'{print $1}\' | xargs --no-run-if-empty docker stop'
deleteDir()
}
}
}
4 changes: 2 additions & 2 deletions apm-dist/bin/oapService.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ PRG="$0"
PRGDIR=`dirname "$PRG"`
[ -z "$OAP_HOME" ] && OAP_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`

OAP_LOG_DIR="${OAP_HOME}/logs"
OAP_LOG_DIR="${OAP_LOG_DIR:-${OAP_HOME}/logs}"
JAVA_OPTS=" -Xms256M -Xmx512M"

if [ ! -d "${OAP_HOME}/logs" ]; then
if [ ! -d "${OAP_LOG_DIR}" ]; then
mkdir -p "${OAP_LOG_DIR}"
fi

Expand Down
4 changes: 2 additions & 2 deletions apm-dist/bin/webappService.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ PRG="$0"
PRGDIR=`dirname "$PRG"`
[ -z "$WEBAPP_HOME" ] && WEBAPP_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`

WEBAPP_LOG_DIR="${WEBAPP_HOME}/logs"
WEBAPP_LOG_DIR="${WEBAPP_LOG_DIR:-${WEBAPP_HOME}/logs}"
JAVA_OPTS=" -Xms256M -Xmx512M"
JAR_PATH="${WEBAPP_HOME}/webapp"

if [ ! -d "${WEBAPP_HOME}/logs" ]; then
if [ ! -d "${WEBAPP_LOG_DIR}" ]; then
mkdir -p "${WEBAPP_LOG_DIR}"
fi

Expand Down
45 changes: 45 additions & 0 deletions test/e2e/e2e-base/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You 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">
<parent>
<artifactId>apache-skywalking-e2e</artifactId>
<groupId>org.apache.skywalking</groupId>
<version>1.0.0</version>
</parent>

<modelVersion>4.0.0</modelVersion>

<artifactId>e2e-base</artifactId>

<dependencies>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>${snake.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.skywalking.e2e;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;

/**
* @author kezhenxu94
*/
public abstract class AbstractQuery<T extends AbstractQuery<?>> {
private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HHmmss");
private static final DateTimeFormatter MINUTE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm");

private String start;
private String end;
private String step = "SECOND";

public String start() {
if (start != null) {
return start;
}
return "SECOND".equals(step())
? LocalDateTime.now(ZoneOffset.UTC).minusMinutes(5).format(TIME_FORMATTER)
: LocalDateTime.now(ZoneOffset.UTC).minusMinutes(5).format(MINUTE_TIME_FORMATTER);
}

public T start(String start) {
this.start = start;
return (T) this;
}

public T start(LocalDateTime start) {
if ("MINUTE".equals(step())) {
this.start = start.format(MINUTE_TIME_FORMATTER);
} else if ("SECOND".equals(step())) {
this.start = start.format(TIME_FORMATTER);
}
return (T) this;
}

public String end() {
if (end != null) {
return end;
}
return "SECOND".equals(step())
? LocalDateTime.now(ZoneOffset.UTC).format(TIME_FORMATTER)
: LocalDateTime.now(ZoneOffset.UTC).format(MINUTE_TIME_FORMATTER);
}

public AbstractQuery end(String end) {
this.end = end;
return this;
}

public T end(LocalDateTime end) {
if ("MINUTE".equals(step())) {
this.end = end.format(MINUTE_TIME_FORMATTER);
} else if ("SECOND".equals(step())) {
this.end = end.format(TIME_FORMATTER);
}
return (T) this;
}

public String step() {
return step;
}

public T step(String step) {
this.step = step;
return (T) this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.skywalking.e2e;

/**
* GraphQL response for easily test
*
* @author kezhenxu94
*/
public class GQLResponse<T> {
private T data;

public T getData() {
return data;
}

public void setData(final T data) {
this.data = data;
}

@Override
public String toString() {
return "GQLResponse{" +
"data=" + data +
'}';
}
}
Loading

0 comments on commit d1a521b

Please sign in to comment.