Skip to content

Commit 5979b64

Browse files
committed
Merge branch 'master' into new-js-client
2 parents 451ac7d + 76a34a6 commit 5979b64

File tree

127 files changed

+3237
-1167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+3237
-1167
lines changed

.ci/.jenkins_edge_nodejs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
NODEJS_VERSION:
2+
- "12"
3+
- "11"
4+
- "10"
5+
- "8"
6+
- "6"

.ci/docker/docker-compose-edge.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
version: '2.1'
2+
3+
services:
4+
cassandra:
5+
extends:
6+
file: docker-compose.yml
7+
service: cassandra
8+
elasticsearch:
9+
extends:
10+
file: docker-compose.yml
11+
service: elasticsearch
12+
mongodb:
13+
extends:
14+
file: docker-compose.yml
15+
service: mongodb
16+
mssql:
17+
extends:
18+
file: docker-compose.yml
19+
service: mssql
20+
mysql:
21+
extends:
22+
file: docker-compose.yml
23+
service: mysql
24+
postgres:
25+
extends:
26+
file: docker-compose.yml
27+
service: postgres
28+
redis:
29+
extends:
30+
file: docker-compose.yml
31+
service: redis
32+
node_tests:
33+
extends:
34+
file: docker-compose-node-edge-test.yml
35+
service: node_tests
36+
depends_on:
37+
cassandra:
38+
condition: service_healthy
39+
elasticsearch:
40+
condition: service_healthy
41+
mongodb:
42+
condition: service_healthy
43+
mssql:
44+
condition: service_healthy
45+
mysql:
46+
condition: service_healthy
47+
postgres:
48+
condition: service_healthy
49+
redis:
50+
condition: service_healthy
51+
52+
volumes:
53+
nodepgdata:
54+
driver: local
55+
nodemongodata:
56+
driver: local
57+
nodemssqldata:
58+
driver: local
59+
nodemysqldata:
60+
driver: local
61+
nodeesdata:
62+
driver: local
63+
nodecassandradata:
64+
driver: local
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: '2.1'
2+
3+
services:
4+
node_tests:
5+
build:
6+
context: node-edge-container
7+
dockerfile: Dockerfile
8+
args:
9+
- NODE_VERSION=${NODE_VERSION}
10+
- NVM_NODEJS_ORG_MIRROR=${NVM_NODEJS_ORG_MIRROR}
11+
- ELASTIC_APM_ASYNC_HOOKS=${ELASTIC_APM_ASYNC_HOOKS}
12+
working_dir: /app
13+
command: >
14+
/bin/bash -c ".ci/scripts/docker-test.sh"
15+
environment:
16+
MONGODB_HOST: 'mongodb'
17+
REDIS_HOST: 'redis'
18+
ES_HOST: 'elasticsearch'
19+
MSSQL_HOST: 'mssql'
20+
MYSQL_HOST: 'mysql'
21+
CASSANDRA_HOST: 'cassandra'
22+
PGHOST: 'postgres'
23+
PGUSER: 'postgres'
24+
NODE_VERSION: ${NODE_VERSION}
25+
NVM_NODEJS_ORG_MIRROR: ${NVM_NODEJS_ORG_MIRROR}
26+
ELASTIC_APM_ASYNC_HOOKS: ${ELASTIC_APM_ASYNC_HOOKS}
27+
TAV: ${TAV_VERSIONS}
28+
HOME: /tmp
29+
volumes:
30+
- ${PWD}:/app
31+
user: ${USER_ID}

.ci/docker/docker-compose-node-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ services:
2121
PGUSER: 'postgres'
2222
NODE_VERSION: ${NODE_VERSION}
2323
TAV: ${TAV_VERSIONS}
24+
ELASTIC_APM_ASYNC_HOOKS: ${ELASTIC_APM_ASYNC_HOOKS}
2425
HOME: /tmp
2526
PATH: /app/node_modules/.bin:./node_modules/.bin:/app/node_modules:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
2627
volumes:

.ci/docker/node-container/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ WORKDIR /npm
55
RUN ( [ "${NODE_VERSION%%.*}" -le 8 ] \
66
&& echo "Node.js ${NODE_VERSION} - Manual install npm" \
77
&& mkdir -p /npm/node_modules \
8-
&& npm install npm \
8+
&& npm install npm@6.9.0 \
99
&& rm /usr/local/bin/npm \
1010
&& ln -s /npm/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm ) || exit 0
1111

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
FROM ubuntu:18.04
2+
3+
# Install nvm dependencies
4+
RUN apt-get -qq update \
5+
&& apt-get -qq install -y build-essential \
6+
&& apt-get -qq install -y libssl-dev \
7+
&& apt-get -qq install -y curl \
8+
&& apt-get -qq clean \
9+
&& rm -fr /var/lib/apt/lists/*
10+
11+
# Environment variables to set what version to be installed
12+
ARG NODE_VERSION
13+
ARG NVM_NODEJS_ORG_MIRROR
14+
ARG ELASTIC_APM_ASYNC_HOOKS
15+
ENV NODE_VERSION=${NODE_VERSION}
16+
ENV NVM_NODEJS_ORG_MIRROR=${NVM_NODEJS_ORG_MIRROR}
17+
ENV ELASTIC_APM_ASYNC_HOOKS=${ELASTIC_APM_ASYNC_HOOKS}
18+
19+
# nvm environment variables
20+
ENV NVM_VERSION v0.34.0
21+
ENV NVM_DIR /usr/local/nvm
22+
RUN mkdir $NVM_DIR
23+
RUN curl --silent -o- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh | bash
24+
25+
ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
26+
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
27+
28+
# Install node
29+
RUN echo "source $NVM_DIR/nvm.sh && \
30+
nvm install $NODE_VERSION && \
31+
nvm alias default $NODE_VERSION && \
32+
nvm use default" | bash
33+
34+
# Create symlinks
35+
RUN echo "source $NVM_DIR/nvm.sh && \
36+
nvm version > /tmp/version" | bash
37+
RUN ln -fs $NVM_DIR/$(cat /tmp/version) $NVM_DIR/v$NODE_VERSION && \
38+
ln -fs $NVM_DIR/versions/node/$(cat /tmp/version) $NVM_DIR/versions/node/v$NODE_VERSION
39+
40+
RUN ( [ "${NODE_VERSION%%.*}" -le 8 ] \
41+
&& echo "Node.js ${NODE_VERSION} - Manual install npm" \
42+
&& mkdir -p /npm/node_modules \
43+
&& npm install npm@6.9.0 \
44+
&& rm /usr/local/bin/npm \
45+
&& ln -s /npm/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm ) || exit 0
46+
47+
RUN ( [ "${NODE_VERSION%%.*}" -gt 8 ] \
48+
&& echo "Node.js ${NODE_VERSION} - upgrade npm" \
49+
&& npm install -g npm@latest) || exit 0
50+
51+
# test npm works properly
52+
RUN node --version && npm --version
53+
54+
# Set the PATH again
55+
ENV PATH /app/node_modules/.bin:./node_modules/.bin:/app/node_modules:$PATH
56+
57+
WORKDIR /app

.ci/downstreamTests.groovy

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ it is need as field to store the results of the tests.
1313
pipeline {
1414
agent any
1515
environment {
16-
BASE_DIR="src/github.com/elastic/apm-agent-nodejs"
16+
REPO = 'apm-agent-nodejs'
17+
BASE_DIR="src/github.com/elastic/${REPO}"
1718
PIPELINE_LOG_LEVEL='INFO'
1819
NOTIFY_TO = credentials('notify-to')
1920
JOB_GCS_BUCKET = credentials('gcs-bucket')
@@ -30,9 +31,9 @@ pipeline {
3031
quietPeriod(10)
3132
}
3233
parameters {
33-
string(name: 'NODE_VERSION', defaultValue: "11", description: "Node.js version to test")
34+
string(name: 'NODE_VERSION', defaultValue: "12", description: "Node.js version to test")
3435
string(name: 'BRANCH_SPECIFIER', defaultValue: "master", description: "Git branch/tag to use")
35-
string(name: 'CHANGE_TARGET', defaultValue: "master", description: "Git branch/tag to merge before building")
36+
string(name: 'MERGE_TARGET', defaultValue: "master", description: "Git branch/tag to merge before building")
3637
}
3738
stages {
3839
/**
@@ -47,7 +48,7 @@ pipeline {
4748
branch: "${params.BRANCH_SPECIFIER}",
4849
repo: "${REPO}",
4950
credentialsId: "${JOB_GIT_CREDENTIALS}",
50-
mergeTarget: "${params.CHANGE_TARGET}"
51+
mergeTarget: "${params.MERGE_TARGET}",
5152
reference: '/var/lib/jenkins/apm-agent-nodejs.git')
5253
stash allowEmpty: true, name: 'source', useDefaultExcludes: false
5354
}
@@ -82,29 +83,22 @@ pipeline {
8283
}
8384
}
8485
post {
85-
always{
86+
cleanup{
8687
script{
8788
if(nodeTasksGen?.results){
8889
writeJSON(file: 'results.json', json: toJSON(nodeTasksGen.results), pretty: 2)
8990
def mapResults = ["${params.agent_integration_test}": nodeTasksGen.results]
9091
def processor = new ResultsProcessor()
9192
processor.processResults(mapResults)
9293
archiveArtifacts allowEmptyArchive: true, artifacts: 'results.json,results.html', defaultExcludes: false
94+
catchError(buildResult: 'SUCCESS') {
95+
def datafile = readFile(file: "results.json")
96+
def json = getVaultSecret(secret: 'secret/apm-team/ci/jenkins-stats-cloud')
97+
sendDataToElasticsearch(es: json.data.url, data: datafile, restCall: '/jenkins-builds-nodejs-test-results/_doc/')
98+
}
9399
}
94100
}
95-
}
96-
success {
97-
echoColor(text: '[SUCCESS]', colorfg: 'green', colorbg: 'default')
98-
}
99-
aborted {
100-
echoColor(text: '[ABORTED]', colorfg: 'magenta', colorbg: 'default')
101-
}
102-
failure {
103-
echoColor(text: '[FAILURE]', colorfg: 'red', colorbg: 'default')
104-
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${NOTIFY_TO}", sendToIndividuals: false])
105-
}
106-
unstable {
107-
echoColor(text: '[UNSTABLE]', colorfg: 'yellow', colorbg: 'default')
101+
notifyBuildResult()
108102
}
109103
}
110104
}
@@ -130,9 +124,9 @@ class NodeParallelTaskGenerator extends DefaultParallelTaskGenerator {
130124
saveResult(x, y, 1)
131125
} catch(e){
132126
saveResult(x, y, 0)
133-
error("${label} tests failed : ${e.toString()}\n")
127+
steps.error("${label} tests failed : ${e.toString()}\n")
134128
} finally {
135-
wrappingUp()
129+
steps.wrappingUp()
136130
}
137131
}
138132
}
@@ -158,9 +152,9 @@ def runScript(Map params = [:]){
158152
Collect test results and report to Codecov
159153
*/
160154
def wrappingUp(){
161-
docker.image('node:11').inside("-v ${WORKSPACE}/${BASE_DIR}:/app"){
162-
steps.sh(label: "Convert Test results to JUnit format", script: 'cd /app && .ci/convert_tap_to_junit.sh')
155+
docker.image('node:12').inside("-v ${WORKSPACE}/${BASE_DIR}:/app"){
156+
sh(label: "Convert Test results to JUnit format", script: 'cd /app && .ci/scripts/convert_tap_to_junit.sh')
163157
}
164158
junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/**/junit-*.xml")
165-
codecov(repo: 'apm-agent-nodejs', basedir: "${BASE_DIR}", secret: "${CODECOV_SECRET}")
159+
codecov(repo: env.REPO, basedir: "${BASE_DIR}", secret: "${CODECOV_SECRET}")
166160
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
- job:
3+
name: apm-agent-nodejs/apm-agent-nodejs-downstream
4+
display-name: APM Agent Node.js Downstream
5+
description: APM Agent Node.js Downstream
6+
script-path: .ci/downstreamTests.groovy
7+
scm:
8+
- github:
9+
branch-discovery: no-pr
10+
discover-pr-forks-strategy: merge-current
11+
discover-pr-forks-trust: permission
12+
discover-pr-origin: merge-current
13+
discover-tags: true
14+
property-strategies:
15+
all-branches:
16+
- suppress-scm-triggering: true
17+
repo: apm-agent-nodejs
18+
repo-owner: elastic
19+
credentials-id: 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken
20+
ssh-checkout:
21+
credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba
22+
clean:
23+
after: true
24+
before: true
25+
prune: true
26+
shallow-clone: true
27+
depth: 3
28+
do-not-fetch-tags: true
29+
submodule:
30+
disable: false
31+
recursive: true
32+
parent-credentials: true
33+
timeout: 100
34+
timeout: '15'
35+
use-author: true
36+
wipe-workspace: 'True'

.ci/jobs/apm-agent-nodejs-mbp.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,39 @@
33
name: apm-agent-nodejs/apm-agent-nodejs-mbp
44
display-name: APM Agent Node.js
55
description: APM Agent Node.js
6+
script-path: Jenkinsfile
7+
scm:
8+
- github:
9+
branch-discovery: no-pr
10+
discover-pr-forks-strategy: merge-current
11+
discover-pr-forks-trust: permission
12+
discover-pr-origin: merge-current
13+
discover-tags: true
14+
head-filter-regex: '^(?!greenkeeper).*$'
15+
repo: apm-agent-nodejs
16+
repo-owner: elastic
17+
credentials-id: 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken
18+
ssh-checkout:
19+
credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba
20+
build-strategies:
21+
- tags:
22+
ignore-tags-older-than: -1
23+
ignore-tags-newer-than: -1
24+
- regular-branches: true
25+
- change-request:
26+
ignore-target-only-changes: false
27+
clean:
28+
after: true
29+
before: true
30+
prune: true
31+
shallow-clone: true
32+
depth: 3
33+
do-not-fetch-tags: true
34+
submodule:
35+
disable: false
36+
recursive: true
37+
parent-credentials: true
38+
timeout: 100
39+
timeout: '15'
40+
use-author: true
41+
wipe-workspace: 'True'
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
- job:
3+
name: apm-agent-nodejs/apm-agent-nodejs-schedule-daily
4+
display-name: Node.js Jobs scheduled daily
5+
description: Node.js Jobs scheduled daily from Monday to Friday
6+
view: APM-CI
7+
project-type: pipeline
8+
parameters:
9+
- string:
10+
name: branch_specifier
11+
default: master
12+
description: the Git branch specifier to build
13+
pipeline-scm:
14+
script-path: .ci/schedule-daily.groovy
15+
scm:
16+
- git:
17+
url: git@github.com:elastic/apm-agent-nodejs.git
18+
refspec: +refs/heads/*:refs/remotes/origin/* +refs/pull/*/head:refs/remotes/origin/pr/*
19+
wipe-workspace: 'True'
20+
name: origin
21+
shallow-clone: true
22+
credentials-id: f6c7695a-671e-4f4f-a331-acdce44ff9ba
23+
reference-repo: /var/lib/jenkins/.git-references/apm-agent-nodejs.git
24+
branches:
25+
- $branch_specifier
26+
triggers:
27+
- timed: 'H H(4-5) * * 1-5'

0 commit comments

Comments
 (0)