parent
e307b69163
commit
cbe03da066
|
|
@ -364,7 +364,7 @@ java -jar ${agent_opts} "-Dskywalking.agent.service_name=jettyclient-scenario"
|
|||
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`
|
||||
`bash ${SKYWALKING_HOME}/test/plugin/generator.sh`
|
||||
|
||||
Then, runs and generates a project, named by `scenario_name`, in `./scenarios`.
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@
|
|||
<fileSet filtered="true" packaged="false">
|
||||
<directory>config</directory>
|
||||
</fileSet>
|
||||
<fileSet filtered="true" packaged="false">
|
||||
<directory>src/main/assembly</directory>
|
||||
</fileSet>
|
||||
<fileSet filtered="true" packaged="true">
|
||||
<directory>src/main/java</directory>
|
||||
</fileSet>
|
||||
|
|
|
|||
|
|
@ -18,4 +18,4 @@
|
|||
|
||||
home="$(cd "$(dirname $0)"; pwd)"
|
||||
|
||||
java -jar ${agent_opts} ${home}/../libs${scenario_name}.jar &
|
||||
java -jar ${agent_opts} ${home}/../libs/${scenario_name}.jar &
|
||||
|
|
@ -19,7 +19,7 @@ registryItems:
|
|||
instances:
|
||||
- {${scenario_name}: 1}
|
||||
operationNames:
|
||||
- canal-scenario: []
|
||||
- ${scenario_name}: []
|
||||
heartbeat: []
|
||||
segmentItems:
|
||||
- applicationCode: ${scenario_name}
|
||||
|
|
|
|||
|
|
@ -19,25 +19,41 @@
|
|||
<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>
|
||||
<groupId>org.apache.skywalking.apm.testcase</groupId>
|
||||
<artifactId>${artifactId}</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.apache.skywalking.apm.testcase</groupId>
|
||||
<artifactId>${artifactId}</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>${scenario_name}</artifactId>
|
||||
<properties>
|
||||
<spring.version>4.3.8.RELEASE</spring.version>
|
||||
<spring-boot-version>1.5.2.RELEASE</spring-boot-version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<compiler.version>1.8</compiler.version>
|
||||
|
||||
<test.framework.version>YOUR VERSION</test.framework.version>
|
||||
|
||||
<spring-boot-version>2.1.6.RELEASE</spring-boot-version>
|
||||
</properties>
|
||||
|
||||
<name>skywalking-${scenario_name}</name>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot-version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<version>${spring-boot-version}</version>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
@ -48,17 +64,6 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
<version>${spring-boot-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<version>${spring-boot-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${spring-boot-version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
@ -77,7 +82,33 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${compiler.version}</source>
|
||||
<target>${compiler.version}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>assemble</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/assembly.xml</descriptor>
|
||||
</descriptors>
|
||||
<outputDirectory>./target/</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
@ -16,20 +16,20 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package $package;
|
||||
package ${package}.controller;
|
||||
|
||||
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.RestController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@Controller
|
||||
@RestController
|
||||
@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}")
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
#
|
||||
|
||||
server.port=8080
|
||||
server.contextPath=/${scenario_name}
|
||||
logging.config=classpath:log4j2.xml
|
||||
server:
|
||||
port: 8080
|
||||
servlet:
|
||||
context-path: /${scenario_name}
|
||||
logging:
|
||||
config: classpath:log4j2.xml
|
||||
|
|
@ -27,4 +27,4 @@
|
|||
<AppenderRef ref="Console"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
</Configuration>
|
||||
|
|
@ -60,5 +60,8 @@
|
|||
<fileSet filtered="true" packaged="false">
|
||||
<directory>src/main/resources</directory>
|
||||
</fileSet>
|
||||
<fileSet filtered="true" packaged="false">
|
||||
<directory>src/main/webapp</directory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</archetype-descriptor>
|
||||
|
|
@ -19,7 +19,7 @@ registryItems:
|
|||
instances:
|
||||
- {${scenario_name}: 1}
|
||||
operationNames:
|
||||
- canal-scenario: []
|
||||
- ${scenario_name}: []
|
||||
heartbeat: []
|
||||
segmentItems:
|
||||
- applicationCode: ${scenario_name}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
type: jvm
|
||||
type: tomcat
|
||||
entryService: http://localhost:8080/${scenario_name}/case/${scenario_case}
|
||||
healthCheck: http://localhost:8080/${scenario_name}/case/healthCheck
|
||||
framework: ${scenario_name}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<name>skywalking-${scenario_name}</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<compiler.version>1.8</compiler.version>
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ public class CaseServlet extends HttpServlet {
|
|||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
// your codes
|
||||
PrintWriter printWriter = resp.getWriter();
|
||||
printWriter.write("success");
|
||||
printWriter.flush();
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ public class HealthCheckServlet extends HttpServlet {
|
|||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
// your codes
|
||||
PrintWriter writer = resp.getWriter();
|
||||
writer.write("Success");
|
||||
writer.flush();
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@
|
|||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
<Configuration status="info">
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d [%traceId] %-5p %c{1}:%L - %m%n"/>
|
||||
<Console name="Console" target="SYSTEM_ERR">
|
||||
<PatternLayout charset="UTF-8" pattern="[%d{yyyy-MM-dd HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="OFF">
|
||||
<Root level="WARN">
|
||||
<AppenderRef ref="Console"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
||||
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
|
||||
version="3.1">
|
||||
<display-name>skywalking-httpclient-scenario</display-name>
|
||||
<display-name>skywalking-${scenario_name}</display-name>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>caseServlet</servlet-name>
|
||||
|
|
|
|||
|
|
@ -17,85 +17,51 @@
|
|||
# limitation under the License.
|
||||
|
||||
wkdir="$(cd "$(dirname $0)"; pwd)"
|
||||
MVNW=${wkdir}/../../../mvnw
|
||||
MVNW=${wkdir}/../../mvnw
|
||||
|
||||
type="jvm"
|
||||
type=
|
||||
artifactId=
|
||||
scenario_home=
|
||||
scenario_case=
|
||||
scenarios_home=${wkdir}/scenarios
|
||||
confirm=
|
||||
|
||||
exitWithMessage() {
|
||||
echo $1>&2
|
||||
exit 1
|
||||
}
|
||||
while [[ -z ${scenario_name} ]]; do
|
||||
echo "Sets the scenario name"
|
||||
read -p ">: " scenario_name
|
||||
done
|
||||
|
||||
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
|
||||
}
|
||||
while [[ ${type} != "jvm" && ${type} != "tomcat" ]]; do
|
||||
echo "Chooses a type of container, 'jvm' or 'tomcat', which is 'jvm-container' or 'tomcat-container'"
|
||||
read -p ">: " type
|
||||
done
|
||||
|
||||
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
|
||||
echo "Gives an artifactId for your project (default: ${scenario_name})"
|
||||
read -p ">: " artifactId
|
||||
[[ -z ${artifactId} ]] && artifactId=${scenario_name}
|
||||
|
||||
|
||||
echo "Sets the entry name of scenario (default: ${scenario_name})"
|
||||
read -p ">: " scenario_case
|
||||
[[ -z ${scenario_case} ]] && scenario_case=${scenario_name}
|
||||
|
||||
${MVNW} -f ./pom.xml install
|
||||
echo ""
|
||||
echo -e "scenario_home: ${scenario_name}"
|
||||
echo -e "type: ${type}"
|
||||
echo -e "artifactId: ${artifactId}"
|
||||
echo -e "scenario_case: ${scenario_case}"
|
||||
echo ""
|
||||
|
||||
while [[ ${confirm} != "Y" && ${confirm} != "N" && ${confirm} != "y" && ${confirm} != "n" ]]; do
|
||||
echo "Please confirm: [Y/N]"
|
||||
read -p ">: " confirm
|
||||
done
|
||||
|
||||
if [[ ${confirm} == "N" || ${confirm} == "n" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
${MVNW} -f ${wkdir}/archetypes/pom.xml clean install
|
||||
|
||||
package="org.apache.skywalking.apm.testcase.${artifactId%%-scenario}"
|
||||
${MVNW} archetype:generate \
|
||||
|
|
@ -108,4 +74,4 @@ ${MVNW} archetype:generate \
|
|||
-DarchetypeCatalog=local \
|
||||
-DinteractiveMode=false \
|
||||
-DarchetypeVersion=1.0.0 \
|
||||
-Dpackage=${package}
|
||||
-Dpackage=${package}
|
||||
Loading…
Reference in New Issue