diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 1076c22516..d29c333d2e 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -9,7 +9,7 @@ pipeline { PIPELINE_LOG_LEVEL = 'INFO' } options { - timeout(time: 3, unit: 'HOURS') + timeout(time: 1, unit: 'HOURS') buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30')) timestamps() ansiColor('xterm') @@ -19,11 +19,10 @@ pipeline { quietPeriod(10) } triggers { - issueCommentTrigger("(${obltGitHubComments()}|^run (module|benchmark) tests.*)") + issueCommentTrigger("^run benchmark tests.*") } parameters { booleanParam(name: 'bench_ci', defaultValue: true, description: 'Enable benchmarks.') - booleanParam(name: 'tests_ci', defaultValue: true, description: 'Enable tests.') } stages { /** @@ -37,44 +36,6 @@ pipeline { gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true, shallow: false, reference: "/var/lib/jenkins/.git-references/${REPO}.git") stash allowEmpty: true, name: 'source', useDefaultExcludes: false - script { - dir("${BASE_DIR}"){ - - // Skip all the stages except docs for PR's with asciidoc or md changes only - env.ONLY_DOCS = isGitRegionMatch(patterns: [ '.*\\.(asciidoc|md)' ], shouldMatchAll: true) - } - } - } - } - /** - Run tests. - */ - stage('Test') { - options { skipDefaultCheckout() } - environment { - HOME = "${env.WORKSPACE}" - } - when { - beforeAgent true - allOf { - not { tag pattern: 'v\\d+\\.\\d+\\.\\d+', comparator: 'REGEXP' } - expression { return env.ONLY_DOCS == "false" } - expression { return params.tests_ci } - } - } - steps { - withGithubNotify(context: 'Test', tab: 'tests') { - deleteDir() - unstash 'source' - dir("${BASE_DIR}"){ - script { - def parallelTasks = [:] - // Only 14 for the time being - parallelTasks["Windows-Node.js-14"] = generateStepForWindows(version: '14') - parallel(parallelTasks) - } - } - } } } /** @@ -94,7 +55,6 @@ pipeline { allOf { anyOf { branch 'main' - expression { return params.Run_As_Main_Branch } expression { return env.GITHUB_COMMENT?.contains('benchmark tests') } } expression { return params.bench_ci } @@ -130,91 +90,3 @@ pipeline { } } } - -def generateStep(Map params = [:]){ - def version = params?.version - def buildType = params.containsKey('buildType') ? params.buildType : 'release' - def contextManager = params.get('disableAsyncHooks', false) ? 'patch' : '' - return { - withNode(labels: 'linux && immutable', forceWorkspace: true, forceWorker: true) { - withEnv(["VERSION=${version}", "ELASTIC_APM_CONTEXT_MANAGER=${contextManager}"]) { - deleteDir() - unstash 'source' - // Grab the current docker context for helping to troubleshoot the docker containers using filebeat and metricbeat - dockerContext(filebeatOutput: "docker-${version}-${buildType}.log", metricbeatOutput: "docker-${version}-${buildType}-metricbeat.log", archiveOnlyOnFail: true){ - dir("${BASE_DIR}"){ - try { - retryWithSleep(retries: 2, seconds: 5, backoff: true) { - sh(label: "Run Tests", script: """.ci/scripts/test.sh -b "${buildType}" "${version}" """) - } - } finally { - junit(testResults: "test_output/*.junit.xml", allowEmptyResults: true, keepLongStdio: true) - archiveArtifacts(artifacts: "test_output/*.tap", allowEmptyArchive: true) - } - } - } - } - } - } -} - -def generateStepForWindows(Map params = [:]){ - def version = params?.version - def contextManager = params.get('disableAsyncHooks', false) ? 'patch' : '' - return { - sh label: 'Prepare services', script: ".ci/scripts/windows/prepare-test.sh ${version}" - def linuxIp = grabWorkerIP() - withNode(labels: 'windows-2019-docker-immutable', forceWorkspace: true, forceWorker: true) { - // When installing with choco the PATH might not be updated within the already connected worker. - withEnv(["PATH=${PATH};C:\\Program Files\\nodejs", - "VERSION=${version}", - "ELASTIC_APM_CONTEXT_MANAGER=${contextManager}", - "CASSANDRA_HOST=${linuxIp}", - "ES_HOST=${linuxIp}", - "LOCALSTACK_HOST=${linuxIp}", - "MEMCACHED_HOST=${linuxIp}", - "MONGODB_HOST=${linuxIp}", - "MSSQL_HOST=${linuxIp}", - "MYSQL_HOST=${linuxIp}", - "PGHOST=${linuxIp}", - "REDIS_HOST=${linuxIp}"]) { - try { - deleteDir() - unstash 'source' - dir(BASE_DIR) { - bat label: 'Ping linux worker', script: "ping -n 3 ${linuxIp}" - installTools([ [tool: 'nodejs-lts', version: "${version}" ] ]) - bat label: 'Tool versions', script: ''' - npm --version - node --version - ''' - retryWithSleep(retries: 2, sideEffect: { bat 'npm cache clean --force' }) { - bat 'npm install' - } - bat 'node test/test.js' - } - } catch(e){ - error(e.toString()) - } finally { - echo 'JUnit archiving no yet in place' - } - } - } - - // If the above execution failed, then it will not reach this section. TBD - sh label: 'Stop services', script: ".ci/scripts/windows/stop-test.sh ${version}" - } -} - - -def grabWorkerIP(){ - def linuxIp = '' - retryWithSleep(retries: 3, seconds: 5, backoff: true){ - linuxIp = sh(label: 'Get IP', script: '''hostname -I | awk '{print $1}' ''', returnStdout: true)?.trim() - log(level: 'INFO', text: "Worker IP '${linuxIp}'") - if(!linuxIp?.trim()){ - error('Unable to get the Linux worker IP') - } - } - return linuxIp -} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 24a7540bbe..da1df16474 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,13 +1,3 @@ -# Run a significant subset of tests on GitHub Actions. -# -# Examples of things *not* being run here currently that are run by -# the Jenkins-based tests: -# - a test run on windows -# - the "TAV" tests that run against all supported versions of instrumented -# modules -# - the integration tests that run with an apm-server -# - code coverage (npm run coverage) - name: Test # https://github.community/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662/2 @@ -40,7 +30,6 @@ jobs: # These services and their configuration should match test/docker-compose.yml. services: - redis: image: redis ports: @@ -161,3 +150,16 @@ jobs: path: "test_output/*.junit.xml" type: "junit" githubToken: ${{ secrets.GITHUB_TOKEN }} + + test-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 14 + cache: 'npm' + - run: npm install + - run: npm ls --all || true + # Run a subset of tests that we can reasonably get running on Windows CI. + - run: node test/test.js diff --git a/test/instrumentation/modules/@elastic/elasticsearch-canary.test.js b/test/instrumentation/modules/@elastic/elasticsearch-canary.test.js index ad1bb4119b..6eca93bc95 100644 --- a/test/instrumentation/modules/@elastic/elasticsearch-canary.test.js +++ b/test/instrumentation/modules/@elastic/elasticsearch-canary.test.js @@ -6,5 +6,10 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + process.env.ELASTIC_APM_TEST_ESCLIENT_PACKAGE_NAME = '@elastic/elasticsearch-canary' require('./elasticsearch.test.js') diff --git a/test/instrumentation/modules/@elastic/elasticsearch.test.js b/test/instrumentation/modules/@elastic/elasticsearch.test.js index 2a2576f519..8fe9d345ec 100644 --- a/test/instrumentation/modules/@elastic/elasticsearch.test.js +++ b/test/instrumentation/modules/@elastic/elasticsearch.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + process.env.ELASTIC_APM_TEST = true const agent = require('../../../..').start({ serviceName: 'test-elasticsearch', diff --git a/test/instrumentation/modules/apollo-server-express.test.js b/test/instrumentation/modules/apollo-server-express.test.js index 58bca92d45..a12d57f99d 100644 --- a/test/instrumentation/modules/apollo-server-express.test.js +++ b/test/instrumentation/modules/apollo-server-express.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', diff --git a/test/instrumentation/modules/aws-sdk/aws4-retries.test.js b/test/instrumentation/modules/aws-sdk/aws4-retries.test.js index 907f0eadec..7b2b390544 100644 --- a/test/instrumentation/modules/aws-sdk/aws4-retries.test.js +++ b/test/instrumentation/modules/aws-sdk/aws4-retries.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + // Test the fix for bug #2134, that AWS4 signature auth with the aws-sdk // and *retries* works as expected. diff --git a/test/instrumentation/modules/aws-sdk/dynamodb.test.js b/test/instrumentation/modules/aws-sdk/dynamodb.test.js index a27a0634bb..bc1f623b3c 100644 --- a/test/instrumentation/modules/aws-sdk/dynamodb.test.js +++ b/test/instrumentation/modules/aws-sdk/dynamodb.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + const agent = require('../../../..').start({ serviceName: 'test-dynamodb', captureExceptions: false, diff --git a/test/instrumentation/modules/aws-sdk/s3.test.js b/test/instrumentation/modules/aws-sdk/s3.test.js index 3c61f812b6..4a817b6e3c 100644 --- a/test/instrumentation/modules/aws-sdk/s3.test.js +++ b/test/instrumentation/modules/aws-sdk/s3.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + // Test S3 instrumentation of the 'aws-sdk' module. // // Note that this uses localstack for testing, which mimicks the S3 API but diff --git a/test/instrumentation/modules/aws-sdk/sns.test.js b/test/instrumentation/modules/aws-sdk/sns.test.js index 3826ab24eb..a2e2a09b2e 100644 --- a/test/instrumentation/modules/aws-sdk/sns.test.js +++ b/test/instrumentation/modules/aws-sdk/sns.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + const agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', diff --git a/test/instrumentation/modules/aws-sdk/sqs.test.js b/test/instrumentation/modules/aws-sdk/sqs.test.js index 5b9af7ce4d..72aaf74e46 100644 --- a/test/instrumentation/modules/aws-sdk/sqs.test.js +++ b/test/instrumentation/modules/aws-sdk/sqs.test.js @@ -5,6 +5,12 @@ */ 'use strict' + +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + const agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', diff --git a/test/instrumentation/modules/bluebird/bluebird.test.js b/test/instrumentation/modules/bluebird/bluebird.test.js index b516df996d..6ea15b7292 100644 --- a/test/instrumentation/modules/bluebird/bluebird.test.js +++ b/test/instrumentation/modules/bluebird/bluebird.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + // The unhandledRejection will be fired by our bluebird tests, which is to be // expected. require('../../../_promise_rejection').remove() diff --git a/test/instrumentation/modules/bluebird/cancel.test.js b/test/instrumentation/modules/bluebird/cancel.test.js index dfc1d7559f..861495e0c8 100644 --- a/test/instrumentation/modules/bluebird/cancel.test.js +++ b/test/instrumentation/modules/bluebird/cancel.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', diff --git a/test/instrumentation/modules/cassandra-driver/index.test.js b/test/instrumentation/modules/cassandra-driver/index.test.js index 5ff13471b9..4c74b98cf4 100644 --- a/test/instrumentation/modules/cassandra-driver/index.test.js +++ b/test/instrumentation/modules/cassandra-driver/index.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + const agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', diff --git a/test/instrumentation/modules/elasticsearch.test.js b/test/instrumentation/modules/elasticsearch.test.js index 2440f3a958..4236521840 100644 --- a/test/instrumentation/modules/elasticsearch.test.js +++ b/test/instrumentation/modules/elasticsearch.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + process.env.ELASTIC_APM_TEST = true var host = (process.env.ES_HOST || 'localhost') + ':9200' diff --git a/test/instrumentation/modules/express-graphql.test.js b/test/instrumentation/modules/express-graphql.test.js index b79128eaa4..53b01fe874 100644 --- a/test/instrumentation/modules/express-graphql.test.js +++ b/test/instrumentation/modules/express-graphql.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', diff --git a/test/instrumentation/modules/express-queue.test.js b/test/instrumentation/modules/express-queue.test.js index 84ed9768c3..d4a77e4949 100644 --- a/test/instrumentation/modules/express-queue.test.js +++ b/test/instrumentation/modules/express-queue.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', diff --git a/test/instrumentation/modules/express/basic.test.js b/test/instrumentation/modules/express/basic.test.js index 2ff9bda0b9..81fd9f35f1 100644 --- a/test/instrumentation/modules/express/basic.test.js +++ b/test/instrumentation/modules/express/basic.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', diff --git a/test/instrumentation/modules/express/capture-exceptions-off.test.js b/test/instrumentation/modules/express/capture-exceptions-off.test.js index 9ce8065733..f450cf7d93 100644 --- a/test/instrumentation/modules/express/capture-exceptions-off.test.js +++ b/test/instrumentation/modules/express/capture-exceptions-off.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + const agent = require('../../../..').start({ captureExceptions: false, metricsInterval: 0, diff --git a/test/instrumentation/modules/express/capture-exceptions-on.test.js b/test/instrumentation/modules/express/capture-exceptions-on.test.js index e306c9cb42..d8b8b712e0 100644 --- a/test/instrumentation/modules/express/capture-exceptions-on.test.js +++ b/test/instrumentation/modules/express/capture-exceptions-on.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + const agent = require('../../../..').start({ captureExceptions: true, metricsInterval: 0, diff --git a/test/instrumentation/modules/express/set-framework.test.js b/test/instrumentation/modules/express/set-framework.test.js index eab44bc789..ce2836d552 100644 --- a/test/instrumentation/modules/express/set-framework.test.js +++ b/test/instrumentation/modules/express/set-framework.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + const agent = require('../../../..').start({ captureExceptions: true, metricsInterval: 0, diff --git a/test/instrumentation/modules/fastify/async-await.test.js b/test/instrumentation/modules/fastify/async-await.test.js index 8dd1b85b6a..3055342ba1 100644 --- a/test/instrumentation/modules/fastify/async-await.test.js +++ b/test/instrumentation/modules/fastify/async-await.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + require('../../../..').start({ captureExceptions: false, metricsInterval: 0, diff --git a/test/instrumentation/modules/fastify/fastify.test.js b/test/instrumentation/modules/fastify/fastify.test.js index cde6f52495..9427c4889c 100644 --- a/test/instrumentation/modules/fastify/fastify.test.js +++ b/test/instrumentation/modules/fastify/fastify.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + const agent = require('../../../..').start({ captureExceptions: false, metricsInterval: 0, diff --git a/test/instrumentation/modules/fastify/set-framework.test.js b/test/instrumentation/modules/fastify/set-framework.test.js index b4487b618a..f59276e583 100644 --- a/test/instrumentation/modules/fastify/set-framework.test.js +++ b/test/instrumentation/modules/fastify/set-framework.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + const agent = require('../../../..').start({ captureExceptions: true, metricsInterval: 0, diff --git a/test/instrumentation/modules/finalhandler.test.js b/test/instrumentation/modules/finalhandler.test.js index 940f6f2813..a34c7a221b 100644 --- a/test/instrumentation/modules/finalhandler.test.js +++ b/test/instrumentation/modules/finalhandler.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', diff --git a/test/instrumentation/modules/generic-pool.test.js b/test/instrumentation/modules/generic-pool.test.js index 93e92e02e2..4e1377825e 100644 --- a/test/instrumentation/modules/generic-pool.test.js +++ b/test/instrumentation/modules/generic-pool.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', diff --git a/test/instrumentation/modules/graphql.test.js b/test/instrumentation/modules/graphql.test.js index a9a71a5c49..8278130438 100644 --- a/test/instrumentation/modules/graphql.test.js +++ b/test/instrumentation/modules/graphql.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../..').start({ serviceName: 'test', secretToken: 'test', diff --git a/test/instrumentation/modules/handlebars.test.js b/test/instrumentation/modules/handlebars.test.js index 8e51f95042..6475545f0c 100644 --- a/test/instrumentation/modules/handlebars.test.js +++ b/test/instrumentation/modules/handlebars.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + process.env.ELASTIC_APM_TEST = true var agent = require('../../..').start({ diff --git a/test/instrumentation/modules/http/github-423.test.js b/test/instrumentation/modules/http/github-423.test.js index a00bebfbfa..e74e2fe50f 100644 --- a/test/instrumentation/modules/http/github-423.test.js +++ b/test/instrumentation/modules/http/github-423.test.js @@ -54,7 +54,7 @@ test('https://github.com/elastic/apm-agent-nodejs/issues/423', function (t) { var server = http.createServer(function (req, res) { got(url).then(function (response) { t.strictEqual(response.body.length, fileSize, 'body should be expected size') - t.strictEqual(response.body.slice(0, 12), '/*\n * Copyri', 'body should be uncompressed') + t.ok(response.body.includes('Copyright Elasticsearch'), 'body should be uncompressed') res.end() }) }) diff --git a/test/instrumentation/modules/ioredis.test.js b/test/instrumentation/modules/ioredis.test.js index e7d388f4e2..fb8e55313d 100644 --- a/test/instrumentation/modules/ioredis.test.js +++ b/test/instrumentation/modules/ioredis.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../..').start({ serviceName: 'test-ioredis', captureExceptions: false, diff --git a/test/instrumentation/modules/koa-router/new-name.test.js b/test/instrumentation/modules/koa-router/new-name.test.js index de807c3121..f692060574 100644 --- a/test/instrumentation/modules/koa-router/new-name.test.js +++ b/test/instrumentation/modules/koa-router/new-name.test.js @@ -6,4 +6,9 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + require('./shared')('@koa/router') diff --git a/test/instrumentation/modules/koa-router/old-name.test.js b/test/instrumentation/modules/koa-router/old-name.test.js index 03015d529e..8ed884790a 100644 --- a/test/instrumentation/modules/koa-router/old-name.test.js +++ b/test/instrumentation/modules/koa-router/old-name.test.js @@ -6,4 +6,9 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + require('./shared')('koa-router') diff --git a/test/instrumentation/modules/mimic-response.test.js b/test/instrumentation/modules/mimic-response.test.js index 5bc7371459..cf927f76d5 100644 --- a/test/instrumentation/modules/mimic-response.test.js +++ b/test/instrumentation/modules/mimic-response.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../..').start({ serviceName: 'test', captureExceptions: false, diff --git a/test/instrumentation/modules/mongodb-core.test.js b/test/instrumentation/modules/mongodb-core.test.js index 9ec0f0fb3c..685070c309 100644 --- a/test/instrumentation/modules/mongodb-core.test.js +++ b/test/instrumentation/modules/mongodb-core.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../..').start({ serviceName: 'test-mongodb-core', captureExceptions: false, diff --git a/test/instrumentation/modules/mongodb.test.js b/test/instrumentation/modules/mongodb.test.js index 1ff48f1196..488272b32e 100644 --- a/test/instrumentation/modules/mongodb.test.js +++ b/test/instrumentation/modules/mongodb.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + const agent = require('../../..').start({ serviceName: 'test-mongodb', captureExceptions: false, diff --git a/test/instrumentation/modules/mysql/mysql.test.js b/test/instrumentation/modules/mysql/mysql.test.js index e81dfd1a3a..3f5a49548c 100644 --- a/test/instrumentation/modules/mysql/mysql.test.js +++ b/test/instrumentation/modules/mysql/mysql.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', diff --git a/test/instrumentation/modules/mysql/pool-release-1.test.js b/test/instrumentation/modules/mysql/pool-release-1.test.js index e20aed332d..e625c429df 100644 --- a/test/instrumentation/modules/mysql/pool-release-1.test.js +++ b/test/instrumentation/modules/mysql/pool-release-1.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', diff --git a/test/instrumentation/modules/mysql2/mysql.test.js b/test/instrumentation/modules/mysql2/mysql.test.js index 9dff1ae63f..fa4379b227 100644 --- a/test/instrumentation/modules/mysql2/mysql.test.js +++ b/test/instrumentation/modules/mysql2/mysql.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', diff --git a/test/instrumentation/modules/mysql2/pool-release-1.test.js b/test/instrumentation/modules/mysql2/pool-release-1.test.js index bc11c80f6c..c1c768e16a 100644 --- a/test/instrumentation/modules/mysql2/pool-release-1.test.js +++ b/test/instrumentation/modules/mysql2/pool-release-1.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', diff --git a/test/instrumentation/modules/next/next.test.js b/test/instrumentation/modules/next/next.test.js index cc867ad0f3..24ace91ace 100644 --- a/test/instrumentation/modules/next/next.test.js +++ b/test/instrumentation/modules/next/next.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + // Test Next.js instrumentation. // // This test roughly does the following: diff --git a/test/instrumentation/modules/pg/knex-no-span-stack-traces.test.js b/test/instrumentation/modules/pg/knex-no-span-stack-traces.test.js index 3e5f9b1a22..0bd0756e05 100644 --- a/test/instrumentation/modules/pg/knex-no-span-stack-traces.test.js +++ b/test/instrumentation/modules/pg/knex-no-span-stack-traces.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../../..').start({ serviceName: 'test-knex-no-span-stack-traces', secretToken: 'test', diff --git a/test/instrumentation/modules/pg/knex.test.js b/test/instrumentation/modules/pg/knex.test.js index 0612c4864a..e51e98b33d 100644 --- a/test/instrumentation/modules/pg/knex.test.js +++ b/test/instrumentation/modules/pg/knex.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + process.env.ELASTIC_APM_TEST = true var agent = require('../../../..').start({ diff --git a/test/instrumentation/modules/pg/pg.test.js b/test/instrumentation/modules/pg/pg.test.js index 6b3e64de61..40451fca1c 100644 --- a/test/instrumentation/modules/pg/pg.test.js +++ b/test/instrumentation/modules/pg/pg.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../../..').start({ serviceName: 'test-pg', captureExceptions: false, diff --git a/test/instrumentation/modules/pug.test.js b/test/instrumentation/modules/pug.test.js index 7b4f97fb5d..b83ef83781 100644 --- a/test/instrumentation/modules/pug.test.js +++ b/test/instrumentation/modules/pug.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + process.env.ELASTIC_APM_TEST = true var agent = require('../../..').start({ diff --git a/test/instrumentation/modules/redis-2-3.test.js b/test/instrumentation/modules/redis-2-3.test.js index 725ea63fa7..a08e0737df 100644 --- a/test/instrumentation/modules/redis-2-3.test.js +++ b/test/instrumentation/modules/redis-2-3.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var redisVersion = require('redis/package.json').version var semver = require('semver') if (semver.gte(redisVersion, '4.0.0')) { diff --git a/test/instrumentation/modules/redis.test.js b/test/instrumentation/modules/redis.test.js index 73d0962ec9..33f5fb5449 100644 --- a/test/instrumentation/modules/redis.test.js +++ b/test/instrumentation/modules/redis.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + const redisVersion = require('redis/package.json').version const semver = require('semver') diff --git a/test/instrumentation/modules/redis4-legacy.test.js b/test/instrumentation/modules/redis4-legacy.test.js index e790fe36fe..032c9915aa 100644 --- a/test/instrumentation/modules/redis4-legacy.test.js +++ b/test/instrumentation/modules/redis4-legacy.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + // this test file is about testing `legacyMode` // https://github.com/redis/node-redis/blob/HEAD/docs/v3-to-v4.md#legacy-mode const redisVersion = require('redis/package.json').version diff --git a/test/instrumentation/modules/restify/basic.test.js b/test/instrumentation/modules/restify/basic.test.js index 426efe306c..22ab6d023e 100644 --- a/test/instrumentation/modules/restify/basic.test.js +++ b/test/instrumentation/modules/restify/basic.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + const isRestifyIncompat = require('../../../_is_restify_incompat')() if (isRestifyIncompat) { console.log(`# SKIP ${isRestifyIncompat}`) diff --git a/test/instrumentation/modules/restify/set-framework.test.js b/test/instrumentation/modules/restify/set-framework.test.js index 8403732eab..6644992ecd 100644 --- a/test/instrumentation/modules/restify/set-framework.test.js +++ b/test/instrumentation/modules/restify/set-framework.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + const isRestifyIncompat = require('../../../_is_restify_incompat')() if (isRestifyIncompat) { console.log(`# SKIP ${isRestifyIncompat}`) diff --git a/test/instrumentation/modules/tedious.test.js b/test/instrumentation/modules/tedious.test.js index a3403937b1..b054462e3c 100644 --- a/test/instrumentation/modules/tedious.test.js +++ b/test/instrumentation/modules/tedious.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + const agent = require('../../../').start({ serviceName: 'test-tedious', captureExceptions: false, diff --git a/test/instrumentation/modules/undici/fetch.test.js b/test/instrumentation/modules/undici/fetch.test.js index 8377e4d428..552777cb12 100644 --- a/test/instrumentation/modules/undici/fetch.test.js +++ b/test/instrumentation/modules/undici/fetch.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + // Test node v18's `fetch` implementation (based on undici). // // Importantly, this test must not `require('undici')` because part of the diff --git a/test/instrumentation/modules/undici/undici.test.js b/test/instrumentation/modules/undici/undici.test.js index a65902fcfd..8f14f6f8ab 100644 --- a/test/instrumentation/modules/undici/undici.test.js +++ b/test/instrumentation/modules/undici/undici.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + process.env.ELASTIC_APM_TEST = true const { CapturingTransport } = require('../../../_capturing_transport') const apm = require('../../../..').start({ diff --git a/test/instrumentation/modules/ws.test.js b/test/instrumentation/modules/ws.test.js index d212a79806..cbcec4f371 100644 --- a/test/instrumentation/modules/ws.test.js +++ b/test/instrumentation/modules/ws.test.js @@ -6,6 +6,11 @@ 'use strict' +if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'win32') { + console.log('# SKIP: GH Actions do not support docker services on Windows') + process.exit(0) +} + var agent = require('../../..').start({ serviceName: 'test-ws', captureExceptions: false, diff --git a/test/opentelemetry-bridge/fixtures.test.js b/test/opentelemetry-bridge/fixtures.test.js index c32657a846..b5468694bf 100644 --- a/test/opentelemetry-bridge/fixtures.test.js +++ b/test/opentelemetry-bridge/fixtures.test.js @@ -97,35 +97,38 @@ const cases = [ // `- transaction "GET unknown route" (context.request.headers.{traceparent,tracestate}) // `- span "GET localhost:$portB" (context.http.url=http://localhost:$portB/b-ping) // `- transaction "GET unknown route" (context.request.headers.{traceparent,tracestate}) + // + // Dev Note: On Windows GitHub Actions runners the timestamp ordering of + // the transaction and span events is not reliable. script: 'distributed-trace.js', check: (t, events) => { + let e + t.equal(events.length, 6, 'exactly 6 events') t.ok(events[0].metadata, 'APM server got event metadata object') - // All the transactions and spans, in timestamp order. - const tas = events.slice(1) - .sort((a, b) => (a.transaction || a.span).timestamp - (b.transaction || b.span).timestamp) // transaction "callServiceA" - t.equal(tas[0].transaction.name, 'callServiceA') + e = findObjInArray(events, 'transaction.name', 'callServiceA') + t.equal(e.transaction.parent_id, undefined, 'trans "callServiceA" has no parent_id') // `- span "GET localhost:$portA" (context.http.url=http://localhost:$portA/a-ping) - const portA = tas[1].span.context.destination.port - t.equal(tas[1].span.parent_id, tas[0].transaction.id) - t.equal(tas[1].span.name, `GET localhost:${portA}`) - t.ok(tas[1].span.context.http.url, `http://localhost:${portA}/a-ping`) + e = findObjInArray(events, 'span.parent_id', e.transaction.id) + const portA = e.span.context.destination.port + t.equal(e.span.name, `GET localhost:${portA}`) + t.ok(e.span.context.http.url, `http://localhost:${portA}/a-ping`) // `- transaction "GET unknown route" (context.request.headers.{traceparent,tracestate}) - t.equal(tas[2].transaction.parent_id, tas[1].span.id) - t.equal(tas[2].transaction.name, 'GET unknown route') - t.ok(tas[2].transaction.context.request.headers.traceparent) - t.equal(tas[2].transaction.context.request.headers.tracestate, 'es=s:1') + e = findObjInArray(events, 'transaction.parent_id', e.span.id) + t.equal(e.transaction.name, 'GET unknown route') + t.ok(e.transaction.context.request.headers.traceparent) + t.equal(e.transaction.context.request.headers.tracestate, 'es=s:1') // `- span "GET localhost:$portB" (context.http.url=http://localhost:$portB/b-ping) - const portB = tas[3].span.context.destination.port - t.equal(tas[3].span.parent_id, tas[2].transaction.id) - t.equal(tas[3].span.name, `GET localhost:${portB}`) - t.ok(tas[3].span.context.http.url, `http://localhost:${portB}/b-ping`) + e = findObjInArray(events, 'span.parent_id', e.transaction.id) + const portB = e.span.context.destination.port + t.equal(e.span.name, `GET localhost:${portB}`) + t.ok(e.span.context.http.url, `http://localhost:${portB}/b-ping`) // `- transaction "GET unknown route" (context.request.headers.{traceparent,tracestate}) - t.equal(tas[4].transaction.parent_id, tas[3].span.id) - t.equal(tas[4].transaction.name, 'GET unknown route') - t.ok(tas[4].transaction.context.request.headers.traceparent) - t.equal(tas[4].transaction.context.request.headers.tracestate, 'es=s:1') + e = findObjInArray(events, 'transaction.parent_id', e.span.id) + t.equal(e.transaction.name, 'GET unknown route') + t.ok(e.transaction.context.request.headers.traceparent) + t.equal(e.transaction.context.request.headers.tracestate, 'es=s:1') } },