-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8c8509
commit edcdb4a
Showing
4 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "@opentelemetry/test-utils", | ||
"version": "0.31.0", | ||
"description": "Test utilities.", | ||
"main": "build/src/index.js", | ||
"scripts": { | ||
"precompile": "tsc --version", | ||
"compile": "tsc -p .", | ||
"prepare": "npm run compile" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/open-telemetry/opentelemetry-js.git" | ||
}, | ||
"keywords": [ | ||
"\"opentelemetry\"", | ||
"\"test-utils\"" | ||
], | ||
"author": "OpenTelemetry Authors", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/open-telemetry/opentelemetry-js/issues" | ||
}, | ||
"homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", | ||
"devDependencies": { | ||
"gts": "^1.1.2", | ||
"ts-node": "^8.5.4", | ||
"tslint-consistent-codestyle": "^1.16.0", | ||
"tslint-microsoft-contrib": "^6.2.0", | ||
"typescript": "3.7.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/*! | ||
* Copyright 2019, OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import * as childProcess from 'child_process'; | ||
export function startDocker(db: 'redis' | 'mysql' | 'postgres') { | ||
let dockerRunCmd; | ||
switch (db) { | ||
case 'redis': | ||
dockerRunCmd = `docker run -d -p 63790:6379 --name ot${db} ${db}:alpine`; | ||
break; | ||
|
||
case 'mysql': | ||
dockerRunCmd = `docker run --rm -d -e MYSQL_ROOT_PASSWORD=rootpw -e MYSQL_DATABASE=test_db -e MYSQL_USER=otel -e MYSQL_PASSWORD=secret -p 33306:3306 --name ot${db} circleci/${db}:5.7`; | ||
break; | ||
|
||
case 'postgres': | ||
dockerRunCmd = `docker run -d -p 54320:5432 --name ot${db} ${db}:alpine`; | ||
break; | ||
} | ||
|
||
const tasks = [run(dockerRunCmd)]; | ||
|
||
for (let i = 0; i < tasks.length; i++) { | ||
const task = tasks[i]; | ||
if (task && task.code !== 0) { | ||
console.error('Failed to start container!'); | ||
console.error(task.output); | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
export function cleanUpDocker(db: 'redis' | 'mysql' | 'postgres') { | ||
run(`docker stop ot${db}`); | ||
run(`docker rm ot${db}`); | ||
} | ||
|
||
function run(cmd: string) { | ||
try { | ||
const proc = childProcess.spawnSync(cmd, { | ||
shell: true, | ||
}); | ||
return { | ||
code: proc.status, | ||
output: proc.output | ||
.map(v => String.fromCharCode.apply(null, v as any)) | ||
.join(''), | ||
}; | ||
} catch (e) { | ||
console.log(e); | ||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../tsconfig.base", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"outDir": "build" | ||
}, | ||
"include": [ | ||
"*.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"], | ||
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"] | ||
} |