Skip to content

Commit 7d7d919

Browse files
committed
chore: remove unused test utils for docker
1 parent 813a7c7 commit 7d7d919

File tree

6 files changed

+2
-73
lines changed

6 files changed

+2
-73
lines changed

packages/contrib-test-utils/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ export type { TestSpan, RunTestFixtureOptions } from './test-fixtures';
3434
export {
3535
assertPropagation,
3636
assertSpan,
37-
cleanUpDocker,
3837
getPackageVersion,
3938
initMeterProvider,
40-
startDocker,
4139
TestMetricReader,
4240
} from './test-utils';
4341
export type { TimedEvent } from './test-utils';

packages/contrib-test-utils/src/test-utils.ts

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import * as childProcess from 'child_process';
1817
import {
1918
HrTime,
2019
Span,
@@ -33,62 +32,6 @@ import * as path from 'path';
3332
import * as fs from 'fs';
3433
import { InstrumentationBase } from '@opentelemetry/instrumentation';
3534

36-
const dockerRunCmds = {
37-
cassandra:
38-
'docker run --rm -d --name otel-cassandra -p 9042:9042 bitnami/cassandra:3',
39-
memcached:
40-
'docker run --rm -d --name otel-memcached -p 11211:11211 memcached:1.6.9-alpine',
41-
mssql:
42-
'docker run --rm -d --name otel-mssql -p 1433:1433 -e MSSQL_SA_PASSWORD=mssql_passw0rd -e ACCEPT_EULA=Y mcr.microsoft.com/mssql/server:2022-latest',
43-
mysql:
44-
'docker run --rm -d --name otel-mysql -p 33306:3306 -e MYSQL_ROOT_PASSWORD=rootpw -e MYSQL_DATABASE=test_db -e MYSQL_USER=otel -e MYSQL_PASSWORD=secret mysql:5.7 --log_output=TABLE --general_log=ON',
45-
oracledb:
46-
'docker run --rm -d --name otel-oracledb -p 1521:1521 -e ORACLE_PASSWORD=oracle -e APP_USER=otel -e APP_USER_PASSWORD=secret gvenzl/oracle-free:slim',
47-
postgres:
48-
'docker run --rm -d --name otel-postgres -p 54320:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=otel_pg_database postgres:16-alpine',
49-
redis: 'docker run --rm -d --name otel-redis -p 63790:6379 redis:alpine',
50-
};
51-
52-
export function startDocker(db: keyof typeof dockerRunCmds) {
53-
const tasks = [run(dockerRunCmds[db])];
54-
55-
for (let i = 0; i < tasks.length; i++) {
56-
const task = tasks[i];
57-
if (task && task.code !== 0) {
58-
console.error('Failed to start container!');
59-
console.error(task.output);
60-
return false;
61-
}
62-
}
63-
return true;
64-
}
65-
66-
export function cleanUpDocker(db: keyof typeof dockerRunCmds) {
67-
run(`docker stop otel-${db}`);
68-
}
69-
70-
function run(cmd: string) {
71-
try {
72-
const proc = childProcess.spawnSync(cmd, {
73-
shell: true,
74-
});
75-
const output = Buffer.concat(
76-
proc.output.filter(c => c) as Buffer[]
77-
).toString('utf8');
78-
if (proc.status !== 0) {
79-
console.error('Failed run command:', cmd);
80-
console.error(output);
81-
}
82-
return {
83-
code: proc.status,
84-
output,
85-
};
86-
} catch (e) {
87-
console.log(e);
88-
return;
89-
}
90-
}
91-
9235
export const assertSpan = (
9336
span: ReadableSpan,
9437
kind: SpanKind,

packages/instrumentation-cassandra-driver/test/cassandra-driver.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ context.setGlobalContextManager(new AsyncLocalStorageContextManager());
5757

5858
const testCassandra = process.env.RUN_CASSANDRA_TESTS;
5959
const shouldTest = testCassandra;
60-
const cassandraTimeoutMs = 60000;
6160
const cassandraContactPoint = process.env.CASSANDRA_HOST
6261
? '127.0.0.1'
6362
: 'cassandra';

packages/instrumentation-memcached/test/index.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
} from '@opentelemetry/api';
2424
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
2525
import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';
26-
import * as testUtils from '@opentelemetry/contrib-test-utils';
2726
import {
2827
InMemorySpanExporter,
2928
SimpleSpanProcessor,

packages/instrumentation-pg/test/pg.test.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ describe('pg', () => {
123123
});
124124
const tracer = provider.getTracer('external');
125125

126-
const testPostgres = process.env.RUN_POSTGRES_TESTS; // For CI: assumes local postgres db is already available
127-
const testPostgresLocally = process.env.RUN_POSTGRES_TESTS_LOCAL; // For local: spins up local postgres db via docker
128-
const shouldTest = testPostgres || testPostgresLocally; // Skips these tests if false (default)
126+
const testPostgres = process.env.RUN_POSTGRES_TESTS;
127+
const shouldTest = testPostgres; // Skips these tests if false (default)
129128

130129
function getExecutedQueries() {
131130
return (client as any).queryQueue.push.args.flat() as (pg.Query & {
@@ -145,10 +144,6 @@ describe('pg', () => {
145144
skip();
146145
}
147146

148-
if (testPostgresLocally) {
149-
testUtils.startDocker('postgres');
150-
}
151-
152147
instrumentation = new PgInstrumentation();
153148

154149
contextManager = new AsyncLocalStorageContextManager().enable();
@@ -162,10 +157,6 @@ describe('pg', () => {
162157
});
163158

164159
after(async () => {
165-
if (testPostgresLocally) {
166-
testUtils.cleanUpDocker('postgres');
167-
}
168-
169160
await client.end();
170161
});
171162

packages/instrumentation-redis/test/v4/redis.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import type { MultiErrorReply } from '../../src/v4/internal-types';
2424
import * as assert from 'assert';
2525

2626
import { redisTestConfig, redisTestUrl, shouldTest } from './utils';
27-
import * as testUtils from '@opentelemetry/contrib-test-utils';
2827

2928
const instrumentation = registerInstrumentationTesting(
3029
new RedisInstrumentation()

0 commit comments

Comments
 (0)