Skip to content

Commit

Permalink
fix: change dataproc success message and test (#269)
Browse files Browse the repository at this point in the history
* Added create cluster sample for Cloud Dataproc

* Modify test and slight change to Dataproc success message

* Changed region tag to include 'dataproc'

* changed dataproc imports to explicit v1
  • Loading branch information
bradmiro authored Nov 18, 2019
1 parent 83b858a commit 0170f9e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
14 changes: 7 additions & 7 deletions dataproc/createCluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
// Code for creating a Cloud Dataproc cluster with the Node.js Client Library

function main(projectId, region, clusterName) {
// [START create_cluster]
const dataproc = require('@google-cloud/dataproc');
// [START dataproc_create_cluster]
const dataproc = require('@google-cloud/dataproc').v1;

// Create a client with the endpoint set to the desired cluster region
const client = new dataproc.v1.ClusterControllerClient({
Expand All @@ -29,7 +29,7 @@ function main(projectId, region, clusterName) {
// region = 'YOUR_CLUSTER_REGION'
// cluster_name = 'YOUR_CLUSTER_NAME'

// Create your cluster config
// Create the cluster config
const request = {
projectId: projectId,
region: region,
Expand All @@ -48,13 +48,13 @@ function main(projectId, region, clusterName) {
},
};

// Create our cluster
// Create the cluster
const [operation] = await client.createCluster(request);
const [response] = await operation.promise();

// Output the response
console.log(response);
// [END create_cluster]
// Output a success message
console.log(`Cluster created successfully: ${response.clusterName}`);
// [END dataproc_create_cluster]
}

createCluster();
Expand Down
4 changes: 3 additions & 1 deletion dataproc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"test": "mocha system-test --timeout 600000"
},
"dependencies": {
"@google-cloud/dataproc": "^1.4.2"
"@google-cloud/dataproc": "^1.4.2",
"uuid": "^3.3.3",
"yargs": "^14.0.0"
},
"devDependencies": {
"chai": "^4.2.0",
Expand Down
4 changes: 2 additions & 2 deletions dataproc/system-test/createCluster.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const uuid = require('uuid');
const region = 'us-central1';
const clusterName = `test-${uuid()}`;

const dataproc = require('@google-cloud/dataproc');
const dataproc = require('@google-cloud/dataproc').v1;
const client = new dataproc.v1.ClusterControllerClient({
apiEndpoint: `${region}-dataproc.googleapis.com`,
});
Expand All @@ -35,7 +35,7 @@ describe('create a dataproc cluster', () => {
const stdout = execSync(
`node createCluster.js "${projectId}" "${region}" "${clusterName}"`
);
assert.match(stdout, /clusterUuid/);
assert.match(stdout, new RegExp(`${clusterName}`));
});

after(async () => {
Expand Down

0 comments on commit 0170f9e

Please sign in to comment.