From 78d7403a6e9016e244c5164436b918a4bf034d9f Mon Sep 17 00:00:00 2001 From: Bob Evans Date: Fri, 6 Oct 2023 16:12:45 -0400 Subject: [PATCH] tried starting es with docker-compose --- .github/workflows/ci-workflow.yml | 19 +++- docker-compose.yml | 103 ++++++++++++++++++++ package.json | 2 +- test/lib/params.js | 2 +- test/versioned/elastic/elasticsearch.tap.js | 9 +- test/versioned/elastic/package.json | 2 +- third_party_manifest.json | 2 +- 7 files changed, 130 insertions(+), 9 deletions(-) create mode 100755 docker-compose.yml diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index a086e5d1c4..2baa798622 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -20,12 +20,29 @@ jobs: node-version: ${{ matrix.node-version }} - name: Install Dependencies run: npm ci + - name: docker version + run: docker compose -v - name: Run Docker Services run: npm run services - name: Run Versioned Tests - run: TEST_CHILD_TIMEOUT=600000 npm run versioned:internal elastic + run: TEST_CHILD_TIMEOUT=600000 npm run versioned:internal env: VERSIONED_MODE: --minor JOBS: 4 # 2 per CPU seems to be the sweet spot in GHA (July 2022) C8_REPORTER: lcovonly + - name: Upload elastic container logs + if: failure() + uses: jwalton/gh-docker-logs@v2 + with: + images: 'docker.elastic.co/elasticsearch/elasticsearch:8.7.1' + dest: './logs' + - name: Tar logs + if: failure() + run: tar cvzf ./logs.tgz ./logs + - name: Upload logs to GitHub + if: failure() + uses: actions/upload-artifact@master + with: + name: logs.tgz + path: ./logs.tgz diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100755 index 0000000000..86208f7eaa --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,103 @@ +version: "3" +services: + elasticsearch: + container_name: nr_node_elastic + image: docker.elastic.co/elasticsearch/elasticsearch:8.7.1 + environment: + - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + - "network.host=_site_" + - "transport.host=127.0.0.1" + - "discovery.type=single-node" + - "http.host=0.0.0.0" + - "xpack.security.enabled=false" + ports: + - "127.0.0.1:9200:9200" + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:9200"] + interval: 30s + timeout: 10s + retries: 5 + memcached: + container_name: nr_node_memcached + image: memcached + ports: + - "11211:11211" + mongodb_3: + container_name: nr_node_mongodb + platform: linux/amd64 + image: library/mongo:3 + ports: + - "27017:27017" + healthcheck: + test: ["CMD", "mongo", "--quiet"] + interval: 1s + timeout: 10s + retries: 30 + mongodb_5: + container_name: nr_node_mongodb_5 + image: library/mongo:5 + ports: + - "27018:27017" + healthcheck: + test: ["CMD", "mongo", "--quiet"] + interval: 1s + timeout: 10s + retries: 30 + mysql: + container_name: nr_node_mysql + platform: linux/amd64 + image: mysql:5 + ports: + - "3306:3306" + environment: + MYSQL_ALLOW_EMPTY_PASSWORD: 1 + healthcheck: + test: ["CMD", "mysql" ,"-h", "mysql", "-P", "3306", "-u", "root", "-e", "SELECT 1"] + interval: 1s + timeout: 10s + retries: 30 + redis: + container_name: nr_node_redis + image: redis + ports: + - "6379:6379" + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 1s + timeout: 10s + retries: 30 + cassandra: + container_name: nr_node_cassandra + platform: linux/amd64 + image: zmarcantel/cassandra + ports: + - "9042:9042" + healthcheck: + test: [ "CMD", "cqlsh", "-u cassandra", "-p cassandra"] + interval: 5s + timeout: 10s + retries: 6 + # pg 9.2 has built in healthcheck + pg: + container_name: nr_node_postgres + image: postgres:9.2 + ports: + - "5432:5432" + pg_prisma: + container_name: nr_node_postgres_prisma + image: postgres:15 + ports: + - "5434:5434" + environment: + PGPORT: 5434 + POSTGRES_PASSWORD: postgres + healthcheck: + test: ["CMD", "pg_isready"] + interval: 1s + timeout: 10s + retries: 30 + rmq: + container_name: nr_node_rabbit + image: rabbitmq:3 + ports: + - "5672:5672" diff --git a/package.json b/package.json index 4e7d9207b9..acc9cb3349 100644 --- a/package.json +++ b/package.json @@ -153,7 +153,7 @@ "lint:lockfile": "lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https --validate-integrity", "public-docs": "jsdoc -c ./jsdoc-conf.json --tutorials examples/shim api.js lib/shim/ lib/transaction/handle.js && cp examples/shim/*.png out/", "publish-docs": "./bin/publish-docs.sh", - "services": "./bin/docker-services.sh", + "services": "docker compose up -d --wait", "smoke": "npm run ssl && time tap test/smoke/**/**/*.tap.js --timeout=180 --no-coverage", "ssl": "./bin/ssl.sh", "sub-install": "node test/bin/install_sub_deps", diff --git a/test/lib/params.js b/test/lib/params.js index 2d81b7b5cd..d3fc1cb6fb 100644 --- a/test/lib/params.js +++ b/test/lib/params.js @@ -26,7 +26,7 @@ module.exports = { cassandra_host: process.env.NR_NODE_TEST_CASSANDRA_HOST || 'localhost', cassandra_port: process.env.NR_NODE_TEST_CASSANDRA_PORT || 9042, - elastic_host: process.env.NR_NODE_TEST_ELASTIC_HOST || 'localhost', + elastic_host: process.env.NR_NODE_TEST_ELASTIC_HOST || '127.0.0.1', elastic_port: process.env.NR_NODE_TEST_ELASTIC_PORT || 9200, postgres_host: process.env.NR_NODE_TEST_POSTGRES_HOST || 'localhost', diff --git a/test/versioned/elastic/elasticsearch.tap.js b/test/versioned/elastic/elasticsearch.tap.js index 55817f4fec..c6d430f1e4 100644 --- a/test/versioned/elastic/elasticsearch.tap.js +++ b/test/versioned/elastic/elasticsearch.tap.js @@ -55,11 +55,12 @@ test('Elasticsearch instrumentation', (t) => { console.log('before ping') await client.ping() console.log('after ping') - console.log('before first idx') + console.log('before first idx', DB_INDEX) await client.indices.create({ index: DB_INDEX }) - console.log('after first idx') - console.log('before 2nd idx') - // await client.indices.create({ index: DB_INDEX_2 }) + console.log('after first idx', DB_INDEX) + console.log('before 2nd idx', DB_INDEX_2) + await client.indices.create({ index: DB_INDEX_2 }) + console.log('after 2nd idx', DB_INDEX_2) }) t.afterEach(() => { diff --git a/test/versioned/elastic/package.json b/test/versioned/elastic/package.json index e8faf824c6..5549fc3093 100644 --- a/test/versioned/elastic/package.json +++ b/test/versioned/elastic/package.json @@ -11,7 +11,7 @@ "node": ">=16" }, "dependencies": { - "@elastic/elasticsearch": ">=8.10.0" + "@elastic/elasticsearch": ">=8.0.0" }, "files": [ "elasticsearch.tap.js" diff --git a/third_party_manifest.json b/third_party_manifest.json index 98702a5228..b62fbbcda6 100644 --- a/third_party_manifest.json +++ b/third_party_manifest.json @@ -1,5 +1,5 @@ { - "lastUpdated": "Tue Oct 03 2023 11:10:41 GMT-0400 (Eastern Daylight Time)", + "lastUpdated": "Fri Oct 06 2023 17:25:04 GMT-0400 (Eastern Daylight Time)", "projectName": "New Relic Node Agent", "projectUrl": "https://github.com/newrelic/node-newrelic", "includeOptDeps": true,