This repository has been archived by the owner on Jun 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64bb646
commit 099adcf
Showing
18 changed files
with
532 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
Test: | ||
runs-on: ubuntu-18.04 | ||
timeout-minutes: 30 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
- name: Use NodeJS 10 | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 10 | ||
- name: Test | ||
run: cd modules/nodejs-agent && npm i && npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Plugin Test | ||
|
||
Plugin test is required and should pass before a new plugin is able to be merged into the master branch. | ||
|
||
## Mock Collector | ||
|
||
Mock Collector respects the same protocol as the SkyWalking backend, and thus receives the report data from the agent side, | ||
besides, it also exposes some http endpoints for verification. | ||
|
||
## Tested Service | ||
|
||
A tested service is a service involving the plugin that is to be tested, and exposes some endpoints to trigger the instrumentation | ||
and report data to the mock collector. | ||
|
||
## Docker Compose | ||
|
||
`docker-compose` is used to orchestrate the mock collector and the tested service(s), the `docker-compose.yml` should be | ||
able to run with `docker-compose -f docker-compose.yml up` in the standalone mode, which can be used in debugging too. | ||
|
||
## Expected Data | ||
|
||
The `expected.data.yml` file contains the expected segment data after we have triggered the instrumentation and report to mock collector, | ||
since the mock collector received the segment data then, we can post the expected data to the mock collector and verify whether | ||
they match. This can be done through the `/dataValidate` of the mock collector, say `http://collector:12800/dataValidate`, for example. | ||
|
||
## Example | ||
|
||
If we want to test the plugin for the built-in library `http`, we will: | ||
|
||
1. Build a tested service, which sets up an http server by `http` library, and exposes an http endpoint to be triggered in the test codes, say `/trigger`, take [this service](../modules/nodejs-agent/test/plugins/http/serverA.js) as example. | ||
1. Compose a `docker-compose.yml` file, orchestrating the service built in step 1 and the mock collector, take [this `docker-compose.yml`](../modules/nodejs-agent/test/plugins/http/docker-compose.yml) as example. | ||
1. Write test codes to trigger the endpoint int step 1, and send the expected data file to the mock collector to verify, take [this test](../modules/nodejs-agent/test/plugins/http/http.test.js) as example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/.git | ||
**/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
# | ||
|
||
FROM openjdk:8 | ||
|
||
WORKDIR /tests | ||
|
||
ARG COMMIT_HASH=3c9d7099f05dc4a4b937c8a47506e56c130b6221 | ||
|
||
ADD https://github.com/apache/skywalking-agent-test-tool/archive/${COMMIT_HASH}.tar.gz . | ||
|
||
RUN tar -xf ${COMMIT_HASH}.tar.gz --strip 1 | ||
|
||
RUN rm ${COMMIT_HASH}.tar.gz | ||
|
||
RUN ./mvnw -B -DskipTests package | ||
|
||
FROM openjdk:8 | ||
|
||
EXPOSE 19876 12800 | ||
|
||
WORKDIR /tests | ||
|
||
COPY --from=0 /tests/dist/skywalking-mock-collector.tar.gz /tests | ||
|
||
RUN tar -xf skywalking-mock-collector.tar.gz --strip 1 | ||
|
||
RUN chmod +x bin/collector-startup.sh | ||
|
||
ENTRYPOINT bin/collector-startup.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
# | ||
|
||
version: '2.1' | ||
|
||
services: | ||
base_collector: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.tool | ||
ports: | ||
- 12800:12800 | ||
networks: | ||
- beyond | ||
healthcheck: | ||
test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/12800"] | ||
interval: 5s | ||
timeout: 60s | ||
retries: 120 | ||
|
||
networks: | ||
beyond: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
const wait = require("wait-until"); | ||
const {spawn, exec} = require("child_process"); | ||
|
||
const ifRebuild = process.env.BUILD !== "false"; | ||
|
||
module.exports = { | ||
/** | ||
* Spawn the containers defined in [composeFile]. | ||
* | ||
* @param {string} composeFile | ||
* @param {function(function(boolean)): void} ready readiness callback. | ||
* @return {Promise<void>} | ||
*/ | ||
setUp: (composeFile, ready) => new Promise((resolve, reject) => { | ||
const options = ["--force-recreate", "-d"]; | ||
ifRebuild && options.push("--build"); | ||
|
||
const composeUp = spawn("docker-compose", ["-f", composeFile, "up", ...options]); | ||
|
||
composeUp.stdout.on("data", (data) => process.stdout.write(data.toString())); | ||
composeUp.stderr.on("data", (data) => process.stderr.write(data.toString())); | ||
|
||
wait() | ||
.times(200) | ||
.interval(3000) | ||
.condition(ready) | ||
.done((result) => result ? resolve() : reject()); | ||
}), | ||
|
||
/** | ||
* Destroy the containers defined in [composeFile]. | ||
* | ||
* @param {string} composeFile | ||
* @return {Promise<void>} | ||
*/ | ||
tearDown: (composeFile) => new Promise((resolve, reject) => { | ||
exec(`docker-compose -f ${composeFile} down`, (err, stdout, stderr) => { | ||
console.info(stdout); | ||
console.error(stderr); | ||
resolve(); | ||
}); | ||
}), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
# | ||
|
||
FROM node:10 | ||
|
||
WORKDIR /agent | ||
|
||
ADD . /agent | ||
|
||
RUN npm i | ||
|
||
WORKDIR /app | ||
|
||
RUN npm init -y && npm i /agent |
Oops, something went wrong.