diff --git a/docs/en/guides/Plugin-test.md b/docs/en/guides/Plugin-test.md index 412ba9ae335c1b366013612dc51b8fdfd6cb27fd..0a5b6b89482934fd0832cc1dd2774650cb30bef3 100644 --- a/docs/en/guides/Plugin-test.md +++ b/docs/en/guides/Plugin-test.md @@ -359,6 +359,16 @@ java -jar ${agent_opts} "-Dskywalking.agent.service_name=jettyclient-scenario" ## Best Practices + +### How To Use The Archetype To Create A Test Case Project +We provided archetypes and a script to make creating a project easier. It creates a completed project of a test case. So that we only need to focus on cases. +First, we can use followed command to get usage about the script. + +`bash ${SKYWALKING_HOME}/test/plugin/generator.sh -h` + +Then, runs and generates a project, named by `scenario_name`, in `./scenarios`. + + ### Recommendations for pom ```xml diff --git a/test/plugin/archetypes/jvm/pom.xml b/test/plugin/archetypes/jvm/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..628fe3c8a7a1f86d5208151267a6fbc262c188e2 --- /dev/null +++ b/test/plugin/archetypes/jvm/pom.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + + + org.apache.skywalking.plugin + archetypes + 1.0.0 + + + jvm + + + + + org.apache.maven.archetype + archetype-packaging + 3.1.1 + + + + diff --git a/test/plugin/archetypes/jvm/src/main/resources/META-INF/maven/archetype-metadata.xml b/test/plugin/archetypes/jvm/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000000000000000000000000000000000..8641ffbe2d306664af5c38aca15f5585cc31badc --- /dev/null +++ b/test/plugin/archetypes/jvm/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,65 @@ + + + + + + + org.apache.skywalking.apm.testcase + + + ${scenario_name} + + + 1.0.0 + + + org.apache.skywalking.apm.testcase.${scenario_name} + + + + + ${scenario_name} + + + + + + + + configuration.yml + support-version.list + bin/startup.sh + + + + config + + + src/main/java + + + src/main/resources + + + \ No newline at end of file diff --git a/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/bin/startup.sh b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/bin/startup.sh new file mode 100644 index 0000000000000000000000000000000000000000..94904d81303550ae6e968dee2baef35ee37303d4 --- /dev/null +++ b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/bin/startup.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# 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. + +home="$(cd "$(dirname $0)"; pwd)" + +java -jar ${agent_opts} ${home}/../libs${scenario_name}.jar & \ No newline at end of file diff --git a/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/config/expectedData.yaml b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/config/expectedData.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d6474510c256730604b6f0720af38112cb2c8eb6 --- /dev/null +++ b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/config/expectedData.yaml @@ -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. +registryItems: + applications: + - {${scenario_name}: 2} + instances: + - {${scenario_name}: 1} + operationNames: + - canal-scenario: [] + heartbeat: [] +segmentItems: + - applicationCode: ${scenario_name} + segmentSize: + segments: diff --git a/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/configuration.yml b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/configuration.yml new file mode 100644 index 0000000000000000000000000000000000000000..38559c6360409bed24f0addec90ab025178a7601 --- /dev/null +++ b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/configuration.yml @@ -0,0 +1,23 @@ +# 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. + +type: jvm +entryService: http://localhost:8080/${scenario_name}/case/${scenario_case} +healthCheck: http://localhost:8080/${scenario_name}/case/healthCheck +startScript: ./bin/startup.sh +framework: ${scenario_name} +environment: +dependencies: \ No newline at end of file diff --git a/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/pom.xml b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..1bf9d5b681a0c6b5ccff6f1914f074eeacb6bc11 --- /dev/null +++ b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,83 @@ + + + + + org.apache.skywalking.apm.testcase + ${artifactId} + 1.0.0 + + + 4.0.0 + + ${scenario_name} + + 4.3.8.RELEASE + 1.5.2.RELEASE + + + + + org.springframework.boot + spring-boot-starter + ${spring-boot-version} + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + ${spring-boot-version} + + + org.springframework.boot + spring-boot-starter-tomcat + ${spring-boot-version} + + + org.springframework.boot + spring-boot-starter-web + ${spring-boot-version} + + + + + ${scenario_name} + + + org.springframework.boot + spring-boot-maven-plugin + 1.5.9.RELEASE + + + + repackage + + + + + + + + \ No newline at end of file diff --git a/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/assembly/assembly.xml b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/assembly/assembly.xml new file mode 100644 index 0000000000000000000000000000000000000000..5431e82480290909e4d1dc99277a227d60d1ae7e --- /dev/null +++ b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/${scenario_name}.jar + ./libs + 0775 + + + diff --git a/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/java/Application.java b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/java/Application.java new file mode 100644 index 0000000000000000000000000000000000000000..3e144e961c83e817eb5c3733009c531545567782 --- /dev/null +++ b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/java/Application.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 $package; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + try { + SpringApplication.run(Application.class, args); + } catch (Exception e) { + // Never do this + } + } +} diff --git a/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/java/controller/CaseController.java b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/java/controller/CaseController.java new file mode 100644 index 0000000000000000000000000000000000000000..e5e6e228af91c47251e074648f519e2a66b2731d --- /dev/null +++ b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/java/controller/CaseController.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 $package; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/case") +@PropertySource("classpath:application.properties") +public class CaseController { + private static final Logger logger = LogManager.getLogger(CaseController.class); + private static final String SUCCESS = "Success"; + + @RequestMapping("/${scenario_case}") + @ResponseBody + public String testcase() { + // your codes + return SUCCESS; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() { + // your codes + return SUCCESS; + } + +} diff --git a/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/resources/application.properties b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/resources/application.properties new file mode 100644 index 0000000000000000000000000000000000000000..6debe48246dc3e876a56fa3e3164e3c083beb9ec --- /dev/null +++ b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/resources/application.properties @@ -0,0 +1,21 @@ +# +# 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=8080 +server.contextPath=/${scenario_name} +logging.config=classpath:log4j2.xml \ No newline at end of file diff --git a/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/resources/log4j2.xml b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/resources/log4j2.xml new file mode 100644 index 0000000000000000000000000000000000000000..b5cda5ae8ad528f3272b269b1c9f0d733c52ef5f --- /dev/null +++ b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + diff --git a/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/support-version.list b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/support-version.list new file mode 100644 index 0000000000000000000000000000000000000000..085c4d8e09f4437b1d168eefe87cb8aa59c73817 --- /dev/null +++ b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/support-version.list @@ -0,0 +1,17 @@ +# 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 +# "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. + +# lists your version here \ No newline at end of file diff --git a/test/plugin/archetypes/pom.xml b/test/plugin/archetypes/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..f0a7aac6ac24762ba1ebc984248f621e535c58f2 --- /dev/null +++ b/test/plugin/archetypes/pom.xml @@ -0,0 +1,38 @@ + + + + + 4.0.0 + pom + + org.apache.skywalking.plugin + archetypes + 1.0.0 + + + tomcat + jvm + + + + true + + diff --git a/test/plugin/archetypes/tomcat/pom.xml b/test/plugin/archetypes/tomcat/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..bbc7b80adfc7745f8b2a5bd6d155d2f47af55979 --- /dev/null +++ b/test/plugin/archetypes/tomcat/pom.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + + + org.apache.skywalking.plugin + archetypes + 1.0.0 + + + tomcat + + + + + org.apache.maven.archetype + archetype-packaging + 3.1.1 + + + + diff --git a/test/plugin/archetypes/tomcat/src/main/resources/META-INF/maven/archetype-metadata.xml b/test/plugin/archetypes/tomcat/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000000000000000000000000000000000..a30eb9d2048c06e86dc4863df2b249b698fb8c44 --- /dev/null +++ b/test/plugin/archetypes/tomcat/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,64 @@ + + + + + + + org.apache.skywalking.apm.testcase + + + ${scenario_name} + + + 1.0.0 + + + org.apache.skywalking.apm.testcase.${scenario_name} + + + + + ${scenario_name} + + + + + + + + configuration.yml + support-version.list + + + + config + + + src/main/java + + + src/main/resources + + + \ No newline at end of file diff --git a/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/config/expectedData.yaml b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/config/expectedData.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d6474510c256730604b6f0720af38112cb2c8eb6 --- /dev/null +++ b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/config/expectedData.yaml @@ -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. +registryItems: + applications: + - {${scenario_name}: 2} + instances: + - {${scenario_name}: 1} + operationNames: + - canal-scenario: [] + heartbeat: [] +segmentItems: + - applicationCode: ${scenario_name} + segmentSize: + segments: diff --git a/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/configuration.yml b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/configuration.yml new file mode 100644 index 0000000000000000000000000000000000000000..af2c8f7d6a452186a79efe3dbde50a8117bff8c6 --- /dev/null +++ b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/configuration.yml @@ -0,0 +1,22 @@ +# 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. + +type: jvm +entryService: http://localhost:8080/${scenario_name}/case/${scenario_case} +healthCheck: http://localhost:8080/${scenario_name}/case/healthCheck +framework: ${scenario_name} +environment: +dependencies: \ No newline at end of file diff --git a/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/pom.xml b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..48fe3612a4f22223e49a0ae1b6da36f83f45ac1a --- /dev/null +++ b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,68 @@ + + + + + org.apache.skywalking.apm.testcase + ${artifactId} + 1.0.0 + war + + 4.0.0 + + + UTF-8 + 1.8 + YOUR VERSION + + + + + javax.servlet + javax.servlet-api + 3.1.0 + provided + + + org.apache.logging.log4j + log4j-api + 2.8.1 + + + org.apache.logging.log4j + log4j-core + 2.8.1 + + + + + ${scenario_name} + + + maven-compiler-plugin + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + + diff --git a/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/java/CaseServlet.java b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/java/CaseServlet.java new file mode 100644 index 0000000000000000000000000000000000000000..a9257aada4dfc400a3caeab4135ac5082e8fe862 --- /dev/null +++ b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/java/CaseServlet.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package $package; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class CaseServlet extends HttpServlet { + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + PrintWriter printWriter = resp.getWriter(); + printWriter.write("success"); + printWriter.flush(); + printWriter.close(); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + doGet(req, resp); + } + +} diff --git a/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/java/HealthCheckServlet.java b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/java/HealthCheckServlet.java new file mode 100644 index 0000000000000000000000000000000000000000..4c85756060b82b3c329b2b0676fe500ba7ae4dcf --- /dev/null +++ b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/java/HealthCheckServlet.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 $package; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class HealthCheckServlet extends HttpServlet { + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + PrintWriter writer = resp.getWriter(); + writer.write("Success"); + writer.flush(); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + doGet(req, resp); + } +} diff --git a/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/resources/log4j2.xml b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/resources/log4j2.xml new file mode 100644 index 0000000000000000000000000000000000000000..4c6c06d4057c035b990f92da9f546ed432c06068 --- /dev/null +++ b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000000000000000000000000000000000..318be17d6db5852cd46a96185c75b40f8384ff94 --- /dev/null +++ b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,44 @@ + + + skywalking-httpclient-scenario + + + caseServlet + ${package}.CaseServlet + + + + healthCheck + ${package}.HealthCheckServlet + + + + healthCheck + /case/healthCheck + + + + caseServlet + /case/${scenario_case} + + diff --git a/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/support-version.list b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/support-version.list new file mode 100644 index 0000000000000000000000000000000000000000..085c4d8e09f4437b1d168eefe87cb8aa59c73817 --- /dev/null +++ b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/support-version.list @@ -0,0 +1,17 @@ +# 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 +# "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. + +# lists your version here \ No newline at end of file diff --git a/test/plugin/generator.sh b/test/plugin/generator.sh new file mode 100644 index 0000000000000000000000000000000000000000..0588b940fa4c58df989cfcbac487f45b956c21fb --- /dev/null +++ b/test/plugin/generator.sh @@ -0,0 +1,111 @@ +#!/bin/bash +# +# 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 +# limitation under the License. + +wkdir="$(cd "$(dirname $0)"; pwd)" +MVNW=${wkdir}/../../../mvnw + +type="jvm" +artifactId= +scenario_home= +scenario_case= +scenarios_home=${wkdir}/scenarios + +exitWithMessage() { + echo $1>&2 + exit 1 +} + +print_help() { + echo -e "Usage: bash generator.sh -n my-scenario -c mycase -type jvm -a my" + echo -e "\t--type:\t\t\tchooses a type of container, 'jvm' or 'tomcat', which is 'jvm-container' or 'tomcat-container'.(required)" + echo -e "\t-a| --artifactId:\tgives an artifactId for your project." + echo -e "\t-n| --scenario_name:\tsets the scenario name.(required)" + echo -e "\t-c| --scenario_case:\tsets the entry name of scenario." + exit 0 +} + +parse_commandline() { + _positionals_count=0 + while test $# -gt 0 + do + _key="$1" + case "$_key" in + --type=*) + type="${_key##--type=}" + ;; + --type) + test $# -lt 2 && exitWithMessage "Missing value for the optional argument '$_key'." + type="$2" + shift + ;; + --artifactId=*) + artifactId="${_key##--artifactId=}" + ;; + -a| --artifactId) + test $# -lt 2 && exitWithMessage "Missing value for the optional argument '$_key'." + artifactId="$2" + shift + ;; + --scenario_name=*) + scenario_name="${_key##--scenario_name=}" + ;; + -n| --scenario_name) + test $# -lt 2 && exitWithMessage "Missing value for the optional argument '$_key'." + scenario_name="$2" + echo "$2" + shift + ;; + -c| --scenario_case) + test $# -lt 2 && exitWithMessage "Missing value for the optional argument '$_key'." + scenario_case="$2" + shift + ;; + --scenario_case=*) + scenario_name="${_key##--scenario_case=}" + ;; + -h|--help) + print_help + exit 0 + ;; + esac + shift + done +} + +parse_commandline "$@" + +echo "${type} ${scenario_name}" +[[ -z ${type} ]] && print_help +[[ -z ${scenario_name} ]] && print_help +[[ -z ${artifactId} ]] && artifactId=${scenario_name} +[[ -z ${scenario_case} ]] && scenario_case=${scenario_name} + +${MVNW} -f ./pom.xml install + +package="org.apache.skywalking.apm.testcase.${artifactId%%-scenario}" +${MVNW} archetype:generate \ + -Dfilter=org.apache.skywalking.apm.testcase:${artifactId}:"1.0.0" \ + -DarchetypeGroupId=org.apache.skywalking.plugin \ + -DoutputDirectory=${scenarios_home} \ + -Dscenario_name=${scenario_name} \ + -Dscenario_case=${scenario_case} \ + -DarchetypeArtifactId=${type} \ + -DarchetypeCatalog=local \ + -DinteractiveMode=false \ + -DarchetypeVersion=1.0.0 \ + -Dpackage=${package}