Skip to content

Commit

Permalink
Add Cloud Healthcare API to Kokoro testing pipeline (#1862)
Browse files Browse the repository at this point in the history
  • Loading branch information
noerog authored Aug 17, 2020
1 parent 39e0177 commit 0e65e14
Show file tree
Hide file tree
Showing 15 changed files with 135 additions and 23 deletions.
29 changes: 29 additions & 0 deletions .kokoro/healthcare/common.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Download trampoline resources. These will be in ${KOKORO_GFILE_DIR}
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Download secrets from Cloud Storage.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/nodejs-docs-samples"

# All builds use the trampoline script to run in docker.
build_file: "nodejs-docs-samples/.kokoro/trampoline.sh"

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user"
}

# Tell the trampoline which build file to use.
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/nodejs-docs-samples/.kokoro/build.sh"
}

# Export XUnit test results for further analysis
action {
define_artifacts {
regex: "**/*sponge_log.xml"
}
}
7 changes: 7 additions & 0 deletions .kokoro/healthcare/datasets.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Set the folder in which the tests are run
env_vars: {
key: "PROJECT"
value: "healthcare/datasets"
}
7 changes: 7 additions & 0 deletions .kokoro/healthcare/dicom.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Set the folder in which the tests are run
env_vars: {
key: "PROJECT"
value: "healthcare/dicom"
}
7 changes: 7 additions & 0 deletions .kokoro/healthcare/fhir.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Set the folder in which the tests are run
env_vars: {
key: "PROJECT"
value: "healthcare/fhir"
}
7 changes: 7 additions & 0 deletions .kokoro/healthcare/hl7v2.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Set the folder in which the tests are run
env_vars: {
key: "PROJECT"
value: "healthcare/hl7v2"
}
30 changes: 15 additions & 15 deletions healthcare/datasets/system-test/datasets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ it('should get a dataset', () => {
assert.ok(output.includes('name'));
});

it('should create and get a dataset IAM policy', () => {
const localMember = 'group:dpebot@google.com';
const localRole = 'roles/viewer';

let output = execSync(
`node setDatasetIamPolicy.js ${projectId} ${cloudRegion} ${datasetId} ${localMember} ${localRole}`,
);
assert.ok(output.includes, 'ETAG');

output = execSync(
`node getDatasetIamPolicy.js ${projectId} ${cloudRegion} ${datasetId}`
);
assert.ok(output.includes('dpebot'));
});

it('should patch a dataset', () => {
const timeZone = 'GMT';
const output = execSync(
Expand All @@ -83,21 +98,6 @@ it('should de-identify data in a dataset and write to a new dataset', () => {
);
});

it('should create and get a dataset IAM policy', () => {
const localMember = 'group:dpebot@google.com';
const localRole = 'roles/viewer';

let output = execSync(
`node setDatasetIamPolicy.js ${projectId} ${cloudRegion} ${datasetId} ${localMember} ${localRole}`,
);
assert.ok(output.includes, 'ETAG');

output = execSync(
`node getDatasetIamPolicy.js ${projectId} ${cloudRegion} ${datasetId}`
);
assert.ok(output.includes('dpebot'));
});

it('should delete a dataset', () => {
const output = execSync(
`node deleteDataset.js ${projectId} ${cloudRegion} ${datasetId}`,
Expand Down
10 changes: 9 additions & 1 deletion healthcare/dicom/system-test/dicom_stores.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,22 @@ const cwdDatasets = path.join(__dirname, '../../datasets');
const cwd = path.join(__dirname, '..');

const datasetId = `nodejs-docs-samples-test-${uuid.v4()}`.replace(/-/gi, '_');
const dicomStoreId = `nodejs-docs-samples-test-fhir-store${uuid.v4()}`.replace(
const dicomStoreId = `nodejs-docs-samples-test-dicom-store${uuid.v4()}`.replace(
/-/gi,
'_'
);
const dcmFileName = 'IM-0002-0001-JPEG-BASELINE.dcm';

const resourceFile = `resources/${dcmFileName}`;
const gcsUri = `${bucketName}/${dcmFileName}`;
const installDeps = 'npm install';

// Run npm install on datasets directory because modalities
// require bootstrapping datasets, and Kokoro needs to know
// to install dependencies from the datasets directory.
assert.ok(
execSync(installDeps, {cwd: `${cwdDatasets}`, shell: true})
);

before(async () => {
assert(
Expand Down
11 changes: 10 additions & 1 deletion healthcare/dicom/system-test/dicomweb.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ const studyUid = '1.2.840.113619.2.176.3596.3364818.7819.1259708454.105';
const seriesUid = '1.2.840.113619.2.176.3596.3364818.7819.1259708454.108';
const instanceUid = '1.2.840.113619.2.176.3596.3364818.7271.1259708501.876';

const installDeps = 'npm install';

// Run npm install on datasets directory because modalities
// require bootstrapping datasets, and Kokoro needs to know
// to install dependencies from the datasets directory.
assert.ok(
execSync(installDeps, {cwd: `${cwdDatasets}`, shell: true})
);

before(() => {
assert(
process.env.GOOGLE_CLOUD_PROJECT,
Expand All @@ -64,7 +73,7 @@ after(() => {
`node deleteDicomStore.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId}`,
{cwd}
);
execSync(`node deleteDataset.js ${datasetId}`, {cwd: cwdDatasets});
execSync(`node deleteDataset.js ${projectId} ${cloudRegion} ${datasetId}`, {cwd: cwdDatasets});
} catch (err) {} // Ignore error
});

Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/exportFhirResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const main = (
{name: operationName}
);

if (typeof operationStatus.data.response.resourceCount !== 'undefined') {
if (typeof operationStatus.data.metadata.counter !== 'undefined') {
console.log('Exported FHIR resources successfully');
} else {
console.log('Export failed');
Expand Down
8 changes: 5 additions & 3 deletions healthcare/fhir/importFhirResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const main = (
const request = {
name,
resource: {
contentStructure: 'BUNDLE',
contentStructure: 'RESOURCE',
gcsSource: {
uri: `gs://${gcsUri}`,
},
Expand All @@ -66,9 +66,11 @@ const main = (
operationRequest
);

if (typeof operationStatus.data.error === 'undefined') {
const success = operationStatus.data.metadata.counter.success;

if (typeof success !== 'undefined') {
console.log(
`Import FHIR resources succeeded. ${operationStatus.data.response.inputSize} resources imported`
`Import FHIR resources succeeded. ${success} resources imported`
);
} else {
console.log(
Expand Down
5 changes: 3 additions & 2 deletions healthcare/fhir/resources/fhir_data.ndjson

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions healthcare/fhir/system-test/fhir_resources.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ const resourceType = 'Patient';
const version = 'STU3';
let resourceId;

const installDeps = 'npm install';

// Run npm install on datasets directory because modalities
// require bootstrapping datasets, and Kokoro needs to know
// to install dependencies from the datasets directory.
assert.ok(
execSync(installDeps, {cwd: `${cwdDatasets}`, shell: true})
);

before(() => {
assert(
process.env.GOOGLE_CLOUD_PROJECT,
Expand Down
10 changes: 10 additions & 0 deletions healthcare/fhir/system-test/fhir_stores.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ const fhirFileName = 'fhir_data.ndjson';

const fhirResourceFile = `resources/${fhirFileName}`;
const gcsUri = `${bucketName}/${fhirFileName}`;
const installDeps = 'npm install';

// Run npm install on datasets directory because modalities
// require bootstrapping datasets, and Kokoro needs to know
// to install dependencies from the datasets directory.
assert.ok(
execSync(installDeps, {cwd: `${cwdDatasets}`, shell: true})
);

before(async () => {
assert(
Expand All @@ -56,6 +64,8 @@ before(async () => {
// Create a Cloud Storage bucket to be used for testing.
await storage.createBucket(bucketName);
console.log(`Bucket ${bucketName} created.`);
// Upload the FHIR resource file so that there's something to
// use for the importFhirResources test.
await storage.bucket(bucketName).upload(fhirResourceFile);

// Create a Pub/Sub topic to be used for testing.
Expand Down
8 changes: 8 additions & 0 deletions healthcare/hl7v2/system-test/hl7v2_messages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ const messageFile = 'resources/hl7v2-sample.json';
const messageId = '2yqbdhYHlk_ucSmWkcKOVm_N0p0OpBXgIlVG18rB-cw=';
const labelKey = 'my-key';
const labelValue = 'my-value';
const installDeps = 'npm install';

// Run npm install on datasets directory because modalities
// require bootstrapping datasets, and Kokoro needs to know
// to install dependencies from the datasets directory.
assert.ok(
execSync(installDeps, {cwd: `${cwdDatasets}`, shell: true})
);

before(() => {
assert(
Expand Down
8 changes: 8 additions & 0 deletions healthcare/hl7v2/system-test/hl7v2_stores.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ const hl7v2StoreId = `nodejs-docs-samples-test-hl7v2-store${uuid.v4()}`.replace(
'_'
);
const topicName = `nodejs-healthcare-test-topic-${uuid.v4()}`;
const installDeps = 'npm install';

// Run npm install on datasets directory because modalities
// require bootstrapping datasets, and Kokoro needs to know
// to install dependencies from the datasets directory.
assert.ok(
execSync(installDeps, {cwd: `${cwdDatasets}`, shell: true})
);

before(async () => {
assert(
Expand Down

0 comments on commit 0e65e14

Please sign in to comment.