Skip to content

Commit

Permalink
[teraslice, scripts] Ci test error logging and potential fixes (#3854)
Browse files Browse the repository at this point in the history
This PR makes the following changes:
- Adds the `--verbose` flag to the root package.json `build` script and
removes `--silent` from `YARN_SETUP_ARGS`. This will hopefully reveal
why the script fails occasionally. ref: #3849
- Replace unmaintained `porty` library with `get-port` library.
- Within the teraslice package, many tests use `findPort()` to get a
random port to start a server on. The implementation did not actually
return a random port and made conflicts more likely. Update `findPort()`
to use `get-port`, increase the port range, and get a truly random port
in that range. ref: #3848
- When starting services, log all TCP ports just before calling `docker
run`. This should give us more information about why the `docker run`
commands occasionally fail with a `port already in use` error. ref:
#3848
  • Loading branch information
busma13 authored Dec 16, 2024
1 parent ee90e71 commit d75756c
Show file tree
Hide file tree
Showing 30 changed files with 149 additions and 138 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Install and build packages
run: yarn setup
env:
YARN_SETUP_ARGS: "--prod=false --silent"
YARN_SETUP_ARGS: "--prod=false"

check-docker-limit-before:
uses: terascope/workflows/.github/workflows/check-docker-limit.yml@f5e098fa861fe7744fa61842e82124f806364be9
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
- name: Install and build packages
run: yarn setup
env:
YARN_SETUP_ARGS: "--prod=false --silent"
YARN_SETUP_ARGS: "--prod=false"

- name: Test
run: yarn --silent test -- --suite unit --
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
- name: Install and build packages
run: yarn setup
env:
YARN_SETUP_ARGS: "--prod=false --silent"
YARN_SETUP_ARGS: "--prod=false"

- name: Create Docker Image List
run: |
Expand Down Expand Up @@ -154,7 +154,7 @@ jobs:
- name: Install and build packages
run: yarn setup
env:
YARN_SETUP_ARGS: "--prod=false --silent"
YARN_SETUP_ARGS: "--prod=false"

- name: Create Docker Image List
run: |
Expand Down Expand Up @@ -190,7 +190,7 @@ jobs:
- name: Install and build packages
run: yarn setup
env:
YARN_SETUP_ARGS: "--prod=false --silent"
YARN_SETUP_ARGS: "--prod=false"

- name: Lint codebase
run: yarn lint
Expand Down Expand Up @@ -227,7 +227,7 @@ jobs:
- name: Install and build packages
run: yarn setup
env:
YARN_SETUP_ARGS: "--prod=false --silent"
YARN_SETUP_ARGS: "--prod=false"

- name: Create Docker Image List
run: |
Expand Down Expand Up @@ -274,7 +274,7 @@ jobs:
- name: Install and build packages
run: yarn setup
env:
YARN_SETUP_ARGS: "--prod=false --silent"
YARN_SETUP_ARGS: "--prod=false"

- name: Create Docker Image List
run: |
Expand Down Expand Up @@ -324,7 +324,7 @@ jobs:
- name: Install and build packages
run: yarn setup
env:
YARN_SETUP_ARGS: "--prod=false --silent"
YARN_SETUP_ARGS: "--prod=false"

- name: Create Docker Image List
run: |
Expand Down Expand Up @@ -379,7 +379,7 @@ jobs:
- name: Install and build packages
run: yarn setup
env:
YARN_SETUP_ARGS: "--prod=false --silent"
YARN_SETUP_ARGS: "--prod=false"

- name: Create Docker Image List
run: |
Expand Down Expand Up @@ -434,7 +434,7 @@ jobs:
- name: Install and build packages
run: yarn setup
env:
YARN_SETUP_ARGS: "--prod=false --silent"
YARN_SETUP_ARGS: "--prod=false"

- name: Create Docker Image List
run: |
Expand Down Expand Up @@ -484,7 +484,7 @@ jobs:
- name: Install and build packages
run: yarn setup
env:
YARN_SETUP_ARGS: "--prod=false --silent"
YARN_SETUP_ARGS: "--prod=false"

- name: Create Docker Image List
run: |
Expand Down
2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"devDependencies": {
"@terascope/types": "~1.3.1",
"bunyan": "~1.8.15",
"elasticsearch-store": "~1.5.0",
"elasticsearch-store": "~1.6.0",
"fs-extra": "~11.2.0",
"ms": "~2.1.3",
"nanoid": "~5.0.9",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"scripts": {
"prebuild": "./packages/xlucene-parser/scripts/generate-engine.js",
"build": "tsc --build && yarn workspace teraslice-cli build",
"build": "tsc --build --verbose && yarn workspace teraslice-cli build --verbose",
"build:cleanup": "./scripts/build-cleanup.sh",
"build:doctor": "./scripts/build-doctor.sh",
"build:fix": "echo '[DEPRECATED], use yarn run build:doctor instead'",
Expand Down
8 changes: 4 additions & 4 deletions packages/data-mate/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/data-mate",
"displayName": "Data-Mate",
"version": "1.5.0",
"version": "1.6.0",
"description": "Library of data validations/transformations",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/data-mate#readme",
"repository": {
Expand Down Expand Up @@ -30,9 +30,9 @@
"test:watch": "ts-scripts test --watch . --"
},
"dependencies": {
"@terascope/data-types": "~1.5.0",
"@terascope/data-types": "~1.6.0",
"@terascope/types": "~1.3.1",
"@terascope/utils": "~1.5.0",
"@terascope/utils": "~1.6.0",
"@types/validator": "~13.12.2",
"awesome-phonenumber": "~7.2.0",
"date-fns": "~4.1.0",
Expand All @@ -45,7 +45,7 @@
"uuid": "~11.0.3",
"valid-url": "~1.0.9",
"validator": "~13.12.0",
"xlucene-parser": "~1.5.0"
"xlucene-parser": "~1.6.0"
},
"devDependencies": {
"@types/ip6addr": "~0.2.6",
Expand Down
4 changes: 2 additions & 2 deletions packages/data-types/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/data-types",
"displayName": "Data Types",
"version": "1.5.0",
"version": "1.6.0",
"description": "A library for defining the data structures and mapping",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/data-types#readme",
"bugs": {
Expand All @@ -28,7 +28,7 @@
},
"dependencies": {
"@terascope/types": "~1.3.1",
"@terascope/utils": "~1.5.0",
"@terascope/utils": "~1.6.0",
"graphql": "~16.9.0",
"yargs": "~17.7.2"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/elasticsearch-api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/elasticsearch-api",
"displayName": "Elasticsearch API",
"version": "4.5.0",
"version": "4.6.0",
"description": "Elasticsearch client api used across multiple services, handles retries and exponential backoff",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/elasticsearch-api#readme",
"bugs": {
Expand All @@ -25,15 +25,15 @@
},
"dependencies": {
"@terascope/types": "~1.3.1",
"@terascope/utils": "~1.5.0",
"@terascope/utils": "~1.6.0",
"bluebird": "~3.7.2",
"setimmediate": "~1.0.5"
},
"devDependencies": {
"@opensearch-project/opensearch": "~1.2.0",
"@types/elasticsearch": "~5.0.43",
"elasticsearch": "~15.4.1",
"elasticsearch-store": "~1.5.0",
"elasticsearch-store": "~1.6.0",
"elasticsearch6": "npm:@elastic/elasticsearch@~6.8.0",
"elasticsearch7": "npm:@elastic/elasticsearch@~7.17.0",
"elasticsearch8": "npm:@elastic/elasticsearch@~8.15.0"
Expand Down
10 changes: 5 additions & 5 deletions packages/elasticsearch-store/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "elasticsearch-store",
"displayName": "Elasticsearch Store",
"version": "1.5.0",
"version": "1.6.0",
"description": "An API for managing an elasticsearch index, with versioning and migration support.",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/elasticsearch-store#readme",
"bugs": {
Expand Down Expand Up @@ -30,10 +30,10 @@
"test:watch": "ts-scripts test --watch . --"
},
"dependencies": {
"@terascope/data-mate": "~1.5.0",
"@terascope/data-types": "~1.5.0",
"@terascope/data-mate": "~1.6.0",
"@terascope/data-types": "~1.6.0",
"@terascope/types": "~1.3.1",
"@terascope/utils": "~1.5.0",
"@terascope/utils": "~1.6.0",
"ajv": "~8.17.1",
"ajv-formats": "~3.0.1",
"elasticsearch6": "npm:@elastic/elasticsearch@~6.8.0",
Expand All @@ -43,7 +43,7 @@
"opensearch2": "npm:@opensearch-project/opensearch@~2.12.0",
"setimmediate": "~1.0.5",
"uuid": "~11.0.3",
"xlucene-translator": "~1.5.0"
"xlucene-translator": "~1.6.0"
},
"devDependencies": {
"@types/uuid": "~10.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/job-components/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/job-components",
"displayName": "Job Components",
"version": "1.7.0",
"version": "1.8.0",
"description": "A teraslice library for validating jobs schemas, registering apis, and defining and running new Job APIs",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/job-components#readme",
"bugs": {
Expand Down Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"@terascope/types": "~1.3.1",
"@terascope/utils": "~1.5.0",
"@terascope/utils": "~1.6.0",
"convict": "~6.2.4",
"convict-format-with-moment": "~6.2.0",
"convict-format-with-validator": "~6.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/scripts",
"displayName": "Scripts",
"version": "1.6.0",
"version": "1.7.0",
"description": "A collection of terascope monorepo scripts",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/scripts#readme",
"bugs": {
Expand Down Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"@kubernetes/client-node": "~0.22.3",
"@terascope/utils": "~1.5.0",
"@terascope/utils": "~1.6.0",
"codecov": "~3.8.3",
"execa": "~9.5.2",
"fs-extra": "~11.2.0",
Expand Down
20 changes: 20 additions & 0 deletions packages/scripts/src/helpers/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,3 +767,23 @@ async function showAssets(tsPort: string) {
return err;
}
}

export async function logTCPPorts() {
try {
let command: string;
let args: string[];

if (process.platform === 'darwin') {
command = 'netstat';
args = ['-an', '-f', 'inet', '-p', 'tcp'];
} else {
command = 'ss';
args = ['-tan4'];
}

const { stdout } = await execa(command, args, { shell: true, reject: false });
signale.info('TCP Ports:\n', stdout);
} catch (err) {
signale.error('Execa command failed trying to log ports: ', err);
}
}
5 changes: 4 additions & 1 deletion packages/scripts/src/helpers/test-runner/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { getServicesForSuite, getRootDir } from '../misc.js';
import {
dockerRun, DockerRunOptions, getContainerInfo,
dockerStop, k8sStartService, k8sStopService,
loadThenDeleteImageFromCache, dockerPull
loadThenDeleteImageFromCache, dockerPull, logTCPPorts
} from '../scripts.js';
import { Kind } from '../kind.js';
import { TestOptions } from './interfaces.js';
Expand Down Expand Up @@ -844,12 +844,15 @@ async function startService(options: TestOptions, service: Service): Promise<()
options.skipImageDeletion
);
await k8sStopService(service);
await logTCPPorts();
await k8sStartService(service, services[service].image, version, kind);
return () => { };
}

await stopService(service);

await logTCPPorts();

const fn = await dockerRun(
services[service],
version,
Expand Down
6 changes: 3 additions & 3 deletions packages/terafoundation/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "terafoundation",
"displayName": "Terafoundation",
"version": "1.7.0",
"version": "1.8.0",
"description": "A Clustering and Foundation tool for Terascope Tools",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/terafoundation#readme",
"bugs": {
Expand Down Expand Up @@ -30,14 +30,14 @@
"dependencies": {
"@terascope/file-asset-apis": "~1.0.3",
"@terascope/types": "~1.3.1",
"@terascope/utils": "~1.5.0",
"@terascope/utils": "~1.6.0",
"bluebird": "~3.7.2",
"bunyan": "~1.8.15",
"convict": "~6.2.4",
"convict-format-with-moment": "~6.2.0",
"convict-format-with-validator": "~6.2.0",
"elasticsearch": "~15.4.1",
"elasticsearch-store": "~1.5.0",
"elasticsearch-store": "~1.6.0",
"express": "~4.21.2",
"js-yaml": "~4.1.0",
"nanoid": "~5.0.9",
Expand Down
4 changes: 2 additions & 2 deletions packages/teraslice-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"devDependencies": {
"@terascope/fetch-github-release": "~1.0.0",
"@terascope/types": "~1.3.1",
"@terascope/utils": "~1.5.0",
"@terascope/utils": "~1.6.0",
"@types/decompress": "~4.2.7",
"@types/diff": "~6.0.0",
"@types/ejs": "~3.1.5",
Expand All @@ -67,7 +67,7 @@
"pretty-bytes": "~6.1.1",
"prompts": "~2.4.2",
"signale": "~1.4.0",
"teraslice-client-js": "~1.5.0",
"teraslice-client-js": "~1.6.0",
"tmp": "~0.2.0",
"tty-table": "~4.2.3",
"yargs": "~17.7.2"
Expand Down
4 changes: 2 additions & 2 deletions packages/teraslice-client-js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "teraslice-client-js",
"displayName": "Teraslice Client (JavaScript)",
"version": "1.5.0",
"version": "1.6.0",
"description": "A Node.js client for teraslice jobs, assets, and cluster references.",
"keywords": [
"elasticsearch",
Expand Down Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"@terascope/types": "~1.3.1",
"@terascope/utils": "~1.5.0",
"@terascope/utils": "~1.6.0",
"auto-bind": "~5.0.1",
"got": "~13.0.0"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/teraslice-messaging/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/teraslice-messaging",
"displayName": "Teraslice Messaging",
"version": "1.8.0",
"version": "1.9.0",
"description": "An internal teraslice messaging library using socket.io",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/teraslice-messaging#readme",
"bugs": {
Expand Down Expand Up @@ -36,11 +36,11 @@
},
"dependencies": {
"@terascope/types": "~1.3.1",
"@terascope/utils": "~1.5.0",
"@terascope/utils": "~1.6.0",
"get-port": "~7.1.0",
"ms": "~2.1.3",
"nanoid": "~5.0.9",
"p-event": "~6.0.1",
"porty": "~3.1.1",
"socket.io": "~1.7.4",
"socket.io-client": "~1.7.4"
},
Expand Down
Loading

0 comments on commit d75756c

Please sign in to comment.