From b3ea23b17e6d73e444e4a3f359f5d54cae550385 Mon Sep 17 00:00:00 2001 From: kezhenxu94 Date: Fri, 27 Nov 2020 19:34:46 +0800 Subject: [PATCH 1/6] Set up GitHub Actions --- .github/workflows/build.yaml | 53 ++++++++++++++++++++++++++++++++++++ .github/workflows/test.yaml | 53 ++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..e338f0b --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,53 @@ +# +# 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. +# + +name: Build + +on: + pull_request: + push: + branches: + - master + +jobs: + Build: + runs-on: ubuntu-18.04 + timeout-minutes: 30 + strategy: + matrix: + node-version: [ 12, 14 ] + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Set Up NodeJS ${{ matrix.node-version }} + uses: actions/setup-node@v2-beta + with: + node-version: ${{ matrix.node-version }} + + - name: Build + run: | + npm i + npm run build diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..1175d3b --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,53 @@ +# +# 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. +# + +name: Test + +on: + pull_request: + push: + branches: + - master + +jobs: + Build: + runs-on: ubuntu-18.04 + timeout-minutes: 30 + strategy: + matrix: + node-version: [ 12, 14 ] + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Set Up NodeJS ${{ matrix.node-version }} + uses: actions/setup-node@v2-beta + with: + node-version: ${{ matrix.node-version }} + + - name: Test + run: | + npm i + npm run test From 1ad5f502dd1e705a4a874cb95da6b8ad3d940d0b Mon Sep 17 00:00:00 2001 From: kezhenxu94 Date: Fri, 27 Nov 2020 19:46:45 +0800 Subject: [PATCH 2/6] Fix test --- tests/plugins/http/server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugins/http/server.ts b/tests/plugins/http/server.ts index 2885c56..1fdb649 100644 --- a/tests/plugins/http/server.ts +++ b/tests/plugins/http/server.ts @@ -38,7 +38,7 @@ const server = http.createServer((req, res) => { .request('http://httpbin.org/xml', async (r) => { let data = ''; r.on('data', (chunk) => (data += chunk)); - r.on('end', () => setTimeout(() => res.end(data), 1000)); + r.on('end', () => setTimeout(() => res.end(data), 3000)); }) .end(); }); From d6a3b0f73c4c3628b24c389dc48f4c4633b61501 Mon Sep 17 00:00:00 2001 From: kezhenxu94 Date: Fri, 27 Nov 2020 19:56:25 +0800 Subject: [PATCH 3/6] Fix test --- tests/plugins/http/expected.data.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/plugins/http/expected.data.yaml b/tests/plugins/http/expected.data.yaml index 3588900..f66042c 100644 --- a/tests/plugins/http/expected.data.yaml +++ b/tests/plugins/http/expected.data.yaml @@ -21,10 +21,10 @@ segmentItems: segments: - segmentId: not null spans: - - operationName: /xml + - operationName: /json operationId: 0 parentSpanId: 0 - spanId: 2 + spanId: 1 spanLayer: Http startTime: gt 0 endTime: gt 0 @@ -34,12 +34,12 @@ segmentItems: peer: httpbin.org skipAnalysis: false tags: - - { key: http.url, value: httpbin.org/xml } + - { key: http.url, value: httpbin.org/json } - { key: http.status.code, value: '200' } - - operationName: /json + - operationName: /xml operationId: 0 parentSpanId: 0 - spanId: 1 + spanId: 2 spanLayer: Http startTime: gt 0 endTime: gt 0 @@ -49,7 +49,7 @@ segmentItems: peer: httpbin.org skipAnalysis: false tags: - - { key: http.url, value: httpbin.org/json } + - { key: http.url, value: httpbin.org/xml } - { key: http.status.code, value: '200' } - operationName: /test operationId: 0 From 0881f61691d7e233436da345d27427b7434e18da Mon Sep 17 00:00:00 2001 From: kezhenxu94 Date: Fri, 27 Nov 2020 20:38:55 +0800 Subject: [PATCH 4/6] Fix test --- tests/plugins/http/expected.data.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/plugins/http/expected.data.yaml b/tests/plugins/http/expected.data.yaml index f66042c..3588900 100644 --- a/tests/plugins/http/expected.data.yaml +++ b/tests/plugins/http/expected.data.yaml @@ -21,10 +21,10 @@ segmentItems: segments: - segmentId: not null spans: - - operationName: /json + - operationName: /xml operationId: 0 parentSpanId: 0 - spanId: 1 + spanId: 2 spanLayer: Http startTime: gt 0 endTime: gt 0 @@ -34,12 +34,12 @@ segmentItems: peer: httpbin.org skipAnalysis: false tags: - - { key: http.url, value: httpbin.org/json } + - { key: http.url, value: httpbin.org/xml } - { key: http.status.code, value: '200' } - - operationName: /xml + - operationName: /json operationId: 0 parentSpanId: 0 - spanId: 2 + spanId: 1 spanLayer: Http startTime: gt 0 endTime: gt 0 @@ -49,7 +49,7 @@ segmentItems: peer: httpbin.org skipAnalysis: false tags: - - { key: http.url, value: httpbin.org/xml } + - { key: http.url, value: httpbin.org/json } - { key: http.status.code, value: '200' } - operationName: /test operationId: 0 From 6a5de6ecbda7428c4b1b3adff9ac93bec4a55537 Mon Sep 17 00:00:00 2001 From: kezhenxu94 Date: Fri, 27 Nov 2020 21:44:29 +0800 Subject: [PATCH 5/6] Fix test --- tests/plugins/http/expected.data.yaml | 12 ++++++------ tests/plugins/http/server.ts | 16 +++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/plugins/http/expected.data.yaml b/tests/plugins/http/expected.data.yaml index 3588900..f66042c 100644 --- a/tests/plugins/http/expected.data.yaml +++ b/tests/plugins/http/expected.data.yaml @@ -21,10 +21,10 @@ segmentItems: segments: - segmentId: not null spans: - - operationName: /xml + - operationName: /json operationId: 0 parentSpanId: 0 - spanId: 2 + spanId: 1 spanLayer: Http startTime: gt 0 endTime: gt 0 @@ -34,12 +34,12 @@ segmentItems: peer: httpbin.org skipAnalysis: false tags: - - { key: http.url, value: httpbin.org/xml } + - { key: http.url, value: httpbin.org/json } - { key: http.status.code, value: '200' } - - operationName: /json + - operationName: /xml operationId: 0 parentSpanId: 0 - spanId: 1 + spanId: 2 spanLayer: Http startTime: gt 0 endTime: gt 0 @@ -49,7 +49,7 @@ segmentItems: peer: httpbin.org skipAnalysis: false tags: - - { key: http.url, value: httpbin.org/json } + - { key: http.url, value: httpbin.org/xml } - { key: http.status.code, value: '200' } - operationName: /test operationId: 0 diff --git a/tests/plugins/http/server.ts b/tests/plugins/http/server.ts index 1fdb649..de8b370 100644 --- a/tests/plugins/http/server.ts +++ b/tests/plugins/http/server.ts @@ -34,13 +34,15 @@ const server = http.createServer((req, res) => { }) .end(); - http - .request('http://httpbin.org/xml', async (r) => { - let data = ''; - r.on('data', (chunk) => (data += chunk)); - r.on('end', () => setTimeout(() => res.end(data), 3000)); - }) - .end(); + setTimeout(() => { + http + .request('http://httpbin.org/xml', async (r) => { + let data = ''; + r.on('data', (chunk) => (data += chunk)); + r.on('end', () => setTimeout(() => res.end(data), 2000)); + }) + .end(); + }, 1000); }); server.listen(5000, () => console.info('Listening on port 5000...')); From e6266ab1b698b6e79cdf32b9bff3ee2f2c78df03 Mon Sep 17 00:00:00 2001 From: kezhenxu94 Date: Fri, 27 Nov 2020 22:19:56 +0800 Subject: [PATCH 6/6] Fix test --- tests/plugins/http/expected.data.yaml | 43 +++++++++------------------ tests/plugins/http/server.ts | 12 +------- 2 files changed, 15 insertions(+), 40 deletions(-) diff --git a/tests/plugins/http/expected.data.yaml b/tests/plugins/http/expected.data.yaml index f66042c..a0e03d3 100644 --- a/tests/plugins/http/expected.data.yaml +++ b/tests/plugins/http/expected.data.yaml @@ -21,25 +21,29 @@ segmentItems: segments: - segmentId: not null spans: - - operationName: /json + - operationName: /test operationId: 0 - parentSpanId: 0 - spanId: 1 + parentSpanId: -1 + spanId: 0 spanLayer: Http startTime: gt 0 endTime: gt 0 - componentId: 2 + componentId: 49 isError: false - spanType: Exit - peer: httpbin.org + spanType: Entry + peer: '' skipAnalysis: false tags: - - { key: http.url, value: httpbin.org/json } + - { key: http.url, value: /test } - { key: http.status.code, value: '200' } - - operationName: /xml + refs: + - { parentEndpoint: '', networkAddress: 'server:5000', refType: CrossProcess, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, + parentService: client, traceId: not null } + - operationName: /json operationId: 0 parentSpanId: 0 - spanId: 2 + spanId: 1 spanLayer: Http startTime: gt 0 endTime: gt 0 @@ -49,27 +53,8 @@ segmentItems: peer: httpbin.org skipAnalysis: false tags: - - { key: http.url, value: httpbin.org/xml } - - { key: http.status.code, value: '200' } - - operationName: /test - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: gt 0 - endTime: gt 0 - componentId: 49 - isError: false - spanType: Entry - peer: '' - skipAnalysis: false - tags: - - { key: http.url, value: /test } + - { key: http.url, value: httpbin.org/json } - { key: http.status.code, value: '200' } - refs: - - { parentEndpoint: '', networkAddress: 'server:5000', refType: CrossProcess, - parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, - parentService: client, traceId: not null } - serviceName: client segmentSize: 1 segments: diff --git a/tests/plugins/http/server.ts b/tests/plugins/http/server.ts index de8b370..b9cbc2f 100644 --- a/tests/plugins/http/server.ts +++ b/tests/plugins/http/server.ts @@ -30,19 +30,9 @@ const server = http.createServer((req, res) => { .request('http://httpbin.org/json', (r) => { let data = ''; r.on('data', (chunk) => (data += chunk)); - r.on('end', () => setImmediate(() => res.write(data))); + r.on('end', () => res.end(data)); }) .end(); - - setTimeout(() => { - http - .request('http://httpbin.org/xml', async (r) => { - let data = ''; - r.on('data', (chunk) => (data += chunk)); - r.on('end', () => setTimeout(() => res.end(data), 2000)); - }) - .end(); - }, 1000); }); server.listen(5000, () => console.info('Listening on port 5000...'));