Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

action: run on windows #3223

Merged
merged 15 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 2 additions & 130 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -19,11 +19,10 @@ pipeline {
quietPeriod(10)
}
triggers {
issueCommentTrigger("(${obltGitHubComments()}|^run (module|benchmark) tests.*)")
issueCommentTrigger("(^run benchmark tests.*)")
v1v marked this conversation as resolved.
Show resolved Hide resolved
}
parameters {
booleanParam(name: 'bench_ci', defaultValue: true, description: 'Enable benchmarks.')
booleanParam(name: 'tests_ci', defaultValue: true, description: 'Enable tests.')
}
stages {
/**
Expand All @@ -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)
}
}
}
}
}
/**
Expand All @@ -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 }
Expand Down Expand Up @@ -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
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
CHANGELOG.asciidoc merge=union
* -text
19 changes: 11 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# 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)

trentm marked this conversation as resolved.
Show resolved Hide resolved
name: Test

Expand Down Expand Up @@ -161,3 +153,14 @@ 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
v1v marked this conversation as resolved.
Show resolved Hide resolved
- run: npm install
- run: npm ls --all || true
- run: node test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
5 changes: 5 additions & 0 deletions test/instrumentation/modules/@elastic/elasticsearch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 5 additions & 0 deletions test/instrumentation/modules/apollo-server-express.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 5 additions & 0 deletions test/instrumentation/modules/aws-sdk/aws4-retries.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 5 additions & 0 deletions test/instrumentation/modules/aws-sdk/dynamodb.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions test/instrumentation/modules/aws-sdk/s3.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/instrumentation/modules/aws-sdk/sns.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions test/instrumentation/modules/aws-sdk/sqs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 5 additions & 0 deletions test/instrumentation/modules/bluebird/bluebird.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions test/instrumentation/modules/bluebird/cancel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 5 additions & 0 deletions test/instrumentation/modules/cassandra-driver/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 5 additions & 0 deletions test/instrumentation/modules/elasticsearch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
5 changes: 5 additions & 0 deletions test/instrumentation/modules/express-graphql.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 5 additions & 0 deletions test/instrumentation/modules/express-queue.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 5 additions & 0 deletions test/instrumentation/modules/express/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading