From 9631b11c1fb5c987064a77e066ec3a811f17c2c3 Mon Sep 17 00:00:00 2001 From: sofisl <55454395+sofisl@users.noreply.github.com> Date: Mon, 3 Feb 2020 06:11:04 -0800 Subject: [PATCH] chore: replace repo tools tools.runAsync function with execSync (#1597) --- auth/system-test/auth.test.js | 10 +- .../system-test/endpoints.test.js | 20 +-- .../datasets/system-test/datasets.test.js | 36 +++--- .../dicom/system-test/dicom_stores.test.js | 40 +++--- healthcare/dicom/system-test/dicomweb.test.js | 42 +++---- .../fhir/system-test/fhir_resources.test.js | 60 ++++----- .../fhir/system-test/fhir_stores.test.js | 40 +++--- .../hl7v2/system-test/hl7v2_messages.test.js | 38 +++--- .../hl7v2/system-test/hl7v2_stores.test.js | 32 ++--- .../system-test/cloudiot_http_example.test.js | 45 +++---- iot/manager/system-test/manager.test.js | 115 +++++++++--------- .../system-test/cloudiot_mqtt_example.test.js | 91 +++++++------- jobs/v2/system-test/quickstart.test.js | 6 +- .../system-test/auto-complete-sample.test.js | 6 +- .../system-test/basic-company-sample.test.js | 6 +- jobs/v3/system-test/basic-job-sample.test.js | 6 +- .../batchdelete-jobs-sample.test.js | 6 +- .../system-test/commute-search-sample.test.js | 6 +- .../custom-attribute-sample.test.js | 6 +- .../email-alert-search-sample.test.js | 6 +- .../featured-job-search-sample.test.js | 6 +- .../system-test/general-search-sample.test.js | 6 +- jobs/v3/system-test/histogram-sample.test.js | 6 +- .../location-search-sample.test.js | 6 +- jobs/v3/system-test/quickstart.test.js | 6 +- .../system-test/metrics-quickstart.test.js | 6 +- 26 files changed, 327 insertions(+), 326 deletions(-) diff --git a/auth/system-test/auth.test.js b/auth/system-test/auth.test.js index b94359f46b..9b313cef0e 100644 --- a/auth/system-test/auth.test.js +++ b/auth/system-test/auth.test.js @@ -16,7 +16,7 @@ const path = require('path'); const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {execSync} = require('child_process'); const cwd = path.join(__dirname, '..'); const cmd = 'node auth.js'; @@ -34,16 +34,16 @@ before(() => { ); }); -it('should load credentials implicitly', async () => { - const output = await tools.runAsync(`${cmd} auth-cloud-implicit`, cwd); +it('should load credentials implicitly', () => { + const output = execSync(`${cmd} auth-cloud-implicit`, cwd); assert.strictEqual(output.includes(BUCKET_NAME), true); }); -it('should load credentials explicitly', async () => { +it('should load credentials explicitly', () => { const project = process.env.GCLOUD_PROJECT; const keyfile = process.env.GOOGLE_APPLICATION_CREDENTIALS; console.log(`${cmd} auth-cloud-explicit -p ${project} -k ${keyfile}`); - const output = await tools.runAsync( + const output = execSync( `${cmd} auth-cloud-explicit -p ${project} -k ${keyfile}`, cwd ); diff --git a/endpoints/getting-started-grpc/system-test/endpoints.test.js b/endpoints/getting-started-grpc/system-test/endpoints.test.js index 2cac2f9468..31ddbaedd7 100644 --- a/endpoints/getting-started-grpc/system-test/endpoints.test.js +++ b/endpoints/getting-started-grpc/system-test/endpoints.test.js @@ -72,16 +72,16 @@ const JWT_AUTH_TOKEN = jwt.sign( ); // API key -it(`should request a greeting from a remote Compute Engine instance using an API key`, async () => { - const output = await tools.runAsync( +it(`should request a greeting from a remote Compute Engine instance using an API key`, () => { + const output = childProcess.execSync( `${clientCmd} -h ${GCE_HOST} -k ${API_KEY}`, cwd ); assert.ok(new RegExp('Hello world').test(output)); }); -it(`should request a greeting from a remote Container Engine cluster using an API key`, async () => { - const output = await tools.runAsync( +it(`should request a greeting from a remote Container Engine cluster using an API key`, () => { + const output = childProcess.execSync( `${clientCmd} -h ${GKE_HOST} -k ${API_KEY}`, cwd ); @@ -93,7 +93,7 @@ it('should request and handle a greeting locally using an API key', async () => const server = childProcess.exec(`${serverCmd} -p ${PORT}`, {cwd: cwd}); await delay(1000); - const clientOutput = await tools.runAsync( + const clientOutput = childProcess.execSync( `${clientCmd} -h localhost:${PORT} -k ${API_KEY}`, cwd ); @@ -102,16 +102,16 @@ it('should request and handle a greeting locally using an API key', async () => }); // Authtoken -it(`should request a greeting from a remote Compute Engine instance using a JWT Auth Token`, async () => { - const output = await tools.runAsync( +it(`should request a greeting from a remote Compute Engine instance using a JWT Auth Token`, () => { + const output = childProcess.execSync( `${clientCmd} -h ${GCE_HOST} -j ${JWT_AUTH_TOKEN}`, cwd ); assert.ok(new RegExp('Hello world').test(output)); }); -it(`should request a greeting from a remote Container Engine cluster using a JWT Auth Token`, async () => { - const output = await tools.runAsync( +it(`should request a greeting from a remote Container Engine cluster using a JWT Auth Token`, () => { + const output = childProcess.execSync( `${clientCmd} -h ${GKE_HOST} -j ${JWT_AUTH_TOKEN}`, cwd ); @@ -123,7 +123,7 @@ it(`should request and handle a greeting locally using a JWT Auth Token`, async const server = childProcess.exec(`${serverCmd} -p ${PORT}`, {cwd: cwd}); await delay(1000); - const clientOutput = await tools.runAsync( + const clientOutput = childProcess.execSync( `${clientCmd} -h localhost:${PORT} -j ${JWT_AUTH_TOKEN}`, cwd ); diff --git a/healthcare/datasets/system-test/datasets.test.js b/healthcare/datasets/system-test/datasets.test.js index 018022b275..f10c9c26ff 100644 --- a/healthcare/datasets/system-test/datasets.test.js +++ b/healthcare/datasets/system-test/datasets.test.js @@ -16,8 +16,8 @@ const path = require('path'); const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); const uuid = require('uuid'); +const {execSync} = require('child_process'); const cwd = path.join(__dirname, '..'); const projectId = process.env.GCLOUD_PROJECT; @@ -36,9 +36,9 @@ before(() => { `Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!` ); }); -after(async () => { +after(() => { try { - await tools.runAsync( + execSync( `node deleteDataset.js ${projectId} ${cloudRegion} ${destinationDatasetId}`, cwd ); @@ -46,25 +46,25 @@ after(async () => { } catch (err) {} // Ignore error }); -it('should create a dataset', async () => { - const output = await tools.runAsync( +it('should create a dataset', () => { + const output = execSync( `node createDataset.js ${projectId} ${cloudRegion} ${datasetId}`, cwd ); assert.strictEqual(output, `Created dataset: ${datasetId}`); }); -it('should get a dataset', async () => { - const output = await tools.runAsync( +it('should get a dataset', () => { + const output = execSync( `node getDataset.js ${projectId} ${cloudRegion} ${datasetId}`, cwd ); assert.ok(output.includes('name')); }); -it('should patch a dataset', async () => { +it('should patch a dataset', () => { const timeZone = 'GMT'; - const output = await tools.runAsync( + const output = execSync( `node patchDataset.js ${projectId} ${cloudRegion} ${datasetId} ${timeZone}`, cwd ); @@ -74,16 +74,16 @@ it('should patch a dataset', async () => { ); }); -it('should list datasets', async () => { - const output = await tools.runAsync( +it('should list datasets', () => { + const output = execSync( `node listDatasets.js ${projectId} ${cloudRegion}`, cwd ); assert.ok(output.includes('datasets')); }); -it('should de-identify data in a dataset and write to a new dataset', async () => { - const output = await tools.runAsync( +it('should de-identify data in a dataset and write to a new dataset', () => { + const output = execSync( `node deidentifyDataset.js ${projectId} ${cloudRegion} ${datasetId} ${destinationDatasetId} ${keeplistTags}`, cwd ); @@ -93,24 +93,24 @@ it('should de-identify data in a dataset and write to a new dataset', async () = ); }); -it('should create and get a dataset IAM policy', async () => { +it('should create and get a dataset IAM policy', () => { const localMember = 'group:dpebot@google.com'; const localRole = 'roles/viewer'; - let output = await tools.runAsync( + let output = execSync( `node setDatasetIamPolicy.js ${projectId} ${cloudRegion} ${datasetId} ${localMember} ${localRole}`, cwd ); assert.ok(output.includes, 'ETAG'); - output = await tools.runAsync( + output = execSync( `node getDatasetIamPolicy.js ${projectId} ${cloudRegion} ${datasetId}` ); assert.ok(output.includes('dpebot')); }); -it('should delete a dataset', async () => { - const output = await tools.runAsync( +it('should delete a dataset', () => { + const output = execSync( `node deleteDataset.js ${projectId} ${cloudRegion} ${datasetId}`, cwd ); diff --git a/healthcare/dicom/system-test/dicom_stores.test.js b/healthcare/dicom/system-test/dicom_stores.test.js index 94244c2860..34734d406c 100644 --- a/healthcare/dicom/system-test/dicom_stores.test.js +++ b/healthcare/dicom/system-test/dicom_stores.test.js @@ -16,8 +16,8 @@ const path = require('path'); const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); const uuid = require('uuid'); +const {execSync} = require('child_process'); const {PubSub} = require('@google-cloud/pubsub'); const {Storage} = require('@google-cloud/storage'); @@ -59,7 +59,7 @@ before(async () => { // Create a Pub/Sub topic to be used for testing. const [topic] = await pubSubClient.createTopic(topicName); console.log(`Topic ${topic.name} created.`); - await tools.runAsync( + execSync( `node createDataset.js ${projectId} ${cloudRegion} ${datasetId}`, cwdDatasets ); @@ -75,79 +75,79 @@ after(async () => { await pubSubClient.topic(topicName).delete(); console.log(`Topic ${topicName} deleted.`); - await tools.runAsync( + execSync( `node deleteDataset.js ${projectId} ${cloudRegion} ${datasetId}`, cwdDatasets ); } catch (err) {} // Ignore error }); -it('should create a DICOM store', async () => { - const output = await tools.runAsync( +it('should create a DICOM store', () => { + const output = execSync( `node createDicomStore.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId}`, cwd ); assert.ok(output.includes('Created DICOM store')); }); -it('should get a DICOM store', async () => { - const output = await tools.runAsync( +it('should get a DICOM store', () => { + const output = execSync( `node getDicomStore.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId}`, cwd ); assert.ok(output.includes('name')); }); -it('should patch a DICOM store', async () => { - const output = await tools.runAsync( +it('should patch a DICOM store', () => { + const output = execSync( `node patchDicomStore.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId} ${topicName}`, cwd ); assert.ok(output.includes('Patched DICOM store')); }); -it('should list DICOM stores', async () => { - const output = await tools.runAsync( +it('should list DICOM stores', () => { + const output = execSync( `node listDicomStores.js ${projectId} ${cloudRegion} ${datasetId}`, cwd ); assert.ok(output.includes('dicomStores')); }); -it('should create and get a DICOM store IAM policy', async () => { +it('should create and get a DICOM store IAM policy', () => { const localMember = 'group:dpebot@google.com'; const localRole = 'roles/viewer'; - let output = await tools.runAsync( + let output = execSync( `node setDicomStoreIamPolicy.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId} ${localMember} ${localRole}`, cwd ); assert.ok(output.includes, 'ETAG'); - output = await tools.runAsync( + output = execSync( `node getDicomStoreIamPolicy.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId}` ); assert.ok(output.includes('dpebot')); }); -it('should import a DICOM object from GCS', async () => { - const output = await tools.runAsync( +it('should import a DICOM object from GCS', () => { + const output = execSync( `node importDicomInstance.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId} ${gcsUri}`, cwd ); assert.ok(output.includes('Successfully imported DICOM instances')); }); -it('should export a DICOM instance', async () => { - const output = await tools.runAsync( +it('should export a DICOM instance', () => { + const output = execSync( `node exportDicomInstanceGcs.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId} ${bucketName}`, cwd ); assert.ok(output.includes('Exported DICOM instances')); }); -it('should delete a DICOM store', async () => { - const output = await tools.runAsync( +it('should delete a DICOM store', () => { + const output = execSync( `node deleteDicomStore.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId}`, cwd ); diff --git a/healthcare/dicom/system-test/dicomweb.test.js b/healthcare/dicom/system-test/dicomweb.test.js index e178aac8e4..2500148749 100644 --- a/healthcare/dicom/system-test/dicomweb.test.js +++ b/healthcare/dicom/system-test/dicomweb.test.js @@ -16,8 +16,8 @@ const path = require('path'); const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); const uuid = require('uuid'); +const {execSync} = require('child_process'); const projectId = process.env.GCLOUD_PROJECT; const cloudRegion = 'us-central1'; @@ -41,7 +41,7 @@ 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'; -before(async () => { +before(() => { assert( process.env.GCLOUD_PROJECT, `Must set GCLOUD_PROJECT environment variable!` @@ -50,75 +50,75 @@ before(async () => { process.env.GOOGLE_APPLICATION_CREDENTIALS, `Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!` ); - await tools.runAsync( + execSync( `node createDataset.js ${projectId} ${cloudRegion} ${datasetId}`, cwdDatasets ); - await tools.runAsync( + execSync( `node createDicomStore.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId}`, cwd ); }); -after(async () => { +after(() => { try { - await tools.runAsync( + execSync( `node deleteDicomStore.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId}`, cwd ); - await tools.runAsync(`node deleteDataset.js ${datasetId}`, cwdDatasets); + execSync(`node deleteDataset.js ${datasetId}`, cwdDatasets); } catch (err) {} // Ignore error }); -it('should store a DICOM instance', async () => { - const output = await tools.runAsync( +it('should store a DICOM instance', () => { + const output = execSync( `node dicomWebStoreInstance.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId} ${dcmFile}`, cwd ); assert.ok(output.includes('Stored DICOM instance')); }); -it('should search DICOM instances', async () => { - const output = await tools.runAsync( +it('should search DICOM instances', () => { + const output = execSync( `node dicomWebSearchForInstances.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId}`, cwd ); assert.ok(output.includes('Found')); }); -it('should retrieve a DICOM study', async () => { - const output = await tools.runAsync( +it('should retrieve a DICOM study', () => { + const output = execSync( `node dicomWebRetrieveStudy.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId} ${studyUid}`, cwd ); assert.ok(output.includes('Retrieved study')); }); -it('should retrieve a DICOM instance', async () => { - const output = await tools.runAsync( +it('should retrieve a DICOM instance', () => { + const output = execSync( `node dicomWebRetrieveInstance.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId} ${studyUid} ${seriesUid} ${instanceUid}`, cwd ); assert.ok(output.includes('Retrieved DICOM instance')); }); -it('should retrieve a DICOM rendered PNG image', async () => { - const output = await tools.runAsync( +it('should retrieve a DICOM rendered PNG image', () => { + const output = execSync( `node dicomWebRetrieveRendered.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId} ${studyUid} ${seriesUid} ${instanceUid}`, cwd ); assert.ok(output.includes('Retrieved rendered image')); }); -it('should search for DICOM studies', async () => { - const output = await tools.runAsync( +it('should search for DICOM studies', () => { + const output = execSync( `node dicomWebSearchStudies.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId}`, cwd ); assert.ok(output.includes('Found')); }); -it('should delete a DICOM study', async () => { - const output = await tools.runAsync( +it('should delete a DICOM study', () => { + const output = execSync( `node dicomWebDeleteStudy.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId} ${studyUid}`, cwd ); diff --git a/healthcare/fhir/system-test/fhir_resources.test.js b/healthcare/fhir/system-test/fhir_resources.test.js index 75bdcf23ac..2759d95d5d 100644 --- a/healthcare/fhir/system-test/fhir_resources.test.js +++ b/healthcare/fhir/system-test/fhir_resources.test.js @@ -16,8 +16,8 @@ const path = require('path'); const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); const uuid = require('uuid'); +const {execSync} = require('child_process'); const projectId = process.env.GCLOUD_PROJECT; const cloudRegion = 'us-central1'; @@ -34,7 +34,7 @@ const bundleFile = 'resources/bundle.json'; const resourceType = 'Patient'; let resourceId; -before(async () => { +before(() => { assert( process.env.GCLOUD_PROJECT, `Must set GCLOUD_PROJECT environment variable!` @@ -43,26 +43,26 @@ before(async () => { process.env.GOOGLE_APPLICATION_CREDENTIALS, `Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!` ); - await tools.runAsync( + execSync( `node createDataset.js ${projectId} ${cloudRegion} ${datasetId}`, cwdDatasets ); }); -after(async () => { +after(() => { try { - await tools.runAsync( + execSync( `node deleteDataset.js ${projectId} ${cloudRegion} ${datasetId}`, cwdDatasets ); } catch (err) {} // Ignore error }); -it('should create a FHIR resource', async () => { - await tools.runAsync( +it('should create a FHIR resource', () => { + execSync( `node createFhirStore.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId}`, cwd ); - const output = await tools.runAsync( + const output = execSync( `node fhir_resources.js createResource ${datasetId} ${fhirStoreId} ${resourceType}`, cwd ); @@ -73,8 +73,8 @@ it('should create a FHIR resource', async () => { [, resourceId] = createdResource.exec(output); }); -it('should get a FHIR resource', async () => { - const output = await tools.runAsync( +it('should get a FHIR resource', () => { + const output = execSync( `node getFhirResource.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`, cwd ); @@ -84,8 +84,8 @@ it('should get a FHIR resource', async () => { ); }); -it('should list and get a FHIR resource history', async () => { - let output = await tools.runAsync( +it('should list and get a FHIR resource history', () => { + let output = execSync( `node listFhirResourceHistory.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`, cwd ); @@ -103,15 +103,15 @@ it('should list and get a FHIR resource history', async () => { ], } = formatted; - output = await tools.runAsync( + output = execSync( `node getFhirResourceHistory.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId} ${versionId}`, cwd ); assert.ok(output.includes(versionId)); }); -it('should get everything in Patient compartment', async () => { - const output = await tools.runAsync( +it('should get everything in Patient compartment', () => { + const output = execSync( `node getPatientEverything.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceId}`, cwd ); @@ -123,8 +123,8 @@ it('should get everything in Patient compartment', async () => { ); }); -it('should update a FHIR resource', async () => { - const output = await tools.runAsync( +it('should update a FHIR resource', () => { + const output = execSync( `node updateFhirResource.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`, cwd ); @@ -134,30 +134,30 @@ it('should update a FHIR resource', async () => { ); }); -it('should patch a FHIR resource', async () => { - const output = await tools.runAsync( +it('should patch a FHIR resource', () => { + const output = execSync( `node fhir_resources.js patchResource ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`, cwd ); assert.strictEqual(output, `Patched ${resourceType} resource`); }); -it('should search for FHIR resources using GET', async () => { - const output = await tools.runAsync( +it('should search for FHIR resources using GET', () => { + const output = execSync( `node searchFhirResourcesGet.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceType}` ); assert.strictEqual(new RegExp('Resources found').test(output), true); }); -it('should search for FHIR resources using POST', async () => { - const output = await tools.runAsync( +it('should search for FHIR resources using POST', () => { + const output = execSync( `node searchFhirResourcesPost.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceType}` ); assert.strictEqual(new RegExp('Resources found').test(output), true); }); -it('should purge all historical versions of a FHIR resource', async () => { - const output = await tools.runAsync( +it('should purge all historical versions of a FHIR resource', () => { + const output = execSync( `node deleteFhirResourcePurge.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`, cwd ); @@ -167,23 +167,23 @@ it('should purge all historical versions of a FHIR resource', async () => { ); }); -it('should execute a Bundle', async () => { - const output = await tools.runAsync( +it('should execute a Bundle', () => { + const output = execSync( `node fhir_resources.js executeBundle ${datasetId} ${fhirStoreId} ${bundleFile}`, cwd ); assert.strictEqual(new RegExp('Executed Bundle').test(output), true); }); -it('should delete a FHIR resource', async () => { - const output = await tools.runAsync( +it('should delete a FHIR resource', () => { + const output = execSync( `node deleteFhirResource.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`, cwd ); assert.strictEqual(output, `Deleted FHIR resource ${resourceType}`); // Clean up - await tools.runAsync( + execSync( `node deleteFhirStore.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId}`, cwd ); diff --git a/healthcare/fhir/system-test/fhir_stores.test.js b/healthcare/fhir/system-test/fhir_stores.test.js index 300a23aba5..a9c095caa0 100644 --- a/healthcare/fhir/system-test/fhir_stores.test.js +++ b/healthcare/fhir/system-test/fhir_stores.test.js @@ -16,8 +16,8 @@ const path = require('path'); const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); const uuid = require('uuid'); +const {execSync} = require('child_process'); const {PubSub} = require('@google-cloud/pubsub'); const {Storage} = require('@google-cloud/storage'); @@ -60,7 +60,7 @@ before(async () => { // Create a Pub/Sub topic to be used for testing. const [topic] = await pubSubClient.createTopic(topicName); console.log(`Topic ${topic.name} created.`); - await tools.runAsync( + execSync( `node createDataset.js ${projectId} ${cloudRegion} ${datasetId}`, cwdDatasets ); @@ -76,79 +76,79 @@ after(async () => { await pubSubClient.topic(topicName).delete(); console.log(`Topic ${topicName} deleted.`); - await tools.runAsync( + execSync( `node deleteDataset.js ${projectId} ${cloudRegion} ${datasetId}`, cwdDatasets ); } catch (err) {} // Ignore error }); -it('should create a FHIR store', async () => { - const output = await tools.runAsync( +it('should create a FHIR store', () => { + const output = execSync( `node createFhirStore.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId}`, cwd ); assert.ok(output.includes('Created FHIR store')); }); -it('should get a FHIR store', async () => { - const output = await tools.runAsync( +it('should get a FHIR store', () => { + const output = execSync( `node getFhirStore.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId}`, cwd ); assert.ok(output.includes('name')); }); -it('should list FHIR stores', async () => { - const output = await tools.runAsync( +it('should list FHIR stores', () => { + const output = execSync( `node listFhirStores.js ${projectId} ${cloudRegion} ${datasetId}`, cwd ); assert.ok(output.includes('fhirStores')); }); -it('should patch a FHIR store', async () => { - const output = await tools.runAsync( +it('should patch a FHIR store', () => { + const output = execSync( `node patchFhirStore.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${topicName}`, cwd ); assert.ok(output.includes('Patched FHIR store')); }); -it('should import FHIR resources into a FHIR store from Cloud Storage', async () => { - const output = await tools.runAsync( +it('should import FHIR resources into a FHIR store from Cloud Storage', () => { + const output = execSync( `node importFhirResources.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${gcsUri}`, cwd ); assert.ok(output.includes('Import FHIR resources succeeded')); }); -it('should export FHIR resources from a FHIR store to Cloud Storage', async () => { - const output = await tools.runAsync( +it('should export FHIR resources from a FHIR store to Cloud Storage', () => { + const output = execSync( `node exportFhirResources.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${gcsUri}`, cwd ); assert.ok(output.includes('Exported FHIR resources successfully')); }); -it('should create and get a FHIR store IAM policy', async () => { +it('should create and get a FHIR store IAM policy', () => { const localMember = 'group:dpebot@google.com'; const localRole = 'roles/viewer'; - let output = await tools.runAsync( + let output = execSync( `node setFhirStoreIamPolicy.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${localMember} ${localRole}`, cwd ); assert.ok(output.includes, 'ETAG'); - output = await tools.runAsync( + output = execSync( `node getFhirStoreIamPolicy.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId}` ); assert.ok(output.includes('dpebot')); }); -it('should delete a FHIR store', async () => { - const output = await tools.runAsync( +it('should delete a FHIR store', () => { + const output = execSync( `node deleteFhirStore.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId}`, cwd ); diff --git a/healthcare/hl7v2/system-test/hl7v2_messages.test.js b/healthcare/hl7v2/system-test/hl7v2_messages.test.js index 070a201724..bcd2f7c7dc 100644 --- a/healthcare/hl7v2/system-test/hl7v2_messages.test.js +++ b/healthcare/hl7v2/system-test/hl7v2_messages.test.js @@ -16,8 +16,8 @@ const path = require('path'); const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); const uuid = require('uuid'); +const {execSync} = require('child_process'); const projectId = process.env.GCLOUD_PROJECT; const cloudRegion = 'us-central1'; @@ -35,7 +35,7 @@ const messageId = '2yqbdhYHlk_ucSmWkcKOVm_N0p0OpBXgIlVG18rB-cw='; const labelKey = 'my-key'; const labelValue = 'my-value'; -before(async () => { +before(() => { assert( process.env.GCLOUD_PROJECT, `Must set GCLOUD_PROJECT environment variable!` @@ -44,73 +44,73 @@ before(async () => { process.env.GOOGLE_APPLICATION_CREDENTIALS, `Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!` ); - await tools.runAsync( + execSync( `node createDataset.js ${projectId} ${cloudRegion} ${datasetId}`, cwdDatasets ); }); -after(async () => { +after(() => { try { - await tools.runAsync( + execSync( `node deleteDataset.js ${projectId} ${cloudRegion} ${datasetId}`, cwdDatasets ); } catch (err) {} // Ignore error }); -it('should create an HL7v2 message', async () => { - await tools.runAsync( +it('should create an HL7v2 message', () => { + execSync( `node createHl7v2Store.js ${projectId} ${cloudRegion} ${datasetId} ${hl7v2StoreId}`, cwd ); - const output = await tools.runAsync( + const output = execSync( `node createHl7v2Message.js ${projectId} ${cloudRegion} ${datasetId} ${hl7v2StoreId} ${messageFile}`, cwd ); assert.ok(output.includes('Created HL7v2 message')); }); -it('should ingest an HL7v2 message', async () => { - const output = await tools.runAsync( +it('should ingest an HL7v2 message', () => { + const output = execSync( `node ingestHl7v2Message.js ${projectId} ${cloudRegion} ${datasetId} ${hl7v2StoreId} ${messageFile}`, cwd ); assert.ok(output.includes('Ingested HL7v2 message')); }); -it('should get an HL7v2 message', async () => { - const output = await tools.runAsync( +it('should get an HL7v2 message', () => { + const output = execSync( `node getHl7v2Message.js ${projectId} ${cloudRegion} ${datasetId} ${hl7v2StoreId} ${messageId}`, cwd ); assert.ok(output.includes('Got HL7v2 message')); }); -it('should list HL7v2 messages', async () => { - const output = await tools.runAsync( +it('should list HL7v2 messages', () => { + const output = execSync( `node listHl7v2Messages.js ${projectId} ${cloudRegion} ${datasetId} ${hl7v2StoreId}`, cwd ); assert.ok(output.includes('HL7v2 messages')); }); -it('should patch an HL7v2 message', async () => { - const output = await tools.runAsync( +it('should patch an HL7v2 message', () => { + const output = execSync( `node patchHl7v2Message.js ${projectId} ${cloudRegion} ${datasetId} ${hl7v2StoreId} ${messageId} ${labelKey} ${labelValue}`, cwd ); assert.ok(output.includes('Patched HL7v2 message')); }); -it('should delete an HL7v2 message', async () => { - const output = await tools.runAsync( +it('should delete an HL7v2 message', () => { + const output = execSync( `node deleteHl7v2Message.js ${projectId} ${cloudRegion} ${datasetId} ${hl7v2StoreId} ${messageId}`, cwd ); assert.ok(output.includes('Deleted HL7v2 message')); // Clean up - tools.runAsync( + execSync( `node deleteHl7v2Store.js ${projectId} ${cloudRegion} ${datasetId} ${hl7v2StoreId}`, cwd ); diff --git a/healthcare/hl7v2/system-test/hl7v2_stores.test.js b/healthcare/hl7v2/system-test/hl7v2_stores.test.js index 855b5db9a6..2c8b7879ba 100644 --- a/healthcare/hl7v2/system-test/hl7v2_stores.test.js +++ b/healthcare/hl7v2/system-test/hl7v2_stores.test.js @@ -16,8 +16,8 @@ const path = require('path'); const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); const uuid = require('uuid'); +const {execSync} = require('child_process'); const projectId = process.env.GCLOUD_PROJECT; const {PubSub} = require('@google-cloud/pubsub'); @@ -45,7 +45,7 @@ before(async () => { // Create a Pub/Sub topic to be used for testing. const [topic] = await pubSubClient.createTopic(topicName); console.log(`Topic ${topic.name} created.`); - await tools.runAsync( + execSync( `node createDataset.js ${projectId} ${cloudRegion} ${datasetId}`, cwdDatasets ); @@ -54,63 +54,63 @@ after(async () => { try { await pubSubClient.topic(topicName).delete(); console.log(`Topic ${topicName} deleted.`); - await tools.runAsync( + execSync( `node deleteDataset.js ${projectId} ${cloudRegion} ${datasetId}`, cwdDatasets ); } catch (err) {} // Ignore error }); -it('should create an HL7v2 store', async () => { - const output = await tools.runAsync( +it('should create an HL7v2 store', () => { + const output = execSync( `node createHl7v2Store.js ${projectId} ${cloudRegion} ${datasetId} ${hl7v2StoreId}`, cwd ); assert.ok(output.includes('Created HL7v2 store')); }); -it('should get an HL7v2 store', async () => { - const output = await tools.runAsync( +it('should get an HL7v2 store', () => { + const output = execSync( `node getHl7v2Store.js ${projectId} ${cloudRegion} ${datasetId} ${hl7v2StoreId}`, cwd ); assert.ok(output.includes('name')); }); -it('should patch an HL7v2 store', async () => { - const output = await tools.runAsync( +it('should patch an HL7v2 store', () => { + const output = execSync( `node patchHl7v2Store.js ${projectId} ${cloudRegion} ${datasetId} ${hl7v2StoreId} ${topicName}`, cwd ); assert.ok(output.includes('Patched HL7v2 store')); }); -it('should list HL7v2 stores', async () => { - const output = await tools.runAsync( +it('should list HL7v2 stores', () => { + const output = execSync( `node listHl7v2Stores.js ${projectId} ${cloudRegion} ${datasetId}`, cwd ); assert.ok(output.includes('hl7V2Stores')); }); -it('should create and get an HL7v2 store IAM policy', async () => { +it('should create and get an HL7v2 store IAM policy', () => { const localMember = 'group:dpebot@google.com'; const localRole = 'roles/viewer'; - let output = await tools.runAsync( + let output = execSync( `node setHl7v2StoreIamPolicy.js ${projectId} ${cloudRegion} ${datasetId} ${hl7v2StoreId} ${localMember} ${localRole}`, cwd ); assert.ok(output.includes, 'ETAG'); - output = await tools.runAsync( + output = execSync( `node getHl7v2StoreIamPolicy.js ${projectId} ${cloudRegion} ${datasetId} ${hl7v2StoreId}` ); assert.ok(output.includes('dpebot')); }); -it('should delete an HL7v2 Store', async () => { - const output = await tools.runAsync( +it('should delete an HL7v2 Store', () => { + const output = execSync( `node deleteHl7v2Store ${projectId} ${cloudRegion} ${datasetId} ${hl7v2StoreId}`, cwd ); diff --git a/iot/http_example/system-test/cloudiot_http_example.test.js b/iot/http_example/system-test/cloudiot_http_example.test.js index 5feb75c0b9..6ee4bd8321 100644 --- a/iot/http_example/system-test/cloudiot_http_example.test.js +++ b/iot/http_example/system-test/cloudiot_http_example.test.js @@ -19,6 +19,7 @@ const {PubSub} = require('@google-cloud/pubsub'); const assert = require('assert'); const tools = require('@google-cloud/nodejs-repo-tools'); const uuid = require('uuid'); +const childProcess = require('child_process'); const deviceId = 'test-node-device'; const topicName = `nodejs-docs-samples-test-iot-${uuid.v4()}`; @@ -50,21 +51,21 @@ after(async () => { console.log(`Topic ${topic.name} deleted.`); }); -it('should receive configuration message', async () => { +it('should receive configuration message', () => { const localDevice = 'test-rsa-device'; const localRegName = `${registryName}-rsa256`; - await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); - await tools.runAsync( + childProcess.execSync(`${helper} setupIotTopic ${topicName}`, cwd); + childProcess.execSync( `${helper} createRegistry ${localRegName} ${topicName}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} createRsa256Device ${localDevice} ${localRegName} resources/rsa_cert.pem`, cwd ); - const output = await tools.runAsync( + const output = childProcess.execSync( `${cmd} --messageType=events --numMessages=1 --privateKeyFile=resources/rsa_private.pem --algorithm=RS256`, cwd ); @@ -72,32 +73,32 @@ it('should receive configuration message', async () => { assert.strictEqual(new RegExp(/Getting config/).test(output), true); // Check / cleanup - await tools.runAsync( + childProcess.execSync( `${helper} getDeviceState ${localDevice} ${localRegName}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} deleteDevice ${localDevice} ${localRegName}`, cwd ); - await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); + childProcess.execSync(`${helper} deleteRegistry ${localRegName}`, cwd); }); it('should send event message', async () => { const localDevice = 'test-rsa-device'; const localRegName = `${registryName}-rsa256`; - await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); - await tools.runAsync( + childProcess.execSync(`${helper} setupIotTopic ${topicName}`, cwd); + childProcess.execSync( `${helper} createRegistry ${localRegName} ${topicName}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} createRsa256Device ${localDevice} ${localRegName} resources/rsa_cert.pem`, cwd ); - const output = await tools.runAsync( + const output = childProcess.execSync( `${cmd} --messageType=events --numMessages=1 --privateKeyFile=resources/rsa_private.pem --algorithm=RS256`, cwd ); @@ -105,44 +106,44 @@ it('should send event message', async () => { assert.strictEqual(new RegExp(/Publishing message/).test(output), true); // Check / cleanup - await tools.runAsync( + await childProcess.execSync( `${helper} getDeviceState ${localDevice} ${localRegName}`, cwd ); - await tools.runAsync( + await childProcess.execSync( `${helper} deleteDevice ${localDevice} ${localRegName}`, cwd ); - await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); + await childProcess.execSync(`${helper} deleteRegistry ${localRegName}`, cwd); }); it('should send state message', async () => { const localDevice = 'test-rsa-device'; const localRegName = `${registryName}-rsa256`; - await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); - await tools.runAsync( + await childProcess.execSync(`${helper} setupIotTopic ${topicName}`, cwd); + await childProcess.execSync( `${helper} createRegistry ${localRegName} ${topicName}`, cwd ); - await tools.runAsync( + await childProcess.execSync( `${helper} createRsa256Device ${localDevice} ${localRegName} resources/rsa_cert.pem`, cwd ); - const output = await tools.runAsync( + const output = await childProcess.execSync( `${cmd} --messageType=state --numMessages=1 --privateKeyFile=resources/rsa_private.pem --algorithm=RS256`, cwd ); assert.strictEqual(new RegExp(/Publishing message/).test(output), true); // Check / cleanup - await tools.runAsync( + await childProcess.execSync( `${helper} getDeviceState ${localDevice} ${localRegName}`, cwd ); - await tools.runAsync( + await childProcess.execSync( `${helper} deleteDevice ${localDevice} ${localRegName}`, cwd ); - await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); + await childProcess.execSync(`${helper} deleteRegistry ${localRegName}`, cwd); }); diff --git a/iot/manager/system-test/manager.test.js b/iot/manager/system-test/manager.test.js index b6d1c27334..9fb16c61cf 100644 --- a/iot/manager/system-test/manager.test.js +++ b/iot/manager/system-test/manager.test.js @@ -20,6 +20,7 @@ const {PubSub} = require('@google-cloud/pubsub'); const assert = require('assert'); const tools = require('@google-cloud/nodejs-repo-tools'); const uuid = require('uuid'); +const childProcess = require('child_process'); const topicName = `nodejs-iot-test-topic-${uuid.v4()}`; const registryName = `nodejs-iot-test-registry-${uuid.v4()}`; @@ -63,7 +64,7 @@ before(async () => { ], }, }; - await tools.runAsync(`${cmd} setupIotTopic ${topicName}`, cwd); + childProcess.execSync(`${cmd} setupIotTopic ${topicName}`, cwd); await iotClient.createDeviceRegistry(createRegistryRequest); console.log(`Created registry: ${registryName}`); @@ -80,187 +81,187 @@ after(async () => { console.log('Deleted test registry.'); }); -it('should create and delete an unauthorized device', async () => { +it('should create and delete an unauthorized device', () => { const localDevice = 'test-device-unauth-delete'; - let output = await tools.runAsync( + let output = childProcess.execSync( `${cmd} createUnauthDevice ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('Created device')); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} deleteDevice ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('Successfully deleted device')); }); -it('should list configs for a device', async () => { +it('should list configs for a device', () => { const localDevice = 'test-device-configs'; - let output = await tools.runAsync( + let output = childProcess.execSync( `${cmd} createUnauthDevice ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('Created device')); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} getDeviceConfigs ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('Configs')); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} deleteDevice ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('Successfully deleted device')); }); -it('should create and delete an RSA256 device', async () => { +it('should create and delete an RSA256 device', () => { const localDevice = 'test-rsa-device'; - let output = await tools.runAsync( + let output = childProcess.execSync( `${cmd} createRsa256Device ${localDevice} ${registryName} ${rsaPublicCert}`, cwd ); assert.ok(output.includes('Created device')); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} getDeviceState ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('State')); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} deleteDevice ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('Successfully deleted device')); }); -it('should create and delete an ES256 device', async () => { +it('should create and delete an ES256 device', () => { const localDevice = 'test-es256-device'; - let output = await tools.runAsync( + let output = childProcess.execSync( `${cmd} createEs256Device ${localDevice} ${registryName} ${ecPublicKey}`, cwd ); assert.ok(output.includes('Created device')); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} getDeviceState ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('State')); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} deleteDevice ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('Successfully deleted device')); }); -it('should patch an unauthorized device with RSA256', async () => { +it('should patch an unauthorized device with RSA256', () => { const localDevice = 'test-device-patch-rs256'; - let output = await tools.runAsync( + let output = childProcess.execSync( `${cmd} createUnauthDevice ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('Created device')); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} patchRsa256 ${localDevice} ${registryName} ${rsaPublicCert}`, cwd ); assert.ok(output.includes('Patched device:')); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} deleteDevice ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('Successfully deleted device')); }); -it('should patch an unauthorized device with ES256', async () => { +it('should patch an unauthorized device with ES256', () => { const localDevice = 'test-device-patch-es256'; - let output = await tools.runAsync( + let output = childProcess.execSync( `${cmd} createUnauthDevice ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('Created device')); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} patchEs256 ${localDevice} ${registryName} ${ecPublicKey}`, cwd ); assert.ok(output.includes('Patched device:')); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} deleteDevice ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('Successfully deleted device')); }); -it('should create and list devices', async () => { +it('should create and list devices', () => { const localDevice = 'test-device-list'; - let output = await tools.runAsync( + let output = childProcess.execSync( `${cmd} createUnauthDevice ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('Created device')); - output = await tools.runAsync(`${cmd} listDevices ${registryName}`, cwd); + output = childProcess.execSync(`${cmd} listDevices ${registryName}`, cwd); assert.ok(output.includes('Current devices in registry:')); assert.ok(output.includes(localDevice)); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} deleteDevice ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('Successfully deleted device')); }); -it('should create and get a device', async () => { +it('should create and get a device', () => { const localDevice = 'test-device-get'; - let output = await tools.runAsync( + let output = childProcess.execSync( `${cmd} createUnauthDevice ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes('Created device')); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} getDevice ${localDevice} ${registryName}`, cwd ); assert.ok(output.includes(`Found device: ${localDevice}`)); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} deleteDevice ${localDevice} ${registryName}`, cwd ); }); -it('should create and get an iam policy', async () => { +it('should create and get an iam policy', () => { const localMember = 'group:dpebot@google.com'; const localRole = 'roles/viewer'; - let output = await tools.runAsync( + let output = childProcess.execSync( `${cmd} setIamPolicy ${registryName} ${localMember} ${localRole}`, cwd ); assert.ok(output.includes('ETAG')); - output = await tools.runAsync(`${cmd} getIamPolicy ${registryName}`, cwd); + output = childProcess.execSync(`${cmd} getIamPolicy ${registryName}`, cwd); assert.ok(output.includes('dpebot')); }); -it('should create and delete a registry', async () => { +it('should create and delete a registry', () => { const createRegistryId = `${registryName}-create`; - let output = await tools.runAsync(`${cmd} setupIotTopic ${topicName}`, cwd); - output = await tools.runAsync( + let output = childProcess.execSync(`${cmd} setupIotTopic ${topicName}`, cwd); + output = childProcess.execSync( `${cmd} createRegistry ${createRegistryId} ${topicName}`, cwd ); assert.ok(output.includes('Successfully created registry')); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} deleteRegistry ${createRegistryId}`, cwd ); assert.ok(output.includes('Successfully deleted registry')); }); -it('should send command message to device', async () => { +it('should send command message to device', () => { const deviceId = 'test-device-command'; const commandMessage = 'rotate:180_degrees'; - await tools.runAsync( + childProcess.execSync( `${cmd} createRsa256Device ${deviceId} ${registryName} ${rsaPublicCert}`, cwd ); @@ -271,18 +272,18 @@ it('should send command message to device', async () => { path.join(__dirname, '../../mqtt_example') ); - const output = await tools.runAsync( + const output = childProcess.execSync( `${cmd} sendCommand ${deviceId} ${registryName} ${commandMessage}` ); console.log(output); assert.ok(output.includes('Sent command')); - await tools.runAsync(`${cmd} deleteDevice ${deviceId} ${registryName}`, cwd); + childProcess.execSync(`${cmd} deleteDevice ${deviceId} ${registryName}`, cwd); }); it('should create a new gateway', async () => { const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`; - const gatewayOut = await tools.runAsync( + const gatewayOut = childProcess.execSync( `${cmd} createGateway --registryId=${registryName} --gatewayId=${gatewayId}\ --format=RSA_X509_PEM --key=${rsaPublicCert}` ); @@ -297,13 +298,13 @@ it('should create a new gateway', async () => { it('should list gateways', async () => { const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`; - await tools.runAsync( + childProcess.execSync( `${cmd} createGateway --registryId=${registryName} --gatewayId=${gatewayId}\ --format=RSA_X509_PEM --key=${rsaPublicCert}` ); // look for output in list gateway - const gateways = await tools.runAsync(`${cmd} listGateways ${registryName}`); + const gateways = childProcess.execSync(`${cmd} listGateways ${registryName}`); assert.ok(gateways.includes(`${gatewayId}`)); await iotClient.deleteDevice({ @@ -313,7 +314,7 @@ it('should list gateways', async () => { it('should bind existing device to gateway', async () => { const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`; - await tools.runAsync( + childProcess.execSync( `${cmd} createGateway --registryId=${registryName} --gatewayId=${gatewayId}\ --format=RSA_X509_PEM --key=${rsaPublicCert}` ); @@ -328,7 +329,7 @@ it('should bind existing device to gateway', async () => { }); // bind device to gateway - const bind = await tools.runAsync( + const bind = childProcess.execSync( `${cmd} bindDeviceToGateway ${registryName} ${gatewayId} ${deviceId}` ); @@ -336,7 +337,7 @@ it('should bind existing device to gateway', async () => { assert.strictEqual(bind.includes('Could not bind device'), false); // test unbind - const unbind = await tools.runAsync( + const unbind = childProcess.execSync( `${cmd} unbindDeviceFromGateway ${registryName} ${gatewayId} ${deviceId}` ); assert.ok(unbind.includes(`Unbound ${deviceId} from ${gatewayId}`)); @@ -352,7 +353,7 @@ it('should bind existing device to gateway', async () => { it('should list devices bound to gateway', async () => { const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`; - await tools.runAsync( + childProcess.execSync( `${cmd} createGateway --registryId=${registryName} --gatewayId=${gatewayId}\ --format=RSA_X509_PEM --key=${rsaPublicCert}` ); @@ -365,11 +366,11 @@ it('should list devices bound to gateway', async () => { }, }); - await tools.runAsync( + childProcess.execSync( `${cmd} bindDeviceToGateway ${registryName} ${gatewayId} ${deviceId}` ); - const devices = await tools.runAsync( + const devices = childProcess.execSync( `${cmd} listDevicesForGateway ${registryName} ${gatewayId}` ); @@ -380,7 +381,7 @@ it('should list devices bound to gateway', async () => { ); // cleanup - await tools.runAsync( + childProcess.execSync( `${cmd} unbindDeviceFromGateway ${registryName} ${gatewayId} ${deviceId}` ); @@ -395,7 +396,7 @@ it('should list devices bound to gateway', async () => { it('should list gateways for bound device', async () => { const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`; - await tools.runAsync( + childProcess.execSync( `${cmd} createGateway --registryId=${registryName} --gatewayId=${gatewayId}\ --format=RSA_X509_PEM --key=${rsaPublicCert}` ); @@ -409,11 +410,11 @@ it('should list gateways for bound device', async () => { }, }); - await tools.runAsync( + childProcess.execSync( `${cmd} bindDeviceToGateway ${registryName} ${gatewayId} ${deviceId}` ); - const devices = await tools.runAsync( + const devices = childProcess.execSync( `${cmd} listGatewaysForDevice ${registryName} ${deviceId}` ); @@ -424,7 +425,7 @@ it('should list gateways for bound device', async () => { ); // cleanup - await tools.runAsync( + childProcess.execSync( `${cmd} unbindDeviceFromGateway ${registryName} ${gatewayId} ${deviceId}` ); diff --git a/iot/mqtt_example/system-test/cloudiot_mqtt_example.test.js b/iot/mqtt_example/system-test/cloudiot_mqtt_example.test.js index 8e3e0fc488..12704b9a0f 100644 --- a/iot/mqtt_example/system-test/cloudiot_mqtt_example.test.js +++ b/iot/mqtt_example/system-test/cloudiot_mqtt_example.test.js @@ -66,7 +66,7 @@ before(async () => { ], }, }; - await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); + childProcess.execSync(`${helper} setupIotTopic ${topicName}`, cwd); await iotClient.createDeviceRegistry(createRegistryRequest); console.log(`Created registry: ${registryName}`); @@ -83,24 +83,24 @@ after(async () => { console.log('Deleted test registry.'); }); -it('should receive configuration message', async () => { +it('should receive configuration message', () => { const localDevice = 'test-rsa-device'; const localRegName = `${registryName}-rsa256`; - let output = await tools.runAsync( + let output = childProcess.execSync( `${helper} setupIotTopic ${topicName}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} createRegistry ${localRegName} ${topicName}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} createRsa256Device ${localDevice} ${localRegName} ${rsaPublicCert}`, cwd ); - output = await tools.runAsync( + output = childProcess.execSync( `${cmd} mqttDeviceDemo --messageType=events --registryId="${localRegName}" --deviceId="${localDevice}" ${cmdSuffix}`, cwd ); @@ -109,78 +109,78 @@ it('should receive configuration message', async () => { assert.strictEqual(new RegExp('Config message received:').test(output), true); // Check / cleanup - await tools.runAsync( + childProcess.execSync( `${helper} getDeviceState ${localDevice} ${localRegName}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} deleteDevice ${localDevice} ${localRegName}`, cwd ); - await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); + childProcess.execSync(`${helper} deleteRegistry ${localRegName}`, cwd); }); -it('should send event message', async () => { +it('should send event message', () => { const localDevice = 'test-rsa-device'; const localRegName = `${registryName}-rsa256`; - await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); - await tools.runAsync( + childProcess.execSync(`${helper} setupIotTopic ${topicName}`, cwd); + childProcess.execSync( `${helper} createRegistry ${localRegName} ${topicName}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} createRsa256Device ${localDevice} ${localRegName} ${rsaPublicCert}`, cwd ); - const output = await tools.runAsync( + const output = childProcess.execSync( `${cmd} mqttDeviceDemo --messageType=events --registryId="${localRegName}" --deviceId="${localDevice}" ${cmdSuffix}`, cwd ); assert.strictEqual(new RegExp('Publishing message:').test(output), true); // Check / cleanup - await tools.runAsync( + childProcess.execSync( `${helper} getDeviceState ${localDevice} ${localRegName}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} deleteDevice ${localDevice} ${localRegName}`, cwd ); - await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); + childProcess.execSync(`${helper} deleteRegistry ${localRegName}`, cwd); }); -it('should send state message', async () => { +it('should send state message', () => { const localDevice = 'test-rsa-device'; const localRegName = `${registryName}-rsa256`; - await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd); - await tools.runAsync( + childProcess.execSync(`${helper} setupIotTopic ${topicName}`, cwd); + childProcess.execSync( `${helper} createRegistry ${localRegName} ${topicName}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} createRsa256Device ${localDevice} ${localRegName} ${rsaPublicCert}`, cwd ); - const output = await tools.runAsync( + const output = childProcess.execSync( `${cmd} mqttDeviceDemo --messageType=state --registryId="${localRegName}" --deviceId="${localDevice}" ${cmdSuffix}`, cwd ); assert.strictEqual(new RegExp('Publishing message:').test(output), true); // Check / cleanup - await tools.runAsync( + childProcess.execSync( `${helper} getDeviceState ${localDevice} ${localRegName}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} deleteDevice ${localDevice} ${localRegName}`, cwd ); - await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd); + childProcess.execSync(`${helper} deleteRegistry ${localRegName}`, cwd); }); it.only('should receive command message', async () => { @@ -217,58 +217,57 @@ it.only('should receive command message', async () => { }); }); -it('should listen for bound device config message', async () => { +it('should listen for bound device config message', () => { const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`; - await tools.runAsync( + childProcess.execSync( `${helper} createGateway ${registryName} ${gatewayId} --publicKeyFormat=RSA_X509_PEM --publicKeyFile=${rsaPublicCert}`, cwd ); const deviceId = `nodejs-test-device-iot-${uuid.v4()}`; - await tools.runAsync( + childProcess.execSync( `${helper} bindDeviceToGateway ${registryName} ${gatewayId} ${deviceId}`, cwd ); // listen for configuration changes - const out = await tools.runAsync( + const out = childProcess.execSync( `${cmd} listenForConfigMessages --deviceId=${deviceId} --gatewayId=${gatewayId} --registryId=${registryName} --privateKeyFile=${rsaPrivateKey} --clientDuration=10000 --algorithm=RS256` ); assert.strictEqual(new RegExp('message received').test(out), true); // cleanup - await tools.runAsync( + childProcess.execSync( `${helper} unbindDeviceFromGateway ${registryName} ${gatewayId} ${deviceId}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} deleteDevice ${gatewayId} ${registryName}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} deleteDevice ${deviceId} ${registryName}`, cwd ); }); -it('should listen for error topic messages', async () => { +it('should listen for error topic messages', () => { const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`; - await tools.runAsync( + childProcess.execSync( `${helper} createGateway ${registryName} ${gatewayId} --publicKeyFormat=RSA_X509_PEM --publicKeyFile=${rsaPublicCert}`, cwd ); - // create a device but don't associate it with the gateway const deviceId = `nodejs-test-device-iot-${uuid.v4()}`; - await tools.runAsync( + childProcess.execSync( `${helper} createRsa256Device ${deviceId} ${registryName} ${rsaPublicCert}`, cwd ); // check error topic contains error of attaching a device that is not bound - const out = await tools.runAsync( + const out = childProcess.execSync( `${cmd} listenForErrorMessages --gatewayId=${gatewayId} --registryId=${registryName} --deviceId=${deviceId} --privateKeyFile=${rsaPrivateKey} --clientDuration=30000 --algorithm=RS256` ); @@ -278,15 +277,15 @@ it('should listen for error topic messages', async () => { ); // cleanup - await tools.runAsync( + childProcess.execSync( `${helper} unbindDeviceFromGateway ${registryName} ${gatewayId} ${deviceId}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} deleteDevice ${gatewayId} ${registryName}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} deleteDevice ${deviceId} ${registryName}`, cwd ); @@ -294,7 +293,7 @@ it('should listen for error topic messages', async () => { it('should send data from bound device', async () => { const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`; - await tools.runAsync( + childProcess.execSync( `${helper} createGateway ${registryName} ${gatewayId} --publicKeyFormat=RSA_X509_PEM --publicKeyFile=${rsaPublicCert}`, cwd ); @@ -307,28 +306,28 @@ it('should send data from bound device', async () => { }, }); - await tools.runAsync( + childProcess.execSync( `${helper} bindDeviceToGateway ${registryName} ${gatewayId} ${deviceId}`, cwd ); // relay telemetry on behalf of device - const out = await tools.runAsync( + const out = childProcess.execSync( `${cmd} sendDataFromBoundDevice --deviceId=${deviceId} --gatewayId=${gatewayId} --registryId=${registryName} --privateKeyFile=${rsaPrivateKey} --numMessages=5 --algorithm=RS256` ); assert.strictEqual(new RegExp('Publishing message 5/5').test(out), true); assert.strictEqual(new RegExp('Error: Connection refused').test(out), false); - await tools.runAsync( + childProcess.execSync( `${helper} unbindDeviceFromGateway ${registryName} ${gatewayId} ${deviceId}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} deleteDevice ${gatewayId} ${registryName}`, cwd ); - await tools.runAsync( + childProcess.execSync( `${helper} deleteDevice ${deviceId} ${registryName}`, cwd ); diff --git a/jobs/v2/system-test/quickstart.test.js b/jobs/v2/system-test/quickstart.test.js index 00fb60857a..4b8736e413 100644 --- a/jobs/v2/system-test/quickstart.test.js +++ b/jobs/v2/system-test/quickstart.test.js @@ -15,9 +15,9 @@ 'use strict'; const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {execSync} = require('child_process'); -it('should list companies', async () => { - const output = await tools.runAsync('node quickstart.js'); +it('should list companies', () => { + const output = execSync('node quickstart.js'); assert.strictEqual(output.includes('Request ID'), true); }); diff --git a/jobs/v3/system-test/auto-complete-sample.test.js b/jobs/v3/system-test/auto-complete-sample.test.js index a2e8f12577..f90369b346 100644 --- a/jobs/v3/system-test/auto-complete-sample.test.js +++ b/jobs/v3/system-test/auto-complete-sample.test.js @@ -15,10 +15,10 @@ 'use strict'; const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {execSync} = require('child_process'); -it('should auto complete job titles within given companyName', async () => { - const output = await tools.runAsync('node auto-complete-sample.js'); +it('should auto complete job titles within given companyName', () => { + const output = execSync('node auto-complete-sample.js'); const pattern = '.*completionResults.*"suggestion":"Google","type":"COMPANY_NAME"}.*\n' + '.*completionResults.*"suggestion":"Software Engineer","type":"JOB_TITLE".*\n' + diff --git a/jobs/v3/system-test/basic-company-sample.test.js b/jobs/v3/system-test/basic-company-sample.test.js index e5e3411307..b5c0d62082 100644 --- a/jobs/v3/system-test/basic-company-sample.test.js +++ b/jobs/v3/system-test/basic-company-sample.test.js @@ -15,11 +15,11 @@ 'use strict'; const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {execSync} = require('child_process'); const runSample = `require('./basic-company-sample').runSample()`; -it('Should create a company, get a company, update a company, update a company with field mask and delete a company', async () => { - const output = await tools.runAsync(`node -e ${runSample}`); +it('Should create a company, get a company, update a company, update a company with field mask and delete a company', () => { + const output = execSync(`node -e ${runSample}`); const pattern = '.*Company generated:.*\n' + '.*Company created:.*\n' + diff --git a/jobs/v3/system-test/basic-job-sample.test.js b/jobs/v3/system-test/basic-job-sample.test.js index 21eeefcd06..c13aea0ba8 100644 --- a/jobs/v3/system-test/basic-job-sample.test.js +++ b/jobs/v3/system-test/basic-job-sample.test.js @@ -15,11 +15,11 @@ 'use strict'; const assert = require(`assert`); -const tools = require(`@google-cloud/nodejs-repo-tools`); +const {execSync} = require('child_process'); const runSample = `require('./basic-job-sample').runSample()`; -it(`Should create a job, get a job, update a job, update a job with field mask, and delete a job`, async () => { - const output = await tools.runAsync(`node -e ${runSample}`); +it(`Should create a job, get a job, update a job, update a job with field mask, and delete a job`, () => { + const output = execSync(`node -e ${runSample}`); const pattern = `.*Job generated:.*\n` + `.*Job created:.*\n` + diff --git a/jobs/v3/system-test/batchdelete-jobs-sample.test.js b/jobs/v3/system-test/batchdelete-jobs-sample.test.js index 93543549bc..6f8cd11b1a 100644 --- a/jobs/v3/system-test/batchdelete-jobs-sample.test.js +++ b/jobs/v3/system-test/batchdelete-jobs-sample.test.js @@ -15,11 +15,11 @@ 'use strict'; const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {execSync} = require('child_process'); const runSample = `require('./batchdelete-jobs-sample')`; -it('Should batchDelete jobs.', async () => { - const output = await tools.runAsync(`node -e ${runSample}`); +it('Should batchDelete jobs.', () => { + const output = execSync(`node -e ${runSample}`); const pattern = '.*Batch deleted.*'; assert.strictEqual(new RegExp(pattern).test(output), true); }); diff --git a/jobs/v3/system-test/commute-search-sample.test.js b/jobs/v3/system-test/commute-search-sample.test.js index 249372f61c..685ab72c2f 100644 --- a/jobs/v3/system-test/commute-search-sample.test.js +++ b/jobs/v3/system-test/commute-search-sample.test.js @@ -15,10 +15,10 @@ 'use strict'; const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {execSync} = require('child_process'); -it('should do a commute search', async () => { - const output = await tools.runAsync('node commute-search-sample.js'); +it('should do a commute search', () => { + const output = execSync('node commute-search-sample.js'); assert.strictEqual( new RegExp('.*matchingJobs.*commuteInfo.*').test(output), diff --git a/jobs/v3/system-test/custom-attribute-sample.test.js b/jobs/v3/system-test/custom-attribute-sample.test.js index a6d3fda55f..c2c2c787c9 100644 --- a/jobs/v3/system-test/custom-attribute-sample.test.js +++ b/jobs/v3/system-test/custom-attribute-sample.test.js @@ -15,11 +15,11 @@ 'use strict'; const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {execSync} = require('child_process'); const runSample = `require('./custom-attribute-sample').runSample()`; -it('should search job with custom attribute filter', async () => { - const output = await tools.runAsync(`node -e ${runSample}`); +it('should search job with custom attribute filter', () => { + const output = execSync(`node -e ${runSample}`); const pattern = '.*Job created:.*jobWithACustomAttribute.*\n' + '.*matchingJobs.*jobWithACustomAttribute.*\n' + diff --git a/jobs/v3/system-test/email-alert-search-sample.test.js b/jobs/v3/system-test/email-alert-search-sample.test.js index 3fd912c48c..353dc0b87a 100644 --- a/jobs/v3/system-test/email-alert-search-sample.test.js +++ b/jobs/v3/system-test/email-alert-search-sample.test.js @@ -15,9 +15,9 @@ 'use strict'; const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {execSync} = require('child_process'); -it('should search jobs for alerts', async () => { - const output = await tools.runAsync('node email-alert-search-sample.js'); +it('should search jobs for alerts', () => { + const output = execSync('node email-alert-search-sample.js'); assert.strictEqual(output.includes('matchingJobs'), true); }); diff --git a/jobs/v3/system-test/featured-job-search-sample.test.js b/jobs/v3/system-test/featured-job-search-sample.test.js index 490fcfce05..899bdebadf 100644 --- a/jobs/v3/system-test/featured-job-search-sample.test.js +++ b/jobs/v3/system-test/featured-job-search-sample.test.js @@ -15,9 +15,9 @@ 'use strict'; const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {execSync} = require('child_process'); -it('should search featured job', async () => { - const output = await tools.runAsync('node featured-job-search-sample.js'); +it('should search featured job', () => { + const output = execSync('node featured-job-search-sample.js'); assert.strictEqual(output.includes('matchingJobs'), true); }); diff --git a/jobs/v3/system-test/general-search-sample.test.js b/jobs/v3/system-test/general-search-sample.test.js index 447dc8eefb..0a3f5411e5 100644 --- a/jobs/v3/system-test/general-search-sample.test.js +++ b/jobs/v3/system-test/general-search-sample.test.js @@ -15,10 +15,10 @@ 'use strict'; const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {execSync} = require('child_process'); -it('should do a general search', async () => { - const output = await tools.runAsync('node general-search-sample.js'); +it('should do a general search', () => { + const output = execSync('node general-search-sample.js'); const pattern = '.*matchingJobs.*\n' + diff --git a/jobs/v3/system-test/histogram-sample.test.js b/jobs/v3/system-test/histogram-sample.test.js index d7f153ce44..d70f8ed990 100644 --- a/jobs/v3/system-test/histogram-sample.test.js +++ b/jobs/v3/system-test/histogram-sample.test.js @@ -15,10 +15,10 @@ 'use strict'; const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {execSync} = require('child_process'); -it('should do a histogram search', async () => { - const output = await tools.runAsync('node histogram-sample.js'); +it('should do a histogram search', () => { + const output = execSync('node histogram-sample.js'); assert.strictEqual(output.includes('COMPANY_ID'), true); assert.strictEqual(output.includes('someFieldName1'), true); diff --git a/jobs/v3/system-test/location-search-sample.test.js b/jobs/v3/system-test/location-search-sample.test.js index dcfded388c..5aab8cdda7 100644 --- a/jobs/v3/system-test/location-search-sample.test.js +++ b/jobs/v3/system-test/location-search-sample.test.js @@ -15,10 +15,10 @@ 'use strict'; const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {execSync} = require('child_process'); -it('should do a search with location filters', async () => { - const output = await tools.runAsync('node location-search-sample.js'); +it('should do a search with location filters', () => { + const output = execSync('node location-search-sample.js'); const pattern = '.*matchingJobs.*locationFilters.*\n' + diff --git a/jobs/v3/system-test/quickstart.test.js b/jobs/v3/system-test/quickstart.test.js index 00fb60857a..4b8736e413 100644 --- a/jobs/v3/system-test/quickstart.test.js +++ b/jobs/v3/system-test/quickstart.test.js @@ -15,9 +15,9 @@ 'use strict'; const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {execSync} = require('child_process'); -it('should list companies', async () => { - const output = await tools.runAsync('node quickstart.js'); +it('should list companies', () => { + const output = execSync('node quickstart.js'); assert.strictEqual(output.includes('Request ID'), true); }); diff --git a/opencensus/system-test/metrics-quickstart.test.js b/opencensus/system-test/metrics-quickstart.test.js index 4db8cab3f5..e706d163f9 100644 --- a/opencensus/system-test/metrics-quickstart.test.js +++ b/opencensus/system-test/metrics-quickstart.test.js @@ -15,13 +15,13 @@ 'use strict'; const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const childProcess = require('child_process'); it('Should throw an error without projectId', async () => { process.env.GOOGLE_PROJECT_ID = ''; try { - await tools.runAsync('node metrics-quickstart.js'); + await childProcess.execSync('node metrics-quickstart.js'); assert.fail('Did not throw an error.'); } catch (err) { assert.ok(err.message.includes('Unable to proceed without a Project ID')); @@ -33,7 +33,7 @@ it('Should capture stats data and export it to backend', async () => { process.env.KUBERNETES_SERVICE_HOST = 'localhost'; process.env.EXPORT_INTERVAL = 1; - const output = await tools.runAsync('node metrics-quickstart.js'); + const output = await childProcess.execSync('node metrics-quickstart.js'); assert.ok(new RegExp('Latency *:*').test(output)); assert.ok(output.includes('Done recording metrics.')); });