You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2019/12/31 12:49:56 UTC
[skywalking] branch master updated: Provide thread monitor create
task feature (#4145)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new d38a8ea Provide thread monitor create task feature (#4145)
d38a8ea is described below
commit d38a8eaaa7e7193bff292cd03016c6a9320c8c9a
Author: mrproliu <74...@qq.com>
AuthorDate: Tue Dec 31 20:49:45 2019 +0800
Provide thread monitor create task feature (#4145)
* provide thread monitor task service to create
* provide thread monitor task GraphQL implements
* 1. change thread monitor field names
2. fix `getThreadMonitorTaskList` query time bucket error
* provide config stream processor
* update submodule `query-protocol`
* resolve e2e-mysql error
* remove useless storage interface method.
* rename `ThreadMonitorTask` to `ProfileTask`
* change e2e-profile to the top level
* fix profile test analyze error
* remove StringUtil#isBlank.
* 1. remove create profile task duration unit
2. remove GraphQL getTask list duration field
3. add `profileTaskQueryMaxSize` in `storage` -> `elasticsearch(7)` configuration, default get 200 profile task
* provide e2e different storage tests
* 1. fix rat check
2. remove DurationUtils.java#toSecond
3. remove ProfileTaskQueryEs7DAO
* fix e2e code format error
* provide es6 and es7 storage e2e tests
* change e2e profile es module artifactId
Co-authored-by: kezhenxu94 <ke...@163.com>
---
.github/workflows/e2e.yaml | 24 ++-
dist-material/application.yml | 2 +
docker/oap/docker-entrypoint.sh | 1 +
docs/en/setup/backend/backend-storage.md | 1 +
.../src/main/resources/application.yml | 1 +
.../skywalking/oap/server/core/CoreModule.java | 16 +-
.../oap/server/core/CoreModuleProvider.java | 5 +
.../core/profile/ProfileTaskMutationService.java | 134 +++++++++++++
.../server/core/profile/ProfileTaskNoneStream.java | 100 ++++++++++
.../profile/entity/ProfileTaskCreationResult.java | 40 ++++
.../oap/server/core/query/DurationUtils.java | 1 +
.../server/core/query/ProfileTaskQueryService.java | 86 ++++++++
.../oap/server/core/query/entity/ProfileTask.java | 42 ++++
.../oap/server/core/source/DefaultScopeDefine.java | 1 +
.../oap/server/core/storage/StorageModule.java | 3 +-
.../core/storage/profile/IProfileTaskQueryDAO.java | 44 +++++
.../oap/query/graphql/GraphQLQueryProvider.java | 2 +
.../query/graphql/resolver/ProfileMutation.java | 60 ++++++
.../oap/query/graphql/resolver/ProfileQuery.java | 56 ++++++
.../graphql/type/ProfileTaskCreationRequest.java | 41 ++++
.../src/main/resources/query-protocol | 2 +-
.../StorageModuleElasticsearchConfig.java | 1 +
.../StorageModuleElasticsearchProvider.java | 12 +-
.../elasticsearch/query/ProfileTaskQueryEsDAO.java | 101 ++++++++++
.../StorageModuleElasticsearch7Provider.java | 11 +-
.../storage/plugin/jdbc/h2/H2StorageProvider.java | 3 +
.../plugin/jdbc/h2/dao/H2ProfileTaskQueryDAO.java | 105 ++++++++++
.../plugin/jdbc/mysql/MySQLStorageProvider.java | 17 +-
.../apache/skywalking/e2e/SimpleQueryClient.java | 4 +-
test/e2e/e2e-mysql/src/docker/application.yml | 1 +
.../e2e-profile/e2e-profile-es-test-runner/pom.xml | 184 +++++++++++++++++
.../src/docker/clusterize.awk | 96 +++++++++
.../src/docker/rc.d/rc0-prepare.sh | 32 +++
.../src/docker/rc.d/rc1-startup.sh | 48 +++++
.../skywalking/e2e/ProfileVerificationITCase.java | 218 +++++++++++++++++++++
.../e2e-profile/e2e-profile-h2-test-runner/pom.xml | 132 +++++++++++++
.../src/docker/rc.d/rc1-startup.sh | 46 +++++
.../skywalking/e2e/ProfileVerificationITCase.java | 217 ++++++++++++++++++++
.../e2e-profile-mysql-test-runner/pom.xml | 158 +++++++++++++++
.../src/docker/application.yml | 1 +
.../src/docker/rc.d/rc0-prepare.sh | 27 +++
.../src/docker/rc.d/rc1-startup.sh | 40 ++++
.../skywalking/e2e/ProfileVerificationITCase.java | 217 ++++++++++++++++++++
test/e2e/e2e-profile/e2e-profile-service/pom.xml | 74 +++++++
.../skywalking/e2e/profile/ProfileApplication.java | 34 ++++
.../skywalking/e2e/profile/TestController.java | 45 +++++
.../org/apache/skywalking/e2e/profile/User.java | 56 ++++++
.../apache/skywalking/e2e/profile/UserRepo.java | 27 +++
.../src/main/resources/application.yml | 35 ++++
.../e2e-profile/e2e-profile-test-runner/pom.xml | 50 +++++
.../skywalking/e2e/profile/ProfileClient.java | 98 +++++++++
.../creation/ProfileTaskCreationRequest.java | 42 ++++
.../creation/ProfileTaskCreationResult.java | 36 ++++
.../creation/ProfileTaskCreationResultMatcher.java | 36 ++++
.../creation/ProfileTaskCreationResultWrapper.java | 35 ++++
.../skywalking/e2e/profile/query/ProfileTask.java | 42 ++++
.../e2e/profile/query/ProfileTaskMatcher.java | 51 +++++
.../e2e/profile/query/ProfileTaskQuery.java | 51 +++++
.../skywalking/e2e/profile/query/ProfileTasks.java | 36 ++++
.../e2e/profile/query/ProfilesTasksMatcher.java | 49 +++++
...ing.e2e.ProfileVerificationITCase.endpoints.yml | 19 ++
...ing.e2e.ProfileVerificationITCase.instances.yml | 28 +++
....e2e.ProfileVerificationITCase.profileTasks.yml | 24 +++
...king.e2e.ProfileVerificationITCase.services.yml | 19 ++
.../src/main/resources/getProfileTaskList.gql | 33 ++++
.../src/main/resources/profileTaskCreation.gql | 35 ++++
test/e2e/e2e-profile/pom.xml | 61 ++++++
test/e2e/pom.xml | 1 +
68 files changed, 3310 insertions(+), 40 deletions(-)
diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml
index 2f00652..0a1b28e 100644
--- a/.github/workflows/e2e.yaml
+++ b/.github/workflows/e2e.yaml
@@ -95,4 +95,26 @@ jobs:
./mvnw -Dcheckstyle.skip -Drat.skip -T2 -Dmaven.compile.fork -Dmaven.compiler.maxmem=3072 -DskipTests clean install
./mvnw -f test/e2e/pom.xml -pl e2e-base clean install
- name: 6.x Agents & 7.x Backend
- run: export E2E_VERSION=jdk8-1.3 && bash -x test/e2e/run.sh e2e-6.x-agent-7.x-oap-compatibility
\ No newline at end of file
+ run: export E2E_VERSION=jdk8-1.3 && bash -x test/e2e/run.sh e2e-6.x-agent-7.x-oap-compatibility
+
+ Profile:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v1
+ with:
+ submodules: true
+ - name: Set environment
+ run: export MAVEN_OPTS='-Dmaven.repo.local=~/.m2/repository -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:-UseGCOverheadLimit -Xmx3g'
+ - name: Compile & Install Test Codes
+ run: |
+ ./mvnw checkstyle:check apache-rat:check
+ ./mvnw -Dcheckstyle.skip -Drat.skip -T2 -Dmaven.compile.fork -Dmaven.compiler.maxmem=3072 -DskipTests clean install
+ ./mvnw -f test/e2e/pom.xml -pl e2e-base clean install
+ - name: Profile Tests H2(JDK8)
+ run: export E2E_VERSION=jdk8-1.3 && bash -x test/e2e/run.sh e2e-profile/e2e-profile-h2-test-runner
+ - name: Profile Tests MySQL(JDK8)
+ run: export E2E_VERSION=jdk8-1.3 && bash -x test/e2e/run.sh e2e-profile/e2e-profile-mysql-test-runner
+ - name: Profile Tests ES6(JDK8)
+ run: export E2E_VERSION=jdk8-1.3 && bash -x test/e2e/run.sh e2e-profile/e2e-profile-es-test-runner
+ - name: Profile Tests ES7(JDK8)
+ run: export E2E_VERSION=jdk8-1.3 DIST_PACKAGE=apache-skywalking-apm-bin-es7.tar.gz ES_VERSION=7.4.2 && bash -x test/e2e/run.sh e2e-profile/e2e-profile-es-test-runner
diff --git a/dist-material/application.yml b/dist-material/application.yml
index 828d15f..9c25498 100644
--- a/dist-material/application.yml
+++ b/dist-material/application.yml
@@ -95,6 +95,7 @@ storage:
# resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000}
# metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
# segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
+# profileTaskQueryMaxSize: ${SW_STORAGE_ES_QUERY_PROFILE_TASK_SIZE:200}
# elasticsearch7:
# nameSpace: ${SW_NAMESPACE:""}
# clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200}
@@ -116,6 +117,7 @@ storage:
# resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000}
# metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
# segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
+# profileTaskQueryMaxSize: ${SW_STORAGE_ES_QUERY_PROFILE_TASK_SIZE:200}
h2:
driver: ${SW_STORAGE_H2_DRIVER:org.h2.jdbcx.JdbcDataSource}
url: ${SW_STORAGE_H2_URL:jdbc:h2:mem:skywalking-oap-db}
diff --git a/docker/oap/docker-entrypoint.sh b/docker/oap/docker-entrypoint.sh
index 67d75c0..b87d420 100755
--- a/docker/oap/docker-entrypoint.sh
+++ b/docker/oap/docker-entrypoint.sh
@@ -119,6 +119,7 @@ cat <<EOT >> ${var_application_file}
resultWindowMaxSize: \${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000}
metadataQueryMaxSize: \${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
segmentQueryMaxSize: \${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
+ profileTaskQueryMaxSize: \${SW_STORAGE_ES_QUERY_PROFILE_TASK_SIZE:200}
EOT
}
diff --git a/docs/en/setup/backend/backend-storage.md b/docs/en/setup/backend/backend-storage.md
index 6693ca1..a58e5c9 100644
--- a/docs/en/setup/backend/backend-storage.md
+++ b/docs/en/setup/backend/backend-storage.md
@@ -63,6 +63,7 @@ storage:
resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000}
metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
+ profileTaskQueryMaxSize: ${SW_STORAGE_ES_QUERY_PROFILE_TASK_SIZE:200}
advanced: ${SW_STORAGE_ES_ADVANCED:""}
```
diff --git a/oap-server/server-bootstrap/src/main/resources/application.yml b/oap-server/server-bootstrap/src/main/resources/application.yml
index 52279ca..9e78870 100755
--- a/oap-server/server-bootstrap/src/main/resources/application.yml
+++ b/oap-server/server-bootstrap/src/main/resources/application.yml
@@ -94,6 +94,7 @@ storage:
# resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000}
# metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
# segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
+# profileTaskQueryMaxSize: ${SW_STORAGE_ES_QUERY_PROFILE_TASK_SIZE:200}
# advanced: ${SW_STORAGE_ES_ADVANCED:""}
elasticsearch7:
nameSpace: ${SW_NAMESPACE:""}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModule.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModule.java
index f8dfab7..49fc220 100755
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModule.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModule.java
@@ -28,14 +28,8 @@ import org.apache.skywalking.oap.server.core.command.CommandService;
import org.apache.skywalking.oap.server.core.config.ConfigService;
import org.apache.skywalking.oap.server.core.config.DownsamplingConfigService;
import org.apache.skywalking.oap.server.core.config.IComponentLibraryCatalogService;
-import org.apache.skywalking.oap.server.core.query.AggregationQueryService;
-import org.apache.skywalking.oap.server.core.query.AlarmQueryService;
-import org.apache.skywalking.oap.server.core.query.LogQueryService;
-import org.apache.skywalking.oap.server.core.query.MetadataQueryService;
-import org.apache.skywalking.oap.server.core.query.MetricQueryService;
-import org.apache.skywalking.oap.server.core.query.TopNRecordsQueryService;
-import org.apache.skywalking.oap.server.core.query.TopologyQueryService;
-import org.apache.skywalking.oap.server.core.query.TraceQueryService;
+import org.apache.skywalking.oap.server.core.profile.ProfileTaskMutationService;
+import org.apache.skywalking.oap.server.core.query.*;
import org.apache.skywalking.oap.server.core.register.service.IEndpointInventoryRegister;
import org.apache.skywalking.oap.server.core.register.service.INetworkAddressInventoryRegister;
import org.apache.skywalking.oap.server.core.register.service.IServiceInstanceInventoryRegister;
@@ -78,12 +72,18 @@ public class CoreModule extends ModuleDefine {
addRegisterService(classes);
addCacheService(classes);
addQueryService(classes);
+ addProfileService(classes);
classes.add(CommandService.class);
return classes.toArray(new Class[] {});
}
+ private void addProfileService(List<Class> classes) {
+ classes.add(ProfileTaskMutationService.class);
+ classes.add(ProfileTaskQueryService.class);
+ }
+
private void addQueryService(List<Class> classes) {
classes.add(TopologyQueryService.class);
classes.add(MetricQueryService.class);
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java
index 51ec77b..4286cb7 100755
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java
@@ -30,6 +30,7 @@ import org.apache.skywalking.oap.server.core.cache.*;
import org.apache.skywalking.oap.server.core.cluster.*;
import org.apache.skywalking.oap.server.core.command.CommandService;
import org.apache.skywalking.oap.server.core.config.*;
+import org.apache.skywalking.oap.server.core.profile.ProfileTaskMutationService;
import org.apache.skywalking.oap.server.core.oal.rt.*;
import org.apache.skywalking.oap.server.core.query.*;
import org.apache.skywalking.oap.server.core.register.service.*;
@@ -166,6 +167,10 @@ public class CoreModuleProvider extends ModuleProvider {
this.registerServiceImplementation(AlarmQueryService.class, new AlarmQueryService(getManager()));
this.registerServiceImplementation(TopNRecordsQueryService.class, new TopNRecordsQueryService(getManager()));
+ // add profile service implementations
+ this.registerServiceImplementation(ProfileTaskMutationService.class, new ProfileTaskMutationService(getManager()));
+ this.registerServiceImplementation(ProfileTaskQueryService.class, new ProfileTaskQueryService(getManager()));
+
this.registerServiceImplementation(CommandService.class, new CommandService(getManager()));
annotationScan.registerListener(streamAnnotationListener);
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/ProfileTaskMutationService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/ProfileTaskMutationService.java
new file mode 100644
index 0000000..c295fca
--- /dev/null
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/ProfileTaskMutationService.java
@@ -0,0 +1,134 @@
+/*
+ * 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.oap.server.core.profile;
+
+import org.apache.skywalking.apm.util.StringUtil;
+import org.apache.skywalking.oap.server.core.analysis.Downsampling;
+import org.apache.skywalking.oap.server.core.analysis.TimeBucket;
+import org.apache.skywalking.oap.server.core.analysis.worker.NoneStreamingProcessor;
+import org.apache.skywalking.oap.server.core.profile.entity.ProfileTaskCreationResult;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileTask;
+import org.apache.skywalking.oap.server.core.storage.StorageModule;
+import org.apache.skywalking.oap.server.core.storage.profile.IProfileTaskQueryDAO;
+import org.apache.skywalking.oap.server.library.module.ModuleManager;
+import org.apache.skywalking.oap.server.library.module.Service;
+import org.apache.skywalking.oap.server.library.util.CollectionUtils;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author MrPro
+ */
+public class ProfileTaskMutationService implements Service {
+
+ private final ModuleManager moduleManager;
+ private IProfileTaskQueryDAO profileTaskQueryDAO;
+
+ public ProfileTaskMutationService(ModuleManager moduleManager) {
+ this.moduleManager = moduleManager;
+ }
+
+ private IProfileTaskQueryDAO getProfileTaskDAO() {
+ if (profileTaskQueryDAO == null) {
+ this.profileTaskQueryDAO = moduleManager.find(StorageModule.NAME).provider().getService(IProfileTaskQueryDAO.class);
+ }
+ return profileTaskQueryDAO;
+ }
+
+ /**
+ * create new profile task
+ * @param serviceId monitor service id
+ * @param endpointName monitor endpoint name
+ * @param monitorStartTime create fix start time task when it's bigger 0
+ * @param monitorDuration monitor task duration(minute)
+ * @param minDurationThreshold min duration threshold
+ * @param dumpPeriod dump period
+ * @return task create result
+ */
+ public ProfileTaskCreationResult createTask(final int serviceId, final String endpointName, final long monitorStartTime, final int monitorDuration,
+ final int minDurationThreshold, final int dumpPeriod) throws IOException {
+
+ // calculate task execute range
+ long taskStartTime = monitorStartTime > 0 ? monitorStartTime : System.currentTimeMillis();
+ long taskEndTime = taskStartTime + TimeUnit.MINUTES.toMillis(monitorDuration);
+
+ // check data
+ final String errorMessage = checkDataSuccess(serviceId, endpointName, taskStartTime, taskEndTime, monitorDuration, minDurationThreshold, dumpPeriod);
+ if (errorMessage != null) {
+ return ProfileTaskCreationResult.builder().errorReason(errorMessage).build();
+ }
+
+ // create task
+ final long createTime = System.currentTimeMillis();
+ final ProfileTaskNoneStream task = new ProfileTaskNoneStream();
+ task.setServiceId(serviceId);
+ task.setEndpointName(endpointName.trim());
+ task.setStartTime(taskStartTime);
+ task.setDuration(monitorDuration);
+ task.setMinDurationThreshold(minDurationThreshold);
+ task.setDumpPeriod(dumpPeriod);
+ task.setCreateTime(createTime);
+ task.setTimeBucket(TimeBucket.getRecordTimeBucket(taskEndTime));
+ NoneStreamingProcessor.getInstance().in(task);
+
+ return ProfileTaskCreationResult.builder().id(task.id()).build();
+ }
+
+ private String checkDataSuccess(final Integer serviceId, final String endpointName, final long monitorStartTime, final long monitorEndTime, final int monitorDuration,
+ final int minDurationThreshold, final int dumpPeriod) throws IOException {
+ // basic check
+ if (serviceId == null) {
+ return "service cannot be null";
+ }
+ if (StringUtil.isEmpty(endpointName)) {
+ return "endpoint name cannot be empty";
+ }
+ if (monitorEndTime - monitorStartTime < TimeUnit.MINUTES.toMillis(1)) {
+ return "monitor duration must greater than 1 minutes";
+ }
+ if (minDurationThreshold < 0) {
+ return "min duration threshold must greater than or equals zero";
+ }
+
+ // check limit
+ // The duration of the monitoring task cannot be greater than 15 minutes
+ final long maxMonitorDurationInSec = TimeUnit.MINUTES.toSeconds(15);
+ if (monitorDuration > maxMonitorDurationInSec) {
+ return "The duration of the monitoring task cannot be greater than 15 minutes";
+ }
+
+ // dump period must be greater than or equals 10 milliseconds
+ if (dumpPeriod < 10) {
+ return "dump period must be greater than or equals 10 milliseconds";
+ }
+
+ // Each service can monitor up to 1 endpoints during the execution of tasks
+ long startTimeBucket = TimeBucket.getTimeBucket(monitorStartTime, Downsampling.Second);
+ long endTimeBucket = TimeBucket.getTimeBucket(monitorEndTime, Downsampling.Second);
+ final List<ProfileTask> alreadyHaveTaskList = getProfileTaskDAO().getTaskList(serviceId, null, startTimeBucket, endTimeBucket, 1);
+ if (CollectionUtils.isNotEmpty(alreadyHaveTaskList)) {
+ // if any task time bucket in this range, means already have task, because time bucket is base on task end time
+ return "current service already has monitor task execute at this time";
+ }
+
+ return null;
+ }
+
+}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/ProfileTaskNoneStream.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/ProfileTaskNoneStream.java
new file mode 100644
index 0000000..9e65c6b
--- /dev/null
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/ProfileTaskNoneStream.java
@@ -0,0 +1,100 @@
+/*
+ * 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.oap.server.core.profile;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.analysis.Stream;
+import org.apache.skywalking.oap.server.core.analysis.config.NoneStream;
+import org.apache.skywalking.oap.server.core.analysis.worker.NoneStreamingProcessor;
+import org.apache.skywalking.oap.server.core.source.ScopeDeclaration;
+import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
+import org.apache.skywalking.oap.server.core.storage.annotation.Column;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROFILE_TASK;
+
+/**
+ * profile task database bean, use none stream
+ *
+ * @author MrPro
+ */
+@Getter
+@Setter
+@ScopeDeclaration(id = PROFILE_TASK, name = "ProfileTask")
+@Stream(name = ProfileTaskNoneStream.INDEX_NAME, scopeId = PROFILE_TASK, builder = ProfileTaskNoneStream.Builder.class, processor = NoneStreamingProcessor.class)
+public class ProfileTaskNoneStream extends NoneStream {
+
+ public static final String INDEX_NAME = "profile_task";
+ public static final String SERVICE_ID = "service_id";
+ public static final String ENDPOINT_NAME = "endpoint_name";
+ public static final String START_TIME = "start_time";
+ public static final String DURATION = "duration";
+ public static final String MIN_DURATION_THRESHOLD = "min_duration_threshold";
+ public static final String DUMP_PERIOD = "dump_period";
+ public static final String CREATE_TIME = "create_time";
+
+ @Override
+ public String id() {
+ return getCreateTime() + Const.ID_SPLIT + getServiceId();
+ }
+
+ @Column(columnName = SERVICE_ID) private int serviceId;
+ @Column(columnName = ENDPOINT_NAME) private String endpointName;
+ @Column(columnName = START_TIME) private long startTime;
+ @Column(columnName = DURATION) private int duration;
+ @Column(columnName = MIN_DURATION_THRESHOLD) private int minDurationThreshold;
+ @Column(columnName = DUMP_PERIOD) private int dumpPeriod;
+ @Column(columnName = CREATE_TIME) private long createTime;
+
+ public static class Builder implements StorageBuilder<ProfileTaskNoneStream> {
+
+ @Override
+ public ProfileTaskNoneStream map2Data(Map<String, Object> dbMap) {
+ final ProfileTaskNoneStream record = new ProfileTaskNoneStream();
+ record.setServiceId(((Number)dbMap.get(SERVICE_ID)).intValue());
+ record.setEndpointName((String)dbMap.get(ENDPOINT_NAME));
+ record.setStartTime(((Number)dbMap.get(START_TIME)).longValue());
+ record.setDuration(((Number)dbMap.get(DURATION)).intValue());
+ record.setMinDurationThreshold(((Number)dbMap.get(MIN_DURATION_THRESHOLD)).intValue());
+ record.setDumpPeriod(((Number)dbMap.get(DUMP_PERIOD)).intValue());
+ record.setCreateTime(((Number)dbMap.get(CREATE_TIME)).longValue());
+ record.setTimeBucket(((Number)dbMap.get(TIME_BUCKET)).longValue());
+ return record;
+ }
+
+ @Override
+ public Map<String, Object> data2Map(ProfileTaskNoneStream storageData) {
+ final HashMap<String, Object> map = new HashMap<>();
+ map.put(SERVICE_ID, storageData.getServiceId());
+ map.put(ENDPOINT_NAME, storageData.getEndpointName());
+ map.put(START_TIME, storageData.getStartTime());
+ map.put(DURATION, storageData.getDuration());
+ map.put(MIN_DURATION_THRESHOLD, storageData.getMinDurationThreshold());
+ map.put(DUMP_PERIOD, storageData.getDumpPeriod());
+ map.put(CREATE_TIME, storageData.getCreateTime());
+ map.put(TIME_BUCKET, storageData.getTimeBucket());
+ return map;
+ }
+ }
+
+}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/entity/ProfileTaskCreationResult.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/entity/ProfileTaskCreationResult.java
new file mode 100644
index 0000000..46a3e40
--- /dev/null
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/entity/ProfileTaskCreationResult.java
@@ -0,0 +1,40 @@
+/*
+ * 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.oap.server.core.profile.entity;
+
+import lombok.*;
+
+/**
+ * create profile task result
+ *
+ * @author MrPro
+ */
+@Setter
+@Getter
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class ProfileTaskCreationResult {
+
+ // if null or empty means the task create success, otherwise get create error reason
+ private String errorReason;
+ // get data id when create success
+ private String id;
+
+}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/DurationUtils.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/DurationUtils.java
index 16e78e4..00fa126 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/DurationUtils.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/DurationUtils.java
@@ -20,6 +20,7 @@ package org.apache.skywalking.oap.server.core.query;
import java.text.*;
import java.util.*;
+
import org.apache.skywalking.oap.server.core.*;
import org.apache.skywalking.oap.server.core.analysis.Downsampling;
import org.apache.skywalking.oap.server.core.query.entity.Step;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/ProfileTaskQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/ProfileTaskQueryService.java
new file mode 100644
index 0000000..c111a80
--- /dev/null
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/ProfileTaskQueryService.java
@@ -0,0 +1,86 @@
+/*
+ * 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.oap.server.core.query;
+
+import org.apache.skywalking.oap.server.core.CoreModule;
+import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileTask;
+import org.apache.skywalking.oap.server.core.register.ServiceInventory;
+import org.apache.skywalking.oap.server.core.storage.StorageModule;
+import org.apache.skywalking.oap.server.core.storage.profile.IProfileTaskQueryDAO;
+import org.apache.skywalking.oap.server.library.module.ModuleManager;
+import org.apache.skywalking.oap.server.library.module.Service;
+import org.apache.skywalking.oap.server.library.util.CollectionUtils;
+
+import java.io.IOException;
+import java.util.List;
+
+import static java.util.Objects.isNull;
+
+/**
+ * handle profile task queries
+ *
+ * @author MrPro
+ */
+public class ProfileTaskQueryService implements Service {
+ private final ModuleManager moduleManager;
+ private IProfileTaskQueryDAO profileTaskQueryDAO;
+ private ServiceInventoryCache serviceInventoryCache;
+
+ public ProfileTaskQueryService(ModuleManager moduleManager) {
+ this.moduleManager = moduleManager;
+ }
+
+ private IProfileTaskQueryDAO getProfileTaskDAO() {
+ if (profileTaskQueryDAO == null) {
+ this.profileTaskQueryDAO = moduleManager.find(StorageModule.NAME).provider().getService(IProfileTaskQueryDAO.class);
+ }
+ return profileTaskQueryDAO;
+ }
+
+ private ServiceInventoryCache getServiceInventoryCache() {
+ if (isNull(serviceInventoryCache)) {
+ this.serviceInventoryCache = moduleManager.find(CoreModule.NAME).provider().getService(ServiceInventoryCache.class);
+ }
+ return serviceInventoryCache;
+ }
+
+ /**
+ * search profile task list
+ * @param serviceId monitor service
+ * @param endpointName endpoint name to monitored
+ * @return
+ */
+ public List<ProfileTask> getTaskList(Integer serviceId, String endpointName) throws IOException {
+ final List<ProfileTask> tasks = getProfileTaskDAO().getTaskList(serviceId, endpointName, null, null, null);
+
+ // add service name
+ if (CollectionUtils.isNotEmpty(tasks)) {
+ final ServiceInventoryCache serviceInventoryCache = getServiceInventoryCache();
+ for (ProfileTask task : tasks) {
+ final ServiceInventory serviceInventory = serviceInventoryCache.get(task.getServiceId());
+ if (serviceInventory != null) {
+ task.setServiceName(serviceInventory.getName());
+ }
+ }
+ }
+
+ return tasks;
+ }
+
+}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/ProfileTask.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/ProfileTask.java
new file mode 100644
index 0000000..2c2bac2
--- /dev/null
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/ProfileTask.java
@@ -0,0 +1,42 @@
+/*
+ * 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.oap.server.core.query.entity;
+
+import lombok.*;
+
+/**
+ * @author MrPro
+ */
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class ProfileTask {
+
+ private String id;
+ private int serviceId;
+ private String serviceName;
+ private String endpointName;
+ private long startTime;
+ private int duration;
+ private int minDurationThreshold;
+ private int dumpPeriod;
+
+}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java
index 97fcd22..3187cb6 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java
@@ -67,6 +67,7 @@ public class DefaultScopeDefine {
public static final int ZIPKIN_SPAN = 23;
public static final int JAEGER_SPAN = 24;
public static final int HTTP_ACCESS_LOG = 25;
+ public static final int PROFILE_TASK = 26;
/**
* Catalog of scope, the metrics processor could use this to group all generated metrics by oal rt.
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageModule.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageModule.java
index 9e42d9b..e5a1cee 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageModule.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageModule.java
@@ -19,6 +19,7 @@
package org.apache.skywalking.oap.server.core.storage;
import org.apache.skywalking.oap.server.core.storage.cache.*;
+import org.apache.skywalking.oap.server.core.storage.profile.IProfileTaskQueryDAO;
import org.apache.skywalking.oap.server.core.storage.query.*;
import org.apache.skywalking.oap.server.library.module.*;
@@ -40,6 +41,6 @@ public class StorageModule extends ModuleDefine {
IServiceInventoryCacheDAO.class, IServiceInstanceInventoryCacheDAO.class,
IEndpointInventoryCacheDAO.class, INetworkAddressInventoryCacheDAO.class,
ITopologyQueryDAO.class, IMetricsQueryDAO.class, ITraceQueryDAO.class, IMetadataQueryDAO.class, IAggregationQueryDAO.class, IAlarmQueryDAO.class,
- ITopNRecordsQueryDAO.class, ILogQueryDAO.class};
+ ITopNRecordsQueryDAO.class, ILogQueryDAO.class, IProfileTaskQueryDAO.class};
}
}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/profile/IProfileTaskQueryDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/profile/IProfileTaskQueryDAO.java
new file mode 100644
index 0000000..5e6fa09
--- /dev/null
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/profile/IProfileTaskQueryDAO.java
@@ -0,0 +1,44 @@
+/*
+ * 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.oap.server.core.storage.profile;
+
+import org.apache.skywalking.oap.server.core.query.entity.ProfileTask;
+import org.apache.skywalking.oap.server.core.storage.DAO;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * process all profile task query
+ *
+ * @author MrPro
+ */
+public interface IProfileTaskQueryDAO extends DAO {
+
+ /**
+ * search task list in appoint time bucket
+ * @param serviceId monitor service id, maybe null
+ * @param endpointName endpoint name, maybe empty
+ * @param startTimeBucket time bucket bigger than or equals, nullable
+ * @param endTimeBucket time bucket small than or equals, nullable
+ * @param limit limit count, if null means query all
+ * @return
+ */
+ List<ProfileTask> getTaskList(final Integer serviceId, final String endpointName, final Long startTimeBucket, final Long endTimeBucket, final Integer limit) throws IOException;
+
+}
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/GraphQLQueryProvider.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/GraphQLQueryProvider.java
index fcd3b24..b9ce7d6 100644
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/GraphQLQueryProvider.java
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/GraphQLQueryProvider.java
@@ -70,6 +70,8 @@ public class GraphQLQueryProvider extends ModuleProvider {
.resolvers(new TopNRecordsQuery(getManager()))
.file("query-protocol/log.graphqls")
.resolvers(new LogQuery(getManager()))
+ .file("query-protocol/profile.graphqls")
+ .resolvers(new ProfileQuery(getManager()), new ProfileMutation(getManager()))
.build()
.makeExecutableSchema();
this.graphQL = GraphQL.newGraphQL(schema).build();
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/ProfileMutation.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/ProfileMutation.java
new file mode 100644
index 0000000..659344d
--- /dev/null
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/ProfileMutation.java
@@ -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.
+ *
+ */
+package org.apache.skywalking.oap.query.graphql.resolver;
+
+import com.coxautodev.graphql.tools.GraphQLMutationResolver;
+import org.apache.skywalking.oap.query.graphql.type.ProfileTaskCreationRequest;
+import org.apache.skywalking.oap.server.core.CoreModule;
+import org.apache.skywalking.oap.server.core.profile.ProfileTaskMutationService;
+import org.apache.skywalking.oap.server.core.profile.entity.ProfileTaskCreationResult;
+import org.apache.skywalking.oap.server.library.module.ModuleManager;
+
+import java.io.IOException;
+
+/**
+ * profile mutation GraphQL resolver
+ *
+ * @author MrPro
+ */
+public class ProfileMutation implements GraphQLMutationResolver {
+
+ private final ModuleManager moduleManager;
+ private ProfileTaskMutationService profileTaskService;
+
+ public ProfileMutation(ModuleManager moduleManager) {
+ this.moduleManager = moduleManager;
+ }
+
+ private ProfileTaskMutationService getProfileTaskService() {
+ if (profileTaskService == null) {
+ this.profileTaskService = moduleManager.find(CoreModule.NAME).provider().getService(ProfileTaskMutationService.class);
+ }
+ return profileTaskService;
+ }
+
+ public ProfileTaskCreationResult createProfileTask(ProfileTaskCreationRequest creationRequest) throws IOException {
+ return getProfileTaskService().createTask(
+ creationRequest.getServiceId(),
+ creationRequest.getEndpointName() == null ? null : creationRequest.getEndpointName().trim(),
+ creationRequest.getStartTime() == null ? -1 : creationRequest.getStartTime(),
+ creationRequest.getDuration(),
+ creationRequest.getMinDurationThreshold(),
+ creationRequest.getDumpPeriod()
+ );
+ }
+}
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/ProfileQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/ProfileQuery.java
new file mode 100644
index 0000000..5fec074
--- /dev/null
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/ProfileQuery.java
@@ -0,0 +1,56 @@
+/*
+ * 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.oap.query.graphql.resolver;
+
+import com.coxautodev.graphql.tools.GraphQLQueryResolver;
+import org.apache.skywalking.oap.server.core.CoreModule;
+import org.apache.skywalking.oap.server.core.query.ProfileTaskQueryService;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileTask;
+import org.apache.skywalking.oap.server.library.module.ModuleManager;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * profile query GraphQL resolver
+ *
+ * @author MrPro
+ */
+public class ProfileQuery implements GraphQLQueryResolver {
+
+ private final ModuleManager moduleManager;
+ private ProfileTaskQueryService profileTaskQueryService;
+
+ public ProfileQuery(ModuleManager moduleManager) {
+ this.moduleManager = moduleManager;
+ }
+
+ private ProfileTaskQueryService getProfileTaskQueryService() {
+ if (profileTaskQueryService == null) {
+ this.profileTaskQueryService = moduleManager.find(CoreModule.NAME).provider().getService(ProfileTaskQueryService.class);
+ }
+ return profileTaskQueryService;
+ }
+
+ public List<ProfileTask> getProfileTaskList(final Integer serviceId, final String endpointName) throws IOException {
+ return getProfileTaskQueryService().getTaskList(serviceId, endpointName);
+ }
+
+
+}
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/ProfileTaskCreationRequest.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/ProfileTaskCreationRequest.java
new file mode 100644
index 0000000..370f120
--- /dev/null
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/ProfileTaskCreationRequest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.oap.query.graphql.type;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.query.entity.Step;
+
+/**
+ * Profile task create need data
+ *
+ * @author MrPro
+ */
+@Setter
+@Getter
+public class ProfileTaskCreationRequest {
+
+ private int serviceId;
+ private String endpointName;
+ private Long startTime;
+ private int duration;
+ private Step durationUnit;
+ private int minDurationThreshold;
+ private int dumpPeriod;
+
+}
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
index e47462f..a52c7a9 160000
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
@@ -1 +1 @@
-Subproject commit e47462fd6af92d42d1c161cf1cec975661148ab0
+Subproject commit a52c7a957f02a37b9409b52fc55db774f20291bf
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchConfig.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchConfig.java
index d50c052..46db72d 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchConfig.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchConfig.java
@@ -44,6 +44,7 @@ public class StorageModuleElasticsearchConfig extends ModuleConfig {
@Setter private int resultWindowMaxSize = 10000;
@Setter private int metadataQueryMaxSize = 5000;
@Setter private int segmentQueryMaxSize = 200;
+ @Setter private int profileTaskQueryMaxSize = 200;
@Setter private int recordDataTTL = 7;
@Setter private int minuteMetricsDataTTL = 2;
@Setter private int hourMetricsDataTTL = 2;
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java
index 821cd83..3a9dd34 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java
@@ -36,6 +36,7 @@ import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCac
import org.apache.skywalking.oap.server.core.storage.cache.INetworkAddressInventoryCacheDAO;
import org.apache.skywalking.oap.server.core.storage.cache.IServiceInstanceInventoryCacheDAO;
import org.apache.skywalking.oap.server.core.storage.cache.IServiceInventoryCacheDAO;
+import org.apache.skywalking.oap.server.core.storage.profile.IProfileTaskQueryDAO;
import org.apache.skywalking.oap.server.core.storage.query.IAggregationQueryDAO;
import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO;
import org.apache.skywalking.oap.server.core.storage.query.ILogQueryDAO;
@@ -60,14 +61,7 @@ import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.cache.Servi
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.cache.ServiceInventoryCacheEsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.lock.RegisterLockDAOImpl;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.lock.RegisterLockInstaller;
-import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.AggregationQueryEsDAO;
-import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.AlarmQueryEsDAO;
-import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.LogQueryEsDAO;
-import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.MetadataQueryEsDAO;
-import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.MetricsQueryEsDAO;
-import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.TopNRecordsQueryEsDAO;
-import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.TopologyQueryEsDAO;
-import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.TraceQueryEsDAO;
+import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.*;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.ttl.ElasticsearchStorageTTL;
/**
@@ -123,6 +117,8 @@ public class StorageModuleElasticsearchProvider extends ModuleProvider {
this.registerServiceImplementation(IAlarmQueryDAO.class, new AlarmQueryEsDAO(elasticSearchClient));
this.registerServiceImplementation(ITopNRecordsQueryDAO.class, new TopNRecordsQueryEsDAO(elasticSearchClient));
this.registerServiceImplementation(ILogQueryDAO.class, new LogQueryEsDAO(elasticSearchClient));
+
+ this.registerServiceImplementation(IProfileTaskQueryDAO.class, new ProfileTaskQueryEsDAO(elasticSearchClient, config.getProfileTaskQueryMaxSize()));
}
@Override
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/ProfileTaskQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/ProfileTaskQueryEsDAO.java
new file mode 100644
index 0000000..c847f54
--- /dev/null
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/ProfileTaskQueryEsDAO.java
@@ -0,0 +1,101 @@
+/*
+ * 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.oap.server.storage.plugin.elasticsearch.query;
+
+import org.apache.skywalking.apm.util.StringUtil;
+import org.apache.skywalking.oap.server.core.profile.ProfileTaskNoneStream;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileTask;
+import org.apache.skywalking.oap.server.core.storage.profile.IProfileTaskQueryDAO;
+import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient;
+import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.EsDAO;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.index.query.BoolQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.search.SearchHit;
+import org.elasticsearch.search.builder.SearchSourceBuilder;
+import org.elasticsearch.search.sort.SortOrder;
+
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author MrPro
+ */
+public class ProfileTaskQueryEsDAO extends EsDAO implements IProfileTaskQueryDAO {
+
+ private final int queryMaxSize;
+
+ public ProfileTaskQueryEsDAO(ElasticSearchClient client, int queryMaxSize) {
+ super(client);
+ this.queryMaxSize = queryMaxSize;
+ }
+
+ @Override
+ public List<ProfileTask> getTaskList(Integer serviceId, String endpointName, Long startTimeBucket, Long endTimeBucket, Integer limit) throws IOException {
+ SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
+
+ final BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
+ sourceBuilder.query(boolQueryBuilder);
+
+ if (serviceId != null) {
+ boolQueryBuilder.must().add(QueryBuilders.termQuery(ProfileTaskNoneStream.SERVICE_ID, serviceId));
+ }
+
+ if (StringUtil.isNotEmpty(endpointName)) {
+ boolQueryBuilder.must().add(QueryBuilders.termQuery(ProfileTaskNoneStream.ENDPOINT_NAME, endpointName));
+ }
+
+ if (startTimeBucket != null) {
+ boolQueryBuilder.must().add(QueryBuilders.rangeQuery(ProfileTaskNoneStream.TIME_BUCKET).gte(startTimeBucket));
+ }
+
+ if (endTimeBucket != null) {
+ boolQueryBuilder.must().add(QueryBuilders.rangeQuery(ProfileTaskNoneStream.TIME_BUCKET).lte(endTimeBucket));
+ }
+
+ if (limit != null) {
+ sourceBuilder.size(limit);
+ } else {
+ sourceBuilder.size(queryMaxSize);
+ }
+
+ sourceBuilder.sort(ProfileTaskNoneStream.START_TIME, SortOrder.DESC);
+
+ final SearchResponse response = getClient().search(ProfileTaskNoneStream.INDEX_NAME, sourceBuilder);
+
+ final LinkedList<ProfileTask> tasks = new LinkedList<>();
+ for (SearchHit searchHit : response.getHits().getHits()) {
+ tasks.add(parseTask(searchHit));
+ }
+
+ return tasks;
+ }
+
+ private ProfileTask parseTask(SearchHit data) {
+ return ProfileTask.builder()
+ .id(data.getId())
+ .serviceId(((Number) data.getSourceAsMap().get(ProfileTaskNoneStream.SERVICE_ID)).intValue())
+ .endpointName((String) data.getSourceAsMap().get(ProfileTaskNoneStream.ENDPOINT_NAME))
+ .startTime(((Number) data.getSourceAsMap().get(ProfileTaskNoneStream.START_TIME)).longValue())
+ .duration(((Number) data.getSourceAsMap().get(ProfileTaskNoneStream.DURATION)).intValue())
+ .minDurationThreshold(((Number) data.getSourceAsMap().get(ProfileTaskNoneStream.MIN_DURATION_THRESHOLD)).intValue())
+ .dumpPeriod(((Number) data.getSourceAsMap().get(ProfileTaskNoneStream.DUMP_PERIOD)).intValue()).build();
+ }
+}
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Provider.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Provider.java
index 7a22bae..e04aa1a 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Provider.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Provider.java
@@ -31,6 +31,7 @@ import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCac
import org.apache.skywalking.oap.server.core.storage.cache.INetworkAddressInventoryCacheDAO;
import org.apache.skywalking.oap.server.core.storage.cache.IServiceInstanceInventoryCacheDAO;
import org.apache.skywalking.oap.server.core.storage.cache.IServiceInventoryCacheDAO;
+import org.apache.skywalking.oap.server.core.storage.profile.IProfileTaskQueryDAO;
import org.apache.skywalking.oap.server.core.storage.query.IAggregationQueryDAO;
import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO;
import org.apache.skywalking.oap.server.core.storage.query.ILogQueryDAO;
@@ -46,6 +47,7 @@ import org.apache.skywalking.oap.server.library.module.ModuleStartException;
import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.BatchProcessEsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.HistoryDeleteEsDAO;
+import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.ProfileTaskQueryEsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.TopNRecordsQueryEsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.TopologyQueryEsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.ttl.ElasticsearchStorageTTL;
@@ -58,12 +60,7 @@ import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.dao.Storag
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.base.StorageEs7Installer;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.lock.RegisterLockEs77DAOImpl;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.lock.RegisterLockEs7Installer;
-import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.AggregationQueryEs7DAO;
-import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.AlarmQueryEs7DAO;
-import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.LogQueryEs7DAO;
-import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.MetadataQueryEs7DAO;
-import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.MetricsQueryEs7DAO;
-import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.TraceQueryEs7DAO;
+import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.*;
import java.io.IOException;
import java.security.KeyManagementException;
@@ -125,6 +122,8 @@ public class StorageModuleElasticsearch7Provider extends ModuleProvider {
this.registerServiceImplementation(IAlarmQueryDAO.class, new AlarmQueryEs7DAO(elasticSearch7Client));
this.registerServiceImplementation(ITopNRecordsQueryDAO.class, new TopNRecordsQueryEsDAO(elasticSearch7Client));
this.registerServiceImplementation(ILogQueryDAO.class, new LogQueryEs7DAO(elasticSearch7Client));
+
+ this.registerServiceImplementation(IProfileTaskQueryDAO.class, new ProfileTaskQueryEsDAO(elasticSearch7Client, config.getProfileTaskQueryMaxSize()));
}
@Override
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/H2StorageProvider.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/H2StorageProvider.java
index 26bf2c6..4663ad2 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/H2StorageProvider.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/H2StorageProvider.java
@@ -22,6 +22,7 @@ import java.util.Properties;
import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.storage.*;
import org.apache.skywalking.oap.server.core.storage.cache.*;
+import org.apache.skywalking.oap.server.core.storage.profile.IProfileTaskQueryDAO;
import org.apache.skywalking.oap.server.core.storage.query.*;
import org.apache.skywalking.oap.server.core.storage.ttl.GeneralStorageTTL;
import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
@@ -89,6 +90,8 @@ public class H2StorageProvider extends ModuleProvider {
this.registerServiceImplementation(IHistoryDeleteDAO.class, new H2HistoryDeleteDAO(getManager(), h2Client, new GeneralStorageTTL()));
this.registerServiceImplementation(ITopNRecordsQueryDAO.class, new H2TopNRecordsQueryDAO(h2Client));
this.registerServiceImplementation(ILogQueryDAO.class, new H2LogQueryDAO(h2Client));
+
+ this.registerServiceImplementation(IProfileTaskQueryDAO.class, new H2ProfileTaskQueryDAO(h2Client));
}
@Override public void start() throws ServiceNotProvidedException, ModuleStartException {
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2ProfileTaskQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2ProfileTaskQueryDAO.java
new file mode 100644
index 0000000..fab463d
--- /dev/null
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2ProfileTaskQueryDAO.java
@@ -0,0 +1,105 @@
+/*
+ * 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.oap.server.storage.plugin.jdbc.h2.dao;
+
+import org.apache.skywalking.apm.util.StringUtil;
+import org.apache.skywalking.oap.server.core.profile.ProfileTaskNoneStream;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileTask;
+import org.apache.skywalking.oap.server.core.storage.profile.IProfileTaskQueryDAO;
+import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author MrPro
+ */
+public class H2ProfileTaskQueryDAO implements IProfileTaskQueryDAO {
+ private JDBCHikariCPClient h2Client;
+
+ public H2ProfileTaskQueryDAO(JDBCHikariCPClient h2Client) {
+ this.h2Client = h2Client;
+ }
+
+ @Override
+ public List<ProfileTask> getTaskList(Integer serviceId, String endpointName, Long startTimeBucket, Long endTimeBucket, Integer limit) throws IOException {
+ final StringBuilder sql = new StringBuilder();
+ final ArrayList<Object> condition = new ArrayList<>(4);
+ sql.append("select * from ").append(ProfileTaskNoneStream.INDEX_NAME).append(" where 1=1 ");
+
+ if (startTimeBucket != null) {
+ sql.append(" and ").append(ProfileTaskNoneStream.TIME_BUCKET).append(" >= ? ");
+ condition.add(startTimeBucket);
+ }
+
+ if (endTimeBucket != null) {
+ sql.append(" and ").append(ProfileTaskNoneStream.TIME_BUCKET).append(" <= ? ");
+ condition.add(endTimeBucket);
+ }
+
+ if (serviceId != null) {
+ sql.append(" and ").append(ProfileTaskNoneStream.SERVICE_ID).append("=? ");
+ condition.add(serviceId);
+ }
+
+ if (StringUtil.isNotEmpty(endpointName)) {
+ sql.append(" and ").append(ProfileTaskNoneStream.ENDPOINT_NAME).append("=?");
+ condition.add(endpointName);
+ }
+
+ sql.append(" ORDER BY ").append(ProfileTaskNoneStream.START_TIME).append(" DESC ");
+
+ if (limit != null) {
+ sql.append(" LIMIT ").append(limit);
+ }
+
+ try (Connection connection = h2Client.getConnection()) {
+ try (ResultSet resultSet = h2Client.executeQuery(connection, sql.toString(), condition.toArray(new Object[0]))) {
+ final LinkedList<ProfileTask> tasks = new LinkedList<>();
+ while (resultSet.next()) {
+ tasks.add(parseTask(resultSet));
+ }
+ return tasks;
+ }
+ } catch (SQLException e) {
+ throw new IOException(e);
+ }
+ }
+
+ /**
+ * parse profile task data
+ * @param data
+ * @return
+ */
+ private ProfileTask parseTask(ResultSet data) throws SQLException {
+ return ProfileTask.builder()
+ .id(data.getString("id"))
+ .serviceId(data.getInt(ProfileTaskNoneStream.SERVICE_ID))
+ .endpointName(data.getString(ProfileTaskNoneStream.ENDPOINT_NAME))
+ .startTime(data.getLong(ProfileTaskNoneStream.START_TIME))
+ .duration(data.getInt(ProfileTaskNoneStream.DURATION))
+ .minDurationThreshold(data.getInt(ProfileTaskNoneStream.MIN_DURATION_THRESHOLD))
+ .dumpPeriod(data.getInt(ProfileTaskNoneStream.DUMP_PERIOD)).build();
+ }
+}
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLStorageProvider.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLStorageProvider.java
index e0a1b28..056e023 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLStorageProvider.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLStorageProvider.java
@@ -29,6 +29,7 @@ import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCac
import org.apache.skywalking.oap.server.core.storage.cache.INetworkAddressInventoryCacheDAO;
import org.apache.skywalking.oap.server.core.storage.cache.IServiceInstanceInventoryCacheDAO;
import org.apache.skywalking.oap.server.core.storage.cache.IServiceInventoryCacheDAO;
+import org.apache.skywalking.oap.server.core.storage.profile.IProfileTaskQueryDAO;
import org.apache.skywalking.oap.server.core.storage.query.IAggregationQueryDAO;
import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO;
import org.apache.skywalking.oap.server.core.storage.query.ILogQueryDAO;
@@ -44,19 +45,7 @@ import org.apache.skywalking.oap.server.library.module.ModuleDefine;
import org.apache.skywalking.oap.server.library.module.ModuleProvider;
import org.apache.skywalking.oap.server.library.module.ModuleStartException;
import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException;
-import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2BatchDAO;
-import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2EndpointInventoryCacheDAO;
-import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2HistoryDeleteDAO;
-import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2MetadataQueryDAO;
-import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2MetricsQueryDAO;
-import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2NetworkAddressInventoryCacheDAO;
-import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2RegisterLockDAO;
-import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2RegisterLockInstaller;
-import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2ServiceInstanceInventoryCacheDAO;
-import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2ServiceInventoryCacheDAO;
-import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2StorageDAO;
-import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TopNRecordsQueryDAO;
-import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TopologyQueryDAO;
+import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -116,6 +105,8 @@ public class MySQLStorageProvider extends ModuleProvider {
this.registerServiceImplementation(IHistoryDeleteDAO.class, new H2HistoryDeleteDAO(getManager(), mysqlClient, new GeneralStorageTTL()));
this.registerServiceImplementation(ITopNRecordsQueryDAO.class, new H2TopNRecordsQueryDAO(mysqlClient));
this.registerServiceImplementation(ILogQueryDAO.class, new MySQLLogQueryDAO(mysqlClient));
+
+ this.registerServiceImplementation(IProfileTaskQueryDAO.class, new H2ProfileTaskQueryDAO(mysqlClient));
}
@Override public void start() throws ServiceNotProvidedException, ModuleStartException {
diff --git a/test/e2e/e2e-base/src/main/java/org/apache/skywalking/e2e/SimpleQueryClient.java b/test/e2e/e2e-base/src/main/java/org/apache/skywalking/e2e/SimpleQueryClient.java
index 10c7c76..7b2509b 100644
--- a/test/e2e/e2e-base/src/main/java/org/apache/skywalking/e2e/SimpleQueryClient.java
+++ b/test/e2e/e2e-base/src/main/java/org/apache/skywalking/e2e/SimpleQueryClient.java
@@ -51,9 +51,9 @@ import java.util.stream.Collectors;
* @author kezhenxu94
*/
public class SimpleQueryClient {
- private final RestTemplate restTemplate = new RestTemplate();
+ protected final RestTemplate restTemplate = new RestTemplate();
- private final String endpointUrl;
+ protected final String endpointUrl;
public SimpleQueryClient(String host, String port) {
this("http://" + host + ":" + port + "/graphql");
diff --git a/test/e2e/e2e-mysql/src/docker/application.yml b/test/e2e/e2e-mysql/src/docker/application.yml
index bb7f189..343c5cf 100644
--- a/test/e2e/e2e-mysql/src/docker/application.yml
+++ b/test/e2e/e2e-mysql/src/docker/application.yml
@@ -92,6 +92,7 @@ storage:
# concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2} # the number of concurrent requests
# metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
# segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
+# profileTaskQueryMaxSize: ${SW_STORAGE_ES_QUERY_PROFILE_TASK_SIZE:200}
# h2:
# driver: ${SW_STORAGE_H2_DRIVER:org.h2.jdbcx.JdbcDataSource}
# url: ${SW_STORAGE_H2_URL:jdbc:h2:mem:skywalking-oap-db}
diff --git a/test/e2e/e2e-profile/e2e-profile-es-test-runner/pom.xml b/test/e2e/e2e-profile/e2e-profile-es-test-runner/pom.xml
new file mode 100644
index 0000000..00de586
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-es-test-runner/pom.xml
@@ -0,0 +1,184 @@
+<?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>e2e-profile</artifactId>
+ <groupId>org.apache.skywalking</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>e2e-profile-es-test-runner</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>e2e-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>e2e-profile-service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>e2e-profile-test-runner</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <provider.name>e2e-profile-service</provider.name>
+ <e2e.container.version>1.1</e2e.container.version>
+ <e2e.container.name.prefix>skywalking-e2e-container-${build.id}-es-profile</e2e.container.name.prefix>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <configuration>
+ <containerNamePattern>%a-%t-%i</containerNamePattern>
+ <imagePullPolicy>Always</imagePullPolicy>
+ <images>
+ <image>
+ <name>elastic/elasticsearch:${elasticsearch.version}</name>
+ <alias>${e2e.container.name.prefix}-elasticsearch</alias>
+ <run>
+ <ports>
+ <port>es.port:9200</port>
+ </ports>
+ <wait>
+ <http>
+ <url>http://localhost:${es.port}</url>
+ <method>GET</method>
+ <status>200</status>
+ </http>
+ <time>120000</time>
+ </wait>
+ <env>
+ <discovery.type>single-node</discovery.type>
+ </env>
+ </run>
+ </image>
+ <image>
+ <name>zookeeper:${zookeeper.image.version}</name>
+ <alias>${e2e.container.name.prefix}-zookeeper</alias>
+ <run>
+ <ports>
+ <port>zk.port:2181</port>
+ </ports>
+ <wait>
+ <log>binding to port</log>
+ <time>120000</time>
+ </wait>
+ </run>
+ </image>
+ <image>
+ <name>skyapm/e2e-container:${e2e.container.version}</name>
+ <alias>${e2e.container.name.prefix}</alias>
+ <run>
+ <env>
+ <MODE>cluster</MODE>
+ <ES_VERSION>${elasticsearch.version}</ES_VERSION>
+ <SW_STORAGE_ES_CLUSTER_NODES>
+ ${e2e.container.name.prefix}-elasticsearch:9200
+ </SW_STORAGE_ES_CLUSTER_NODES>
+ <SW_CLUSTER_ZK_HOST_PORT>
+ ${e2e.container.name.prefix}-zookeeper:2181
+ </SW_CLUSTER_ZK_HOST_PORT>
+
+ <INSTRUMENTED_SERVICE_1>
+ ${provider.name}-${project.version}.jar
+ </INSTRUMENTED_SERVICE_1>
+ <INSTRUMENTED_SERVICE_1_OPTS>
+ -DSW_AGENT_COLLECTOR_BACKEND_SERVICES=127.0.0.1:11800
+ -DSW_AGENT_NAME=${provider.name}
+ -Dserver.port=9090
+ </INSTRUMENTED_SERVICE_1_OPTS>
+ </env>
+ <dependsOn>
+ <container>${e2e.container.name.prefix}-elasticsearch</container>
+ <container>${e2e.container.name.prefix}-zookeeper</container>
+ </dependsOn>
+ <ports>
+ <port>+webapp.host:webapp.port:8081</port>
+ <port>+service.host:service.port:9090</port>
+ </ports>
+ <links>
+ <link>${e2e.container.name.prefix}-elasticsearch</link>
+ <link>${e2e.container.name.prefix}-zookeeper</link>
+ </links>
+ <volumes>
+ <bind>
+ <volume>${sw.home}:/sw</volume>
+ <volume>
+ ../${provider.name}/target/${provider.name}-${project.version}.jar:/home/${provider.name}-${project.version}.jar
+ </volume>
+ <volume>
+ ${project.basedir}/src/docker/rc.d:/rc.d:ro
+ </volume>
+ <volume>
+ ${project.basedir}/src/docker/clusterize.awk:/clusterize.awk
+ </volume>
+ </bind>
+ </volumes>
+ <wait>
+ <log>SkyWalking e2e container is ready for tests</log>
+ <time>3000000</time>
+ </wait>
+ </run>
+ </image>
+ </images>
+ </configuration>
+ </plugin>
+
+ <!-- set the system properties that can be used in test codes -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <sw.webapp.host>${webapp.host}</sw.webapp.host>
+ <sw.webapp.port>${webapp.port}</sw.webapp.port>
+ <service.host>${service.host}</service.host>
+ <service.port>${service.port}</service.port>
+ <provider.name>${provider.name}</provider.name>
+ <consumer.name>${consumer.name}</consumer.name>
+ </systemPropertyVariables>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
diff --git a/test/e2e/e2e-profile/e2e-profile-es-test-runner/src/docker/clusterize.awk b/test/e2e/e2e-profile/e2e-profile-es-test-runner/src/docker/clusterize.awk
new file mode 100644
index 0000000..830ede7
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-es-test-runner/src/docker/clusterize.awk
@@ -0,0 +1,96 @@
+# 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.
+
+#!/usr/bin/awk -f
+
+BEGIN {
+ in_cluster_section=0;
+ in_cluster_zk_section=0;
+
+ in_storage_section=0;
+ in_storage_es_section=0;
+ in_storage_h2_section=0;
+}
+
+{
+ if (in_cluster_section == 0) {
+ in_cluster_section=$0 ~ /^cluster:$/
+ } else {
+ in_cluster_section=$0 ~ /^(#|\s{2})/
+ }
+ if (in_storage_section == 0) {
+ in_storage_section=$0 ~ /^storage:$/
+ } else {
+ in_storage_section=$0 ~ /^(#|\s{2})/
+ }
+
+ if (in_cluster_section == 1) {
+ # in the cluster: section now
+ # disable standalone module
+ if ($0 ~ /^ standalone:$/) {
+ print "#" $0
+ } else {
+ if (in_cluster_zk_section == 0) {
+ in_cluster_zk_section=$0 ~ /^#?\s+zookeeper:$/
+ } else {
+ in_cluster_zk_section=$0 ~ /^(#\s{4}|\s{2})/
+ }
+ if (in_cluster_zk_section == 1) {
+ # in the cluster.zookeeper section now
+ # uncomment zk config
+ gsub("^#", "", $0)
+ print
+ } else {
+ print
+ }
+ }
+ } else if (in_storage_section == 1) {
+ # in the storage: section now
+ # disable h2 module
+ if (in_storage_es_section == 0) {
+ if (ENVIRON["ES_VERSION"] ~ /^6.+/) {
+ in_storage_es_section=$0 ~ /^#?\s+elasticsearch:$/
+ } else if (ENVIRON["ES_VERSION"] ~ /^7.+/) {
+ in_storage_es_section=$0 ~ /^#?\s+elasticsearch7:$/
+ }
+ } else {
+ in_storage_es_section=$0 ~ /^#?\s{4}/
+ }
+ if (in_storage_h2_section == 0) {
+ in_storage_h2_section=$0 ~ /^#?\s+h2:$/
+ } else {
+ in_storage_h2_section=$0 ~ /^#?\s{4}/
+ }
+ if (in_storage_es_section == 1) {
+ # in the storage.elasticsearch section now
+ # uncomment es config
+ gsub("^#", "", $0)
+ print
+ } else if (in_storage_h2_section == 1) {
+ # comment out h2 config
+ if ($0 !~ /^#/) {
+ print "#" $0
+ } else {
+ print
+ }
+ } else {
+ print
+ }
+ } else {
+ print
+ }
+}
+
diff --git a/test/e2e/e2e-profile/e2e-profile-es-test-runner/src/docker/rc.d/rc0-prepare.sh b/test/e2e/e2e-profile/e2e-profile-es-test-runner/src/docker/rc.d/rc0-prepare.sh
new file mode 100755
index 0000000..4a96718
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-es-test-runner/src/docker/rc.d/rc0-prepare.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+# Licensed to the SkyAPM 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.
+
+apt-get update && apt-get install -y gawk
+
+if test "${MODE}" = "cluster"; then
+ original_wd=$(pwd)
+
+ # substitute application.yml to be capable of cluster mode
+ cd ${SW_HOME}/config \
+ && gawk -f /clusterize.awk application.yml > clusterized_app.yml \
+ && mv clusterized_app.yml application.yml \
+ && sed '/<Loggers>/a<logger name="org.apache.skywalking.oap.server.receiver.trace.provider.UninstrumentedGatewaysConfig" level="DEBUG"/>\
+ \n<logger name="org.apache.skywalking.oap.server.receiver.trace.provider.parser.listener.service.ServiceMappingSpanListener" level="DEBUG"/>' log4j2.xml > log4j2debuggable.xml \
+ && mv log4j2debuggable.xml log4j2.xml
+
+ cd ${original_wd}
+fi
diff --git a/test/e2e/e2e-profile/e2e-profile-es-test-runner/src/docker/rc.d/rc1-startup.sh b/test/e2e/e2e-profile/e2e-profile-es-test-runner/src/docker/rc.d/rc1-startup.sh
new file mode 100755
index 0000000..b423561
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-es-test-runner/src/docker/rc.d/rc1-startup.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+# Licensed to the SkyAPM 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.
+
+echo 'starting OAP server...' \
+ && SW_STORAGE_ES_BULK_ACTIONS=1 \
+ SW_STORAGE_ES_FLUSH_INTERVAL=1 \
+ SW_RECEIVER_BUFFER_PATH=/tmp/oap/trace_buffer1 \
+ SW_SERVICE_MESH_BUFFER_PATH=/tmp/oap/mesh_buffer1 \
+ start_oap 'init'
+
+echo 'starting Web app...' \
+ && start_webapp '0.0.0.0' 8081
+
+echo 'starting instrumented services...' && start_instrumented_services
+
+check_tcp 127.0.0.1 \
+ 9090 \
+ 60 \
+ 10 \
+ "waiting for the instrumented service 0 to be ready"
+
+if [[ $? -ne 0 ]]; then
+ echo "instrumented service 0 failed to start in 30 * 10 seconds: "
+ cat ${SERVICE_LOG}/*
+ exit 1
+fi
+
+echo "SkyWalking e2e container is ready for tests"
+
+tail -f ${OAP_LOG_DIR}/* \
+ ${WEBAPP_LOG_DIR}/* \
+ ${SERVICE_LOG}/* \
+ ${ES_HOME}/logs/elasticsearch.log \
+ ${ES_HOME}/logs/stdout.log
\ No newline at end of file
diff --git a/test/e2e/e2e-profile/e2e-profile-es-test-runner/src/test/java/org/apache/skywalking/e2e/ProfileVerificationITCase.java b/test/e2e/e2e-profile/e2e-profile-es-test-runner/src/test/java/org/apache/skywalking/e2e/ProfileVerificationITCase.java
new file mode 100644
index 0000000..c6ded0f
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-es-test-runner/src/test/java/org/apache/skywalking/e2e/ProfileVerificationITCase.java
@@ -0,0 +1,218 @@
+/*
+ * 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 org.apache.skywalking.e2e.profile.ProfileClient;
+import org.apache.skywalking.e2e.profile.creation.ProfileTaskCreationRequest;
+import org.apache.skywalking.e2e.profile.creation.ProfileTaskCreationResult;
+import org.apache.skywalking.e2e.profile.creation.ProfileTaskCreationResultMatcher;
+import org.apache.skywalking.e2e.profile.query.ProfileTaskQuery;
+import org.apache.skywalking.e2e.profile.query.ProfileTasks;
+import org.apache.skywalking.e2e.profile.query.ProfilesTasksMatcher;
+import org.apache.skywalking.e2e.service.Service;
+import org.apache.skywalking.e2e.service.ServicesMatcher;
+import org.apache.skywalking.e2e.service.ServicesQuery;
+import org.apache.skywalking.e2e.service.endpoint.EndpointQuery;
+import org.apache.skywalking.e2e.service.endpoint.Endpoints;
+import org.apache.skywalking.e2e.service.endpoint.EndpointsMatcher;
+import org.apache.skywalking.e2e.service.instance.Instances;
+import org.apache.skywalking.e2e.service.instance.InstancesMatcher;
+import org.apache.skywalking.e2e.service.instance.InstancesQuery;
+import org.apache.skywalking.e2e.trace.Trace;
+import org.apache.skywalking.e2e.trace.TracesQuery;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.web.client.RestTemplate;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.InputStream;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * @author Mrpro
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+public class ProfileVerificationITCase {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ProfileVerificationITCase.class);
+
+ private final RestTemplate restTemplate = new RestTemplate();
+ private final int retryInterval = 30;
+
+ private ProfileClient profileClient;
+ private String instrumentedServiceUrl;
+
+ @Before
+ public void setUp() {
+ final String swWebappHost = System.getProperty("sw.webapp.host", "127.0.0.1");
+// final String swWebappPort = System.getProperty("sw.webapp.port", "32783");
+ final String swWebappPort = System.getProperty("sw.webapp.port", "12800");
+ final String instrumentedServiceHost = System.getProperty("service.host", "127.0.0.1");
+ final String instrumentedServicePort = System.getProperty("service.port", "32782");
+ profileClient = new ProfileClient(swWebappHost, swWebappPort);
+ instrumentedServiceUrl = "http://" + instrumentedServiceHost + ":" + instrumentedServicePort;
+ }
+
+ @Test(timeout = 1200000)
+ @DirtiesContext
+ public void verify() throws Exception {
+ final LocalDateTime minutesAgo = LocalDateTime.now(ZoneOffset.UTC);
+
+ while (true) {
+ try {
+ final Map<String, String> user = new HashMap<>();
+ user.put("name", "SkyWalking");
+ final ResponseEntity<String> responseEntity = restTemplate.postForEntity(
+ instrumentedServiceUrl + "/e2e/users",
+ user,
+ String.class
+ );
+ LOGGER.info("responseEntity: {}", responseEntity);
+ assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
+ final List<Trace> traces = profileClient.traces(
+ new TracesQuery()
+ .start(minutesAgo)
+ .end(LocalDateTime.now())
+ .orderByDuration()
+ );
+ if (!traces.isEmpty()) {
+ break;
+ }
+ Thread.sleep(10000L);
+ } catch (Exception ignored) {
+ LOGGER.error(ignored.getMessage(), ignored);
+ }
+ }
+
+ // verify basic info
+ verifyServices(minutesAgo);
+
+ // create profile task
+ verifyCreateProfileTask(minutesAgo);
+
+ }
+
+ /**
+ * verify create profile task
+ * @param minutesAgo
+ * @throws Exception
+ */
+ private void verifyCreateProfileTask(LocalDateTime minutesAgo) throws Exception {
+ final LocalDateTime now = LocalDateTime.now(ZoneOffset.UTC);
+
+ final ProfileTaskCreationRequest creationRequest = ProfileTaskCreationRequest.builder()
+ .serviceId(2)
+ .endpointName("/e2e/users")
+ .duration(5)
+ .startTime(-1)
+ .minDurationThreshold(10)
+ .dumpPeriod(10).build();
+
+ // verify create task
+ final ProfileTaskCreationResult creationResult = profileClient.createProfileTask(creationRequest);
+ LOGGER.info("create profile task result: {}", creationResult);
+
+ ProfileTaskCreationResultMatcher creationResultMatcher = new ProfileTaskCreationResultMatcher();
+ creationResultMatcher.verify(creationResult);
+
+ // verify get task list
+ final ProfileTasks tasks = profileClient.getProfileTaskList(
+ new ProfileTaskQuery()
+ .serviceId(creationRequest.getServiceId())
+ .endpointName("")
+ );
+ LOGGER.info("get profile task list: {}", tasks);
+
+ InputStream expectedInputStream =
+ new ClassPathResource("expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.profileTasks.yml").getInputStream();
+
+ final ProfilesTasksMatcher servicesMatcher = new Yaml().loadAs(expectedInputStream, ProfilesTasksMatcher.class);
+ servicesMatcher.verify(tasks);
+ }
+
+ private void verifyServices(LocalDateTime minutesAgo) throws Exception {
+ final LocalDateTime now = LocalDateTime.now(ZoneOffset.UTC);
+
+ final List<Service> services = profileClient.services(
+ new ServicesQuery()
+ .start(minutesAgo)
+ .end(now)
+ );
+ LOGGER.info("services: {}", services);
+
+ InputStream expectedInputStream =
+ new ClassPathResource("expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.services.yml").getInputStream();
+
+ final ServicesMatcher servicesMatcher = new Yaml().loadAs(expectedInputStream, ServicesMatcher.class);
+ servicesMatcher.verify(services);
+
+ for (Service service : services) {
+ LOGGER.info("verifying service instances: {}", service);
+
+ verifyServiceInstances(minutesAgo, now, service);
+
+ verifyServiceEndpoints(minutesAgo, now, service);
+
+ }
+ }
+
+ private Instances verifyServiceInstances(LocalDateTime minutesAgo, LocalDateTime now,
+ Service service) throws Exception {
+ InputStream expectedInputStream;
+ Instances instances = profileClient.instances(
+ new InstancesQuery()
+ .serviceId(service.getKey())
+ .start(minutesAgo)
+ .end(now)
+ );
+ LOGGER.info("instances: {}", instances);
+ expectedInputStream =
+ new ClassPathResource("expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.instances.yml").getInputStream();
+ final InstancesMatcher instancesMatcher = new Yaml().loadAs(expectedInputStream, InstancesMatcher.class);
+ instancesMatcher.verify(instances);
+ return instances;
+ }
+
+ private Endpoints verifyServiceEndpoints(LocalDateTime minutesAgo, LocalDateTime now,
+ Service service) throws Exception {
+ Endpoints instances = profileClient.endpoints(
+ new EndpointQuery().serviceId(service.getKey())
+ );
+ LOGGER.info("instances: {}", instances);
+ InputStream expectedInputStream =
+ new ClassPathResource("expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.endpoints.yml").getInputStream();
+ final EndpointsMatcher endpointsMatcher = new Yaml().loadAs(expectedInputStream, EndpointsMatcher.class);
+ endpointsMatcher.verify(instances);
+ return instances;
+ }
+
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-h2-test-runner/pom.xml b/test/e2e/e2e-profile/e2e-profile-h2-test-runner/pom.xml
new file mode 100644
index 0000000..993eb1d
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-h2-test-runner/pom.xml
@@ -0,0 +1,132 @@
+<?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>e2e-profile</artifactId>
+ <groupId>org.apache.skywalking</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>e2e-profile-h2-test-runner</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>e2e-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>e2e-profile-service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>e2e-profile-test-runner</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <provider.name>e2e-profile-service</provider.name>
+ <e2e.container.version>1.1</e2e.container.version>
+ <e2e.container.name.prefix>skywalking-e2e-container-${build.id}-h2-profile</e2e.container.name.prefix>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <configuration>
+ <containerNamePattern>%a-%t-%i</containerNamePattern>
+ <imagePullPolicy>Always</imagePullPolicy>
+ <images>
+ <image>
+ <name>skyapm/e2e-container:${e2e.container.version}</name>
+ <alias>${e2e.container.name.prefix}</alias>
+ <run>
+ <env>
+ <MODE>profile</MODE>
+ <INSTRUMENTED_SERVICE_1>
+ ${provider.name}-${project.version}.jar
+ </INSTRUMENTED_SERVICE_1>
+ <INSTRUMENTED_SERVICE_1_OPTS>
+ -DSW_AGENT_COLLECTOR_BACKEND_SERVICES=127.0.0.1:11800
+ -DSW_AGENT_NAME=${provider.name}
+ -Dserver.port=9090
+ </INSTRUMENTED_SERVICE_1_OPTS>
+ </env>
+ <ports>
+ <port>+webapp.host:webapp.port:8081</port>
+ <port>+service.host:service.port:9090</port>
+ </ports>
+ <volumes>
+ <bind>
+ <volume>${sw.home}:/sw</volume>
+ <volume>
+ ../${provider.name}/target/${provider.name}-${project.version}.jar:/home/${provider.name}-${project.version}.jar
+ </volume>
+ <volume>
+ ${project.basedir}/src/docker/rc.d:/rc.d:ro
+ </volume>
+ </bind>
+ </volumes>
+ <wait>
+ <log>SkyWalking e2e container is ready for tests</log>
+ <time>3000000</time>
+ </wait>
+ </run>
+ </image>
+ </images>
+ </configuration>
+ </plugin>
+
+ <!-- set the system properties that can be used in test codes -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <sw.webapp.host>${webapp.host}</sw.webapp.host>
+ <sw.webapp.port>${webapp.port}</sw.webapp.port>
+ <service.host>${service.host}</service.host>
+ <service.port>${service.port}</service.port>
+ <provider.name>${provider.name}</provider.name>
+ </systemPropertyVariables>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
\ No newline at end of file
diff --git a/test/e2e/e2e-profile/e2e-profile-h2-test-runner/src/docker/rc.d/rc1-startup.sh b/test/e2e/e2e-profile/e2e-profile-h2-test-runner/src/docker/rc.d/rc1-startup.sh
new file mode 100755
index 0000000..4a9f43c
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-h2-test-runner/src/docker/rc.d/rc1-startup.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+# Licensed to the SkyAPM 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.
+
+echo 'starting OAP server...' \
+ && SW_STORAGE_ES_BULK_ACTIONS=1 \
+ SW_STORAGE_ES_FLUSH_INTERVAL=1 \
+ SW_RECEIVER_BUFFER_PATH=/tmp/oap/trace_buffer1 \
+ SW_SERVICE_MESH_BUFFER_PATH=/tmp/oap/mesh_buffer1 \
+ start_oap 'init'
+
+echo 'starting Web app...' \
+ && start_webapp '0.0.0.0' 8081
+
+echo 'starting instrumented services...' && start_instrumented_services
+
+check_tcp 127.0.0.1 \
+ 9090 \
+ 60 \
+ 10 \
+ "waiting for the instrumented service 0 to be ready"
+
+if [[ $? -ne 0 ]]; then
+ echo "instrumented service 0 failed to start in 30 * 10 seconds: "
+ cat ${SERVICE_LOG}/*
+ exit 1
+fi
+
+echo "SkyWalking e2e container is ready for tests"
+
+tail -f ${OAP_LOG_DIR}/* \
+ ${WEBAPP_LOG_DIR}/* \
+ ${SERVICE_LOG}/*
diff --git a/test/e2e/e2e-profile/e2e-profile-h2-test-runner/src/test/java/org/apache/skywalking/e2e/ProfileVerificationITCase.java b/test/e2e/e2e-profile/e2e-profile-h2-test-runner/src/test/java/org/apache/skywalking/e2e/ProfileVerificationITCase.java
new file mode 100644
index 0000000..8fa6128
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-h2-test-runner/src/test/java/org/apache/skywalking/e2e/ProfileVerificationITCase.java
@@ -0,0 +1,217 @@
+/*
+ * 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 org.apache.skywalking.e2e.profile.ProfileClient;
+import org.apache.skywalking.e2e.profile.creation.ProfileTaskCreationRequest;
+import org.apache.skywalking.e2e.profile.creation.ProfileTaskCreationResult;
+import org.apache.skywalking.e2e.profile.creation.ProfileTaskCreationResultMatcher;
+import org.apache.skywalking.e2e.profile.query.ProfileTaskQuery;
+import org.apache.skywalking.e2e.profile.query.ProfileTasks;
+import org.apache.skywalking.e2e.profile.query.ProfilesTasksMatcher;
+import org.apache.skywalking.e2e.service.Service;
+import org.apache.skywalking.e2e.service.ServicesMatcher;
+import org.apache.skywalking.e2e.service.ServicesQuery;
+import org.apache.skywalking.e2e.service.endpoint.EndpointQuery;
+import org.apache.skywalking.e2e.service.endpoint.Endpoints;
+import org.apache.skywalking.e2e.service.endpoint.EndpointsMatcher;
+import org.apache.skywalking.e2e.service.instance.Instances;
+import org.apache.skywalking.e2e.service.instance.InstancesMatcher;
+import org.apache.skywalking.e2e.service.instance.InstancesQuery;
+import org.apache.skywalking.e2e.trace.Trace;
+import org.apache.skywalking.e2e.trace.TracesQuery;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.web.client.RestTemplate;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.InputStream;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * @author Mrpro
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+public class ProfileVerificationITCase {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ProfileVerificationITCase.class);
+
+ private final RestTemplate restTemplate = new RestTemplate();
+ private final int retryInterval = 30;
+
+ private ProfileClient profileClient;
+ private String instrumentedServiceUrl;
+
+ @Before
+ public void setUp() {
+ final String swWebappHost = System.getProperty("sw.webapp.host", "127.0.0.1");
+ // final String swWebappPort = System.getProperty("sw.webapp.port", "32783");
+ final String swWebappPort = System.getProperty("sw.webapp.port", "12800");
+ final String instrumentedServiceHost = System.getProperty("service.host", "127.0.0.1");
+ final String instrumentedServicePort = System.getProperty("service.port", "32782");
+ profileClient = new ProfileClient(swWebappHost, swWebappPort);
+ instrumentedServiceUrl = "http://" + instrumentedServiceHost + ":" + instrumentedServicePort;
+ }
+
+ @Test(timeout = 1200000)
+ @DirtiesContext
+ public void verify() throws Exception {
+ final LocalDateTime minutesAgo = LocalDateTime.now(ZoneOffset.UTC);
+
+ while (true) {
+ try {
+ final Map<String, String> user = new HashMap<>();
+ user.put("name", "SkyWalking");
+ final ResponseEntity<String> responseEntity = restTemplate.postForEntity(
+ instrumentedServiceUrl + "/e2e/users",
+ user,
+ String.class
+ );
+ LOGGER.info("responseEntity: {}", responseEntity);
+ assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
+ final List<Trace> traces = profileClient.traces(
+ new TracesQuery()
+ .start(minutesAgo)
+ .end(LocalDateTime.now())
+ .orderByDuration()
+ );
+ if (!traces.isEmpty()) {
+ break;
+ }
+ Thread.sleep(10000L);
+ } catch (Exception ignored) {
+ }
+ }
+
+ // verify basic info
+ verifyServices(minutesAgo);
+
+ // create profile task
+ verifyCreateProfileTask(minutesAgo);
+
+ }
+
+ /**
+ * verify create profile task
+ * @param minutesAgo
+ * @throws Exception
+ */
+ private void verifyCreateProfileTask(LocalDateTime minutesAgo) throws Exception {
+ final LocalDateTime now = LocalDateTime.now(ZoneOffset.UTC);
+
+ final ProfileTaskCreationRequest creationRequest = ProfileTaskCreationRequest.builder()
+ .serviceId(2)
+ .endpointName("/e2e/users")
+ .duration(5)
+ .startTime(-1)
+ .minDurationThreshold(10)
+ .dumpPeriod(10).build();
+
+ // verify create task
+ final ProfileTaskCreationResult creationResult = profileClient.createProfileTask(creationRequest);
+ LOGGER.info("create profile task result: {}", creationResult);
+
+ ProfileTaskCreationResultMatcher creationResultMatcher = new ProfileTaskCreationResultMatcher();
+ creationResultMatcher.verify(creationResult);
+
+ // verify get task list
+ final ProfileTasks tasks = profileClient.getProfileTaskList(
+ new ProfileTaskQuery()
+ .serviceId(creationRequest.getServiceId())
+ .endpointName("")
+ );
+ LOGGER.info("get profile task list: {}", tasks);
+
+ InputStream expectedInputStream =
+ new ClassPathResource("expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.profileTasks.yml").getInputStream();
+
+ final ProfilesTasksMatcher servicesMatcher = new Yaml().loadAs(expectedInputStream, ProfilesTasksMatcher.class);
+ servicesMatcher.verify(tasks);
+ }
+
+ private void verifyServices(LocalDateTime minutesAgo) throws Exception {
+ final LocalDateTime now = LocalDateTime.now(ZoneOffset.UTC);
+
+ final List<Service> services = profileClient.services(
+ new ServicesQuery()
+ .start(minutesAgo)
+ .end(now)
+ );
+ LOGGER.info("services: {}", services);
+
+ InputStream expectedInputStream =
+ new ClassPathResource("expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.services.yml").getInputStream();
+
+ final ServicesMatcher servicesMatcher = new Yaml().loadAs(expectedInputStream, ServicesMatcher.class);
+ servicesMatcher.verify(services);
+
+ for (Service service : services) {
+ LOGGER.info("verifying service instances: {}", service);
+
+ verifyServiceInstances(minutesAgo, now, service);
+
+ verifyServiceEndpoints(minutesAgo, now, service);
+
+ }
+ }
+
+ private Instances verifyServiceInstances(LocalDateTime minutesAgo, LocalDateTime now,
+ Service service) throws Exception {
+ InputStream expectedInputStream;
+ Instances instances = profileClient.instances(
+ new InstancesQuery()
+ .serviceId(service.getKey())
+ .start(minutesAgo)
+ .end(now)
+ );
+ LOGGER.info("instances: {}", instances);
+ expectedInputStream =
+ new ClassPathResource("expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.instances.yml").getInputStream();
+ final InstancesMatcher instancesMatcher = new Yaml().loadAs(expectedInputStream, InstancesMatcher.class);
+ instancesMatcher.verify(instances);
+ return instances;
+ }
+
+ private Endpoints verifyServiceEndpoints(LocalDateTime minutesAgo, LocalDateTime now,
+ Service service) throws Exception {
+ Endpoints instances = profileClient.endpoints(
+ new EndpointQuery().serviceId(service.getKey())
+ );
+ LOGGER.info("instances: {}", instances);
+ InputStream expectedInputStream =
+ new ClassPathResource("expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.endpoints.yml").getInputStream();
+ final EndpointsMatcher endpointsMatcher = new Yaml().loadAs(expectedInputStream, EndpointsMatcher.class);
+ endpointsMatcher.verify(instances);
+ return instances;
+ }
+
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-mysql-test-runner/pom.xml b/test/e2e/e2e-profile/e2e-profile-mysql-test-runner/pom.xml
new file mode 100644
index 0000000..a1901bc
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-mysql-test-runner/pom.xml
@@ -0,0 +1,158 @@
+<?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>e2e-profile</artifactId>
+ <groupId>org.apache.skywalking</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>e2e-profile-mysql-test-runner</artifactId>
+
+ <properties>
+ <provider.name>e2e-profile-service</provider.name>
+ <e2e.container.version>1.1</e2e.container.version>
+ <e2e.container.name.prefix>skywalking-e2e-container-${build.id}-mysql-profile</e2e.container.name.prefix>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>e2e-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>e2e-profile-service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>e2e-profile-test-runner</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <configuration>
+ <containerNamePattern>%a-%t-%i</containerNamePattern>
+ <images>
+ <image>
+ <name>mysql/mysql-server:${mysql.version}</name>
+ <alias>${e2e.container.name.prefix}-mysql</alias>
+ <run>
+ <wait>
+ <log>Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 3306</log>
+ <time>120000</time>
+ </wait>
+ <env>
+ <MYSQL_ROOT_PASSWORD>root@1234</MYSQL_ROOT_PASSWORD>
+ <MYSQL_DATABASE>swtest</MYSQL_DATABASE>
+ <MYSQL_ROOT_HOST>%</MYSQL_ROOT_HOST>
+ </env>
+ <ports>
+ <port>mysql.port:3306</port>
+ </ports>
+ </run>
+ </image>
+ <image>
+ <name>skyapm/e2e-container:${e2e.container.version}</name>
+ <alias>${e2e.container.name.prefix}</alias>
+ <run>
+ <env>
+ <MODE>profile</MODE>
+ <SW_JDBC_URL>jdbc:mysql://${e2e.container.name.prefix}-mysql:3306/swtest</SW_JDBC_URL>
+ <INSTRUMENTED_SERVICE_1>
+ ${provider.name}-${project.version}.jar
+ </INSTRUMENTED_SERVICE_1>
+ <INSTRUMENTED_SERVICE_1_OPTS>
+ -DSW_AGENT_COLLECTOR_BACKEND_SERVICES=127.0.0.1:11800
+ -DSW_AGENT_NAME=${provider.name}
+ -Dserver.port=9090
+ </INSTRUMENTED_SERVICE_1_OPTS>
+ </env>
+ <dependsOn>
+ <container>${e2e.container.name.prefix}-mysql</container>
+ </dependsOn>
+ <links>
+ <link>${e2e.container.name.prefix}-mysql</link>
+ </links>
+ <ports>
+ <port>+webapp.host:webapp.port:8081</port>
+ <port>+service.host:service.port:9090</port>
+ </ports>
+ <volumes>
+ <bind>
+ <volume>${sw.home}:/sw</volume>
+ <volume>${project.build.directory}:/home</volume>
+ <volume>${project.basedir}/src/docker/rc.d:/rc.d:ro</volume>
+ <volume>${project.basedir}/src/docker/application.yml:/application.yml</volume>
+ <volume>
+ ../${provider.name}/target/${provider.name}-${project.version}.jar:/home/${provider.name}-${project.version}.jar
+ </volume>
+ </bind>
+ </volumes>
+ <wait>
+ <log>SkyWalking e2e container is ready for tests</log>
+ <time>3000000</time>
+ </wait>
+ </run>
+ </image>
+ </images>
+ </configuration>
+ </plugin>
+
+ <!-- set the system properties that can be used in test codes -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <sw.webapp.host>${webapp.host}</sw.webapp.host>
+ <sw.webapp.port>${webapp.port}</sw.webapp.port>
+ <service.host>${service.host}</service.host>
+ <service.port>${service.port}</service.port>
+ <provider.name>${provider.name}</provider.name>
+ </systemPropertyVariables>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+
+
+</project>
\ No newline at end of file
diff --git a/test/e2e/e2e-mysql/src/docker/application.yml b/test/e2e/e2e-profile/e2e-profile-mysql-test-runner/src/docker/application.yml
similarity index 99%
copy from test/e2e/e2e-mysql/src/docker/application.yml
copy to test/e2e/e2e-profile/e2e-profile-mysql-test-runner/src/docker/application.yml
index bb7f189..343c5cf 100644
--- a/test/e2e/e2e-mysql/src/docker/application.yml
+++ b/test/e2e/e2e-profile/e2e-profile-mysql-test-runner/src/docker/application.yml
@@ -92,6 +92,7 @@ storage:
# concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2} # the number of concurrent requests
# metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
# segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
+# profileTaskQueryMaxSize: ${SW_STORAGE_ES_QUERY_PROFILE_TASK_SIZE:200}
# h2:
# driver: ${SW_STORAGE_H2_DRIVER:org.h2.jdbcx.JdbcDataSource}
# url: ${SW_STORAGE_H2_URL:jdbc:h2:mem:skywalking-oap-db}
diff --git a/test/e2e/e2e-profile/e2e-profile-mysql-test-runner/src/docker/rc.d/rc0-prepare.sh b/test/e2e/e2e-profile/e2e-profile-mysql-test-runner/src/docker/rc.d/rc0-prepare.sh
new file mode 100755
index 0000000..f6c1d0e
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-mysql-test-runner/src/docker/rc.d/rc0-prepare.sh
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+# Licensed to the SkyAPM 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.
+
+MYSQL_URL="http://central.maven.org/maven2/mysql/mysql-connector-java/8.0.13/mysql-connector-java-8.0.13.jar"
+MYSQL_DRIVER="mysql-connector-java-8.0.13.jar"
+
+echo "MySQL database is storage provider..."
+# Download MySQL connector.
+curl ${MYSQL_URL} > "${SW_HOME}/oap-libs/${MYSQL_DRIVER}"
+[[ $? -ne 0 ]] && echo "Fail to download ${MYSQL_DRIVER}." && exit 1
+
+# Modify application.yml to set MySQL as storage provider.
+cat /application.yml > "${SW_HOME}/config/application.yml"
diff --git a/test/e2e/e2e-profile/e2e-profile-mysql-test-runner/src/docker/rc.d/rc1-startup.sh b/test/e2e/e2e-profile/e2e-profile-mysql-test-runner/src/docker/rc.d/rc1-startup.sh
new file mode 100755
index 0000000..f9382e4
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-mysql-test-runner/src/docker/rc.d/rc1-startup.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+# Licensed to the SkyAPM 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.
+
+echo 'starting OAP server...' && start_oap 'init'
+
+echo 'starting Web app...' && start_webapp '0.0.0.0' 8081
+
+echo 'starting instrumented services...' && start_instrumented_services
+
+check_tcp 127.0.0.1 \
+ 9090 \
+ 60 \
+ 10 \
+ "waiting for the instrumented service to be ready"
+
+if [[ $? -ne 0 ]]; then
+ echo "instrumented service 0 failed to start in 30 * 10 seconds: "
+ cat ${SERVICE_LOG}/*
+ exit 1
+fi
+
+echo "SkyWalking e2e container is ready for tests"
+
+tail -f ${OAP_LOG_DIR}/* \
+ ${WEBAPP_LOG_DIR}/* \
+ ${SERVICE_LOG}/*
diff --git a/test/e2e/e2e-profile/e2e-profile-mysql-test-runner/src/test/java/org/apache/skywalking/e2e/ProfileVerificationITCase.java b/test/e2e/e2e-profile/e2e-profile-mysql-test-runner/src/test/java/org/apache/skywalking/e2e/ProfileVerificationITCase.java
new file mode 100644
index 0000000..a82b47b
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-mysql-test-runner/src/test/java/org/apache/skywalking/e2e/ProfileVerificationITCase.java
@@ -0,0 +1,217 @@
+/*
+ * 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 org.apache.skywalking.e2e.profile.ProfileClient;
+import org.apache.skywalking.e2e.profile.creation.ProfileTaskCreationRequest;
+import org.apache.skywalking.e2e.profile.creation.ProfileTaskCreationResult;
+import org.apache.skywalking.e2e.profile.creation.ProfileTaskCreationResultMatcher;
+import org.apache.skywalking.e2e.profile.query.ProfileTaskQuery;
+import org.apache.skywalking.e2e.profile.query.ProfileTasks;
+import org.apache.skywalking.e2e.profile.query.ProfilesTasksMatcher;
+import org.apache.skywalking.e2e.service.Service;
+import org.apache.skywalking.e2e.service.ServicesMatcher;
+import org.apache.skywalking.e2e.service.ServicesQuery;
+import org.apache.skywalking.e2e.service.endpoint.EndpointQuery;
+import org.apache.skywalking.e2e.service.endpoint.Endpoints;
+import org.apache.skywalking.e2e.service.endpoint.EndpointsMatcher;
+import org.apache.skywalking.e2e.service.instance.Instances;
+import org.apache.skywalking.e2e.service.instance.InstancesMatcher;
+import org.apache.skywalking.e2e.service.instance.InstancesQuery;
+import org.apache.skywalking.e2e.trace.Trace;
+import org.apache.skywalking.e2e.trace.TracesQuery;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.web.client.RestTemplate;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.InputStream;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * @author Mrpro
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+public class ProfileVerificationITCase {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ProfileVerificationITCase.class);
+
+ private final RestTemplate restTemplate = new RestTemplate();
+ private final int retryInterval = 30;
+
+ private ProfileClient profileClient;
+ private String instrumentedServiceUrl;
+
+ @Before
+ public void setUp() {
+ final String swWebappHost = System.getProperty("sw.webapp.host", "127.0.0.1");
+// final String swWebappPort = System.getProperty("sw.webapp.port", "32783");
+ final String swWebappPort = System.getProperty("sw.webapp.port", "12800");
+ final String instrumentedServiceHost = System.getProperty("service.host", "127.0.0.1");
+ final String instrumentedServicePort = System.getProperty("service.port", "32782");
+ profileClient = new ProfileClient(swWebappHost, swWebappPort);
+ instrumentedServiceUrl = "http://" + instrumentedServiceHost + ":" + instrumentedServicePort;
+ }
+
+ @Test(timeout = 1200000)
+ @DirtiesContext
+ public void verify() throws Exception {
+ final LocalDateTime minutesAgo = LocalDateTime.now(ZoneOffset.UTC);
+
+ while (true) {
+ try {
+ final Map<String, String> user = new HashMap<>();
+ user.put("name", "SkyWalking");
+ final ResponseEntity<String> responseEntity = restTemplate.postForEntity(
+ instrumentedServiceUrl + "/e2e/users",
+ user,
+ String.class
+ );
+ LOGGER.info("responseEntity: {}", responseEntity);
+ assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
+ final List<Trace> traces = profileClient.traces(
+ new TracesQuery()
+ .start(minutesAgo)
+ .end(LocalDateTime.now())
+ .orderByDuration()
+ );
+ if (!traces.isEmpty()) {
+ break;
+ }
+ Thread.sleep(10000L);
+ } catch (Exception ignored) {
+ }
+ }
+
+ // verify basic info
+ verifyServices(minutesAgo);
+
+ // create profile task
+ verifyCreateProfileTask(minutesAgo);
+
+ }
+
+ /**
+ * verify create profile task
+ * @param minutesAgo
+ * @throws Exception
+ */
+ private void verifyCreateProfileTask(LocalDateTime minutesAgo) throws Exception {
+ final LocalDateTime now = LocalDateTime.now(ZoneOffset.UTC);
+
+ final ProfileTaskCreationRequest creationRequest = ProfileTaskCreationRequest.builder()
+ .serviceId(2)
+ .endpointName("/e2e/users")
+ .duration(5)
+ .startTime(-1)
+ .minDurationThreshold(10)
+ .dumpPeriod(10).build();
+
+ // verify create task
+ final ProfileTaskCreationResult creationResult = profileClient.createProfileTask(creationRequest);
+ LOGGER.info("create profile task result: {}", creationResult);
+
+ ProfileTaskCreationResultMatcher creationResultMatcher = new ProfileTaskCreationResultMatcher();
+ creationResultMatcher.verify(creationResult);
+
+ // verify get task list
+ final ProfileTasks tasks = profileClient.getProfileTaskList(
+ new ProfileTaskQuery()
+ .serviceId(creationRequest.getServiceId())
+ .endpointName("")
+ );
+ LOGGER.info("get profile task list: {}", tasks);
+
+ InputStream expectedInputStream =
+ new ClassPathResource("expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.profileTasks.yml").getInputStream();
+
+ final ProfilesTasksMatcher servicesMatcher = new Yaml().loadAs(expectedInputStream, ProfilesTasksMatcher.class);
+ servicesMatcher.verify(tasks);
+ }
+
+ private void verifyServices(LocalDateTime minutesAgo) throws Exception {
+ final LocalDateTime now = LocalDateTime.now(ZoneOffset.UTC);
+
+ final List<Service> services = profileClient.services(
+ new ServicesQuery()
+ .start(minutesAgo)
+ .end(now)
+ );
+ LOGGER.info("services: {}", services);
+
+ InputStream expectedInputStream =
+ new ClassPathResource("expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.services.yml").getInputStream();
+
+ final ServicesMatcher servicesMatcher = new Yaml().loadAs(expectedInputStream, ServicesMatcher.class);
+ servicesMatcher.verify(services);
+
+ for (Service service : services) {
+ LOGGER.info("verifying service instances: {}", service);
+
+ verifyServiceInstances(minutesAgo, now, service);
+
+ verifyServiceEndpoints(minutesAgo, now, service);
+
+ }
+ }
+
+ private Instances verifyServiceInstances(LocalDateTime minutesAgo, LocalDateTime now,
+ Service service) throws Exception {
+ InputStream expectedInputStream;
+ Instances instances = profileClient.instances(
+ new InstancesQuery()
+ .serviceId(service.getKey())
+ .start(minutesAgo)
+ .end(now)
+ );
+ LOGGER.info("instances: {}", instances);
+ expectedInputStream =
+ new ClassPathResource("expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.instances.yml").getInputStream();
+ final InstancesMatcher instancesMatcher = new Yaml().loadAs(expectedInputStream, InstancesMatcher.class);
+ instancesMatcher.verify(instances);
+ return instances;
+ }
+
+ private Endpoints verifyServiceEndpoints(LocalDateTime minutesAgo, LocalDateTime now,
+ Service service) throws Exception {
+ Endpoints instances = profileClient.endpoints(
+ new EndpointQuery().serviceId(service.getKey())
+ );
+ LOGGER.info("instances: {}", instances);
+ InputStream expectedInputStream =
+ new ClassPathResource("expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.endpoints.yml").getInputStream();
+ final EndpointsMatcher endpointsMatcher = new Yaml().loadAs(expectedInputStream, EndpointsMatcher.class);
+ endpointsMatcher.verify(instances);
+ return instances;
+ }
+
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-service/pom.xml b/test/e2e/e2e-profile/e2e-profile-service/pom.xml
new file mode 100644
index 0000000..29ffb81
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-service/pom.xml
@@ -0,0 +1,74 @@
+<?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>e2e-profile</artifactId>
+ <groupId>org.apache.skywalking</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>e2e-profile-service</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ <version>${spring.boot.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>${h2.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>e2e-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <version>${spring.boot.version}</version>
+ <configuration>
+ <executable>true</executable>
+ <addResources>true</addResources>
+ <excludeDevtools>true</excludeDevtools>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
\ No newline at end of file
diff --git a/test/e2e/e2e-profile/e2e-profile-service/src/main/java/org/apache/skywalking/e2e/profile/ProfileApplication.java b/test/e2e/e2e-profile/e2e-profile-service/src/main/java/org/apache/skywalking/e2e/profile/ProfileApplication.java
new file mode 100644
index 0000000..5958107
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-service/src/main/java/org/apache/skywalking/e2e/profile/ProfileApplication.java
@@ -0,0 +1,34 @@
+/*
+ * 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.profile;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+
+/**
+ * @author MrPro
+ */
+@EnableJpaRepositories
+@SpringBootApplication
+public class ProfileApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(ProfileApplication.class, args);
+ }
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-service/src/main/java/org/apache/skywalking/e2e/profile/TestController.java b/test/e2e/e2e-profile/e2e-profile-service/src/main/java/org/apache/skywalking/e2e/profile/TestController.java
new file mode 100644
index 0000000..c300fc3
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-service/src/main/java/org/apache/skywalking/e2e/profile/TestController.java
@@ -0,0 +1,45 @@
+/*
+ * 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.profile;
+
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author MrPro
+ */
+@RestController
+@RequestMapping("/e2e")
+public class TestController {
+ private final UserRepo userRepo;
+
+ public TestController(final UserRepo userRepo) {
+ this.userRepo = userRepo;
+ }
+
+ @GetMapping("/health-check")
+ public String hello() {
+ return "healthy";
+ }
+
+ @PostMapping("/users")
+ public User createAuthor(@RequestBody final User user) throws InterruptedException {
+ Thread.sleep(1000L);
+ return userRepo.save(user);
+ }
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-service/src/main/java/org/apache/skywalking/e2e/profile/User.java b/test/e2e/e2e-profile/e2e-profile-service/src/main/java/org/apache/skywalking/e2e/profile/User.java
new file mode 100644
index 0000000..bcff90e
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-service/src/main/java/org/apache/skywalking/e2e/profile/User.java
@@ -0,0 +1,56 @@
+/*
+ * 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.profile;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author MrPro
+ */
+@Entity
+public class User {
+ public User() {
+ }
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ @Column
+ private String name;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(final Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-service/src/main/java/org/apache/skywalking/e2e/profile/UserRepo.java b/test/e2e/e2e-profile/e2e-profile-service/src/main/java/org/apache/skywalking/e2e/profile/UserRepo.java
new file mode 100644
index 0000000..f124a34
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-service/src/main/java/org/apache/skywalking/e2e/profile/UserRepo.java
@@ -0,0 +1,27 @@
+/*
+ * 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.profile;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+
+/**
+ * @author MrPro
+ */
+public interface UserRepo extends JpaRepository<User, Long> {
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-service/src/main/resources/application.yml b/test/e2e/e2e-profile/e2e-profile-service/src/main/resources/application.yml
new file mode 100644
index 0000000..ef3ed01
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-service/src/main/resources/application.yml
@@ -0,0 +1,35 @@
+# 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.
+
+server:
+ port: 9090
+
+spring:
+ main:
+ banner-mode: 'off'
+ datasource:
+ url: jdbc:h2:mem:testdb
+ driver-class-name: org.h2.Driver
+ data-username: sa
+ password: sa
+ platform: org.hibernate.dialect.H2Dialect
+ jpa:
+ generate-ddl: true
+ hibernate:
+ ddl-auto: create-drop
+ properties:
+ hibernate.format_sql: true
+ show-sql: true
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/pom.xml b/test/e2e/e2e-profile/e2e-profile-test-runner/pom.xml
new file mode 100644
index 0000000..3211261
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/pom.xml
@@ -0,0 +1,50 @@
+<?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>e2e-profile</artifactId>
+ <groupId>org.apache.skywalking</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>e2e-profile-test-runner</artifactId>
+
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>e2e-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>e2e-profile-service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
+
+
+</project>
\ No newline at end of file
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/ProfileClient.java b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/ProfileClient.java
new file mode 100644
index 0000000..bb53584
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/ProfileClient.java
@@ -0,0 +1,98 @@
+/*
+ * 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.profile;
+
+import com.google.common.io.Resources;
+import org.apache.skywalking.e2e.GQLResponse;
+import org.apache.skywalking.e2e.SimpleQueryClient;
+import org.apache.skywalking.e2e.profile.creation.ProfileTaskCreationRequest;
+import org.apache.skywalking.e2e.profile.creation.ProfileTaskCreationResult;
+import org.apache.skywalking.e2e.profile.creation.ProfileTaskCreationResultWrapper;
+import org.apache.skywalking.e2e.profile.query.ProfileTaskQuery;
+import org.apache.skywalking.e2e.profile.query.ProfileTasks;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.RequestEntity;
+import org.springframework.http.ResponseEntity;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.util.stream.Collectors;
+
+/**
+ * Profile client, use profile.graphqls, base on {@link SimpleQueryClient}
+ *
+ * @author MrPro
+ */
+public class ProfileClient extends SimpleQueryClient {
+ public ProfileClient(String host, String port) {
+ super(host, port);
+ }
+
+ public ProfileTaskCreationResult createProfileTask(final ProfileTaskCreationRequest creationRequest) throws Exception {
+ final URL queryFileUrl = Resources.getResource("profileTaskCreation.gql");
+ final String queryString = Resources.readLines(queryFileUrl, Charset.forName("UTF8"))
+ .stream()
+ .filter(it -> !it.startsWith("#"))
+ .collect(Collectors.joining())
+ .replace("{serviceId}", String.valueOf(creationRequest.getServiceId()))
+ .replace("{endpointName}", creationRequest.getEndpointName())
+ .replace("{duration}", String.valueOf(creationRequest.getDuration()))
+ .replace("{startTime}", String.valueOf(creationRequest.getStartTime()))
+ .replace("{minDurationThreshold}", String.valueOf(creationRequest.getMinDurationThreshold()))
+ .replace("{dumpPeriod}", String.valueOf(creationRequest.getDumpPeriod()));
+ final ResponseEntity<GQLResponse<ProfileTaskCreationResultWrapper>> responseEntity = restTemplate.exchange(
+ new RequestEntity<>(queryString, HttpMethod.POST, URI.create(endpointUrl)),
+ new ParameterizedTypeReference<GQLResponse<ProfileTaskCreationResultWrapper>>() {
+ }
+ );
+
+ if (responseEntity.getStatusCode() != HttpStatus.OK) {
+ throw new RuntimeException("Response status != 200, actual: " + responseEntity.getStatusCode());
+ }
+
+ return responseEntity.getBody().getData().getCreationResult();
+ }
+
+ public ProfileTasks getProfileTaskList(final ProfileTaskQuery query) throws IOException {
+ final URL queryFileUrl = Resources.getResource("getProfileTaskList.gql");
+ final String queryString = Resources.readLines(queryFileUrl, Charset.forName("UTF8"))
+ .stream()
+ .filter(it -> !it.startsWith("#"))
+ .collect(Collectors.joining())
+ .replace("{serviceId}", String.valueOf(query.serviceId()))
+ .replace("{endpointName}", query.endpointName());
+ final ResponseEntity<GQLResponse<ProfileTasks>> responseEntity = restTemplate.exchange(
+ new RequestEntity<>(queryString, HttpMethod.POST, URI.create(endpointUrl)),
+ new ParameterizedTypeReference<GQLResponse<ProfileTasks>>() {
+ }
+ );
+
+ if (responseEntity.getStatusCode() != HttpStatus.OK) {
+ throw new RuntimeException("Response status != 200, actual: " + responseEntity.getStatusCode());
+ }
+
+ return responseEntity.getBody().getData();
+ }
+
+
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/creation/ProfileTaskCreationRequest.java b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/creation/ProfileTaskCreationRequest.java
new file mode 100644
index 0000000..78323c9
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/creation/ProfileTaskCreationRequest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.profile.creation;
+
+import lombok.*;
+
+/**
+ * e2e profile, create profile task entity
+ *
+ * @author MrPro
+ */
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class ProfileTaskCreationRequest {
+
+ private int serviceId;
+ private String endpointName;
+ private long startTime;
+ private int duration;
+ private int minDurationThreshold;
+ private int dumpPeriod;
+
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/creation/ProfileTaskCreationResult.java b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/creation/ProfileTaskCreationResult.java
new file mode 100644
index 0000000..ba111fd
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/creation/ProfileTaskCreationResult.java
@@ -0,0 +1,36 @@
+/*
+ * 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.profile.creation;
+
+import lombok.*;
+
+/**
+ * e2e profile, create profile task result entity
+ *
+ * @author MrPro
+ */
+@Setter
+@Getter
+@ToString
+public class ProfileTaskCreationResult {
+
+ private String errorReason;
+ private String id;
+
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/creation/ProfileTaskCreationResultMatcher.java b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/creation/ProfileTaskCreationResultMatcher.java
new file mode 100644
index 0000000..baa24bf
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/creation/ProfileTaskCreationResultMatcher.java
@@ -0,0 +1,36 @@
+/*
+ * 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.profile.creation;
+
+import org.apache.skywalking.e2e.verification.AbstractMatcher;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * @author MrPro
+ */
+public class ProfileTaskCreationResultMatcher extends AbstractMatcher<ProfileTaskCreationResult> {
+
+ @Override
+ public void verify(ProfileTaskCreationResult profileTaskCreationResult) {
+ doVerify("not null", profileTaskCreationResult.getId());
+ assertThat(profileTaskCreationResult.getErrorReason()).isNullOrEmpty();
+ }
+
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/creation/ProfileTaskCreationResultWrapper.java b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/creation/ProfileTaskCreationResultWrapper.java
new file mode 100644
index 0000000..9d03fd3
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/creation/ProfileTaskCreationResultWrapper.java
@@ -0,0 +1,35 @@
+/*
+ * 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.profile.creation;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * wrap profile task create result, for profileTaskCreation.gql
+ *
+ * @author MrPro
+ */
+@Setter
+@Getter
+public class ProfileTaskCreationResultWrapper {
+
+ private ProfileTaskCreationResult creationResult;
+
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/query/ProfileTask.java b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/query/ProfileTask.java
new file mode 100644
index 0000000..3485124
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/query/ProfileTask.java
@@ -0,0 +1,42 @@
+/*
+ * 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.profile.query;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * Profile task bean for e2e GraphQL test result
+ *
+ * @author MrPro
+ */
+@Setter
+@Getter
+@ToString
+public class ProfileTask {
+
+ private String id;
+ private String serviceId;
+ private String endpointName;
+ private String startTime;
+ private String duration;
+ private String minDurationThreshold;
+ private String dumpPeriod;
+
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/query/ProfileTaskMatcher.java b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/query/ProfileTaskMatcher.java
new file mode 100644
index 0000000..f5c420c
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/query/ProfileTaskMatcher.java
@@ -0,0 +1,51 @@
+/*
+ * 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.profile.query;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.e2e.verification.AbstractMatcher;
+
+/**
+ * @author MrPro
+ */
+@Setter
+@Getter
+public class ProfileTaskMatcher extends AbstractMatcher<ProfileTask> {
+
+ private String id;
+ private String serviceId;
+ private String endpointName;
+ private String startTime;
+ private String duration;
+ private String minDurationThreshold;
+ private String dumpPeriod;
+
+ @Override
+ public void verify(ProfileTask task) {
+ doVerify(id, task.getId());
+ doVerify(serviceId, task.getServiceId());
+ doVerify(endpointName, task.getEndpointName());
+ doVerify(startTime, task.getStartTime());
+ doVerify(duration, task.getDuration());
+ doVerify(minDurationThreshold, task.getMinDurationThreshold());
+ doVerify(dumpPeriod, task.getDumpPeriod());
+ }
+
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/query/ProfileTaskQuery.java b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/query/ProfileTaskQuery.java
new file mode 100644
index 0000000..606153d
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/query/ProfileTaskQuery.java
@@ -0,0 +1,51 @@
+/*
+ * 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.profile.query;
+
+import org.apache.skywalking.e2e.AbstractQuery;
+
+/**
+ * profile query data
+ *
+ * @author MrPro
+ */
+public class ProfileTaskQuery extends AbstractQuery<ProfileTaskQuery> {
+
+ private int serviceId;
+ private String endpointName;
+
+ public int serviceId() {
+ return serviceId;
+ }
+
+ public String endpointName() {
+ return endpointName;
+ }
+
+ public ProfileTaskQuery serviceId(int serviceId) {
+ this.serviceId = serviceId;
+ return this;
+ }
+
+ public ProfileTaskQuery endpointName(String endpointName) {
+ this.endpointName = endpointName;
+ return this;
+ }
+
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/query/ProfileTasks.java b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/query/ProfileTasks.java
new file mode 100644
index 0000000..da388bb
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/query/ProfileTasks.java
@@ -0,0 +1,36 @@
+/*
+ * 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.profile.query;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.util.List;
+
+/**
+ * @author MrPro
+ */
+@Setter
+@Getter
+@ToString
+public class ProfileTasks {
+
+ private List<ProfileTask> tasks;
+
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/query/ProfilesTasksMatcher.java b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/query/ProfilesTasksMatcher.java
new file mode 100644
index 0000000..a0cf577
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/java/org/apache/skywalking/e2e/profile/query/ProfilesTasksMatcher.java
@@ -0,0 +1,49 @@
+/*
+ * 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.profile.query;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.e2e.verification.AbstractMatcher;
+import org.assertj.core.api.Assertions;
+
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * @author MrPro
+ */
+@Setter
+@Getter
+public class ProfilesTasksMatcher extends AbstractMatcher<ProfileTasks> {
+
+ private List<ProfileTaskMatcher> tasks;
+
+ @Override
+ public void verify(ProfileTasks matcher) {
+ Assertions.assertThat(matcher.getTasks()).hasSameSizeAs(this.tasks);
+
+ int size = this.getTasks().size();
+
+ for (int i = 0; i < size; i++) {
+ this.getTasks().get(i).verify(matcher.getTasks().get(i));
+ }
+ }
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.endpoints.yml b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.endpoints.yml
new file mode 100644
index 0000000..56535f7
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.endpoints.yml
@@ -0,0 +1,19 @@
+# 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.
+
+endpoints:
+ - key: not null
+ label: /e2e/users
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.instances.yml b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.instances.yml
new file mode 100644
index 0000000..f3d8684
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.instances.yml
@@ -0,0 +1,28 @@
+# 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.
+
+instances:
+ - key: 2
+ label: not null
+ attributes:
+ - name: os_name
+ value: not null
+ - name: host_name
+ value: not null
+ - name: process_no
+ value: gt 0
+ - name: ipv4s
+ value: not null
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.profileTasks.yml b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.profileTasks.yml
new file mode 100644
index 0000000..67afb7b
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.profileTasks.yml
@@ -0,0 +1,24 @@
+# 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.
+
+tasks:
+ - id: not null
+ serviceId: gt 0
+ endpointName: not null
+ startTime: gt 0
+ duration: gt 0
+ minDurationThreshold: gt 0
+ dumpPeriod: gt 0
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.services.yml b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.services.yml
new file mode 100644
index 0000000..c949dc8
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/expected-data/org.apache.skywalking.e2e.ProfileVerificationITCase.services.yml
@@ -0,0 +1,19 @@
+# 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.
+
+services:
+ - key: 2
+ label: "e2e-profile-service"
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/getProfileTaskList.gql b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/getProfileTaskList.gql
new file mode 100644
index 0000000..c112924
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/getProfileTaskList.gql
@@ -0,0 +1,33 @@
+# 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.
+
+{
+ "query":"query queryProfileTaskList($serviceId: ID!, $endpointName: String!) {
+ tasks: getProfileTaskList(serviceId: $serviceId, endpointName: $endpointName) {
+ id: id
+ serviceId: serviceId
+ endpointName: endpointName
+ startTime: startTime
+ duration: duration
+ minDurationThreshold: minDurationThreshold
+ dumpPeriod: dumpPeriod
+ }
+ }",
+ "variables": {
+ "serviceId": "{serviceId}",
+ "endpointName": "{endpointName}"
+ }
+}
diff --git a/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/profileTaskCreation.gql b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/profileTaskCreation.gql
new file mode 100644
index 0000000..8aa5028
--- /dev/null
+++ b/test/e2e/e2e-profile/e2e-profile-test-runner/src/main/resources/profileTaskCreation.gql
@@ -0,0 +1,35 @@
+# 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.
+
+{
+ "query":"mutation createProfileTask($creationRequest: ProfileTaskCreationRequest!) {
+ creationResult: createProfileTask(creationRequest: $creationRequest) {
+ errorReason: errorReason
+ id: id
+ }
+ }",
+ "variables": {
+ "creationRequest": {
+ "serviceId": "{serviceId}",
+ "endpointName": "{endpointName}",
+ "duration": {duration},
+ "startTime": {startTime},
+ "minDurationThreshold": {minDurationThreshold},
+ "dumpPeriod": {dumpPeriod}
+ }
+ }
+}
+
diff --git a/test/e2e/e2e-profile/pom.xml b/test/e2e/e2e-profile/pom.xml
new file mode 100644
index 0000000..dcfe0f7
--- /dev/null
+++ b/test/e2e/e2e-profile/pom.xml
@@ -0,0 +1,61 @@
+<?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-profile</artifactId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>e2e-profile-service</module>
+ <module>e2e-profile-test-runner</module>
+ <module>e2e-profile-h2-test-runner</module>
+ <module>e2e-profile-mysql-test-runner</module>
+ <module>e2e-profile-es-test-runner</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ <version>${spring.boot.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>${h2.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>e2e-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+
+</project>
\ No newline at end of file
diff --git a/test/e2e/pom.xml b/test/e2e/pom.xml
index 790f774..83872f5 100644
--- a/test/e2e/pom.xml
+++ b/test/e2e/pom.xml
@@ -40,6 +40,7 @@
<module>e2e-agent-reboot</module>
<module>e2e-ttl</module>
<module>e2e-6.x-agent-7.x-oap-compatibility</module>
+ <module>e2e-profile</module>
</modules>
<properties>