From 2e23d7480ce9aa769efbad63705aa337abe59898 Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Fri, 12 Aug 2022 10:31:48 +0800 Subject: [PATCH] chore: add windows unit test action (#3136) Co-authored-by: Daniel Dyla --- .github/workflows/unit-test.yml | 40 +++++++++++++++++++ .../test/functionals/http-enable.test.ts | 10 +++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 571b4af38e..21c99fbf5e 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -54,6 +54,46 @@ jobs: - name: Report Coverage run: npm run codecov if: ${{ matrix.node_version == '14' }} + node-windows-tests: + strategy: + fail-fast: false + runs-on: windows-latest + env: + NPM_CONFIG_UNSAFE_PERM: true + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: '16' + + - run: npm install -g npm@latest + + - name: restore lerna + id: cache + uses: actions/cache@v3 + with: + path: | + node_modules + package-lock.json + packages/*/node_modules + packages/*/package-lock.json + experimental/packages/*/node_modules + experimental/packages/*/package-lock.json + key: node-windows-tests-${{ runner.os }}-${{ hashFiles('package.json', 'packages/*/package.json', 'experimental/packages/*/package.json') }} + + - name: Bootstrap + run: | + npm install --ignore-scripts + npx lerna bootstrap --no-ci --hoist --nohoist='zone.js' --ignore @opentelemetry/selenium-tests + + - name: Build 🔧 + run: | + npm run compile + + - name: Unit tests + run: npm run test browser-tests: runs-on: ubuntu-latest container: diff --git a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts index 44bedc3a1f..bee473ed3d 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts @@ -725,14 +725,16 @@ describe('HttpInstrumentation', () => { } }); - it("should have 1 ended span when request doesn't listening response", done => { + it("should have 1 ended client span when request doesn't listening response", done => { + // nock doesn't emit close event. nock.cleanAll(); nock.enableNetConnect(); - const req = http.request(`${protocol}://${hostname}/`); + + const req = http.request(`${protocol}://${hostname}:${serverPort}/`); req.on('close', () => { - const spans = memoryExporter.getFinishedSpans(); - const [span] = spans; + const spans = memoryExporter.getFinishedSpans().filter(it => it.kind === SpanKind.CLIENT); assert.strictEqual(spans.length, 1); + const [span] = spans; assert.ok(Object.keys(span.attributes).length > 6); done(); });