Skip to content

Commit

Permalink
Merge branch 'master' into tag-ex-comments-row
Browse files Browse the repository at this point in the history
  • Loading branch information
sduskis authored Sep 28, 2018
2 parents cdb87ab + a90315f commit daa0d4e
Show file tree
Hide file tree
Showing 44 changed files with 1,418 additions and 1,292 deletions.
20 changes: 0 additions & 20 deletions .appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .circleci/npm-install-retry.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let spawn = require('child_process').spawn;
//USE: ./index.js <ms npm can be idle> <number of attempts> [... NPM ARGS]
//

let timeout = process.argv[2] || 60000;
let timeout = process.argv[2] || process.env.NPM_INSTALL_TIMEOUT || 60000;
let attempts = process.argv[3] || 3;
let args = process.argv.slice(4);
if (args.length === 0) {
Expand Down
2 changes: 2 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ rules:
block-scoped-var: error
eqeqeq: error
no-warning-comments: warn
no-var: error
prefer-const: error
7 changes: 7 additions & 0 deletions .kokoro/presubmit/node8/samples-test.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Download resources for system tests (service account key, etc.)
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs"

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/nodejs-bigtable/.kokoro/samples-test.sh"
}
7 changes: 7 additions & 0 deletions .kokoro/presubmit/node8/system-test.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Download resources for system tests (service account key, etc.)
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs"

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/nodejs-bigtable/.kokoro/system-test.sh"
}
7 changes: 7 additions & 0 deletions .kokoro/samples-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ export GCLOUD_PROJECT=long-door-651

cd $(dirname $0)/..

# Run a pre-test hook, if a pre-samples-test.sh is in the project
if [ -f .kokoro/pre-samples-test.sh ]; then
set +x
. .kokoro/pre-samples-test.sh
set -x
fi

npm install

# Install and link samples
Expand Down
2 changes: 2 additions & 0 deletions .kokoro/system-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ cd $(dirname $0)/..

# Run a pre-test hook, if a pre-system-test.sh is in the project
if [ -f .kokoro/pre-system-test.sh ]; then
set +x
. .kokoro/pre-system-test.sh
set -x
fi

npm install
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@
"lint": "eslint src/ samples/ system-test/ test/",
"prettier": "prettier --write src/*.js src/*/*.js samples/*.js samples/*/*.js test/*.js test/*/*.js system-test/*.js system-test/*/*.js",
"system-test": "mocha system-test/*.js --timeout 600000",
"snippet-test": "mocha samples/document-snippets/tests/*.js --timeout 600000"
"snippet-test": "mocha samples/document-snippets/tests/*.js --timeout 600000",
"fix": "eslint --fix '**/*.js' && npm run prettier"
},
"dependencies": {
"@google-cloud/common-grpc": "^0.8.0",
"@google-cloud/common-grpc": "^0.9.0",
"@google-cloud/paginator": "^0.1.0",
"@google-cloud/projectify": "^0.3.0",
"@google-cloud/promisify": "^0.3.0",
Expand Down
6 changes: 3 additions & 3 deletions samples/document-snippets/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const snippets = {
instance
.create(options)
.then(result => {
let newInstance = result[0];
const newInstance = result[0];
// let operations = result[1];
// let apiResponse = result[2];

Expand Down Expand Up @@ -269,7 +269,7 @@ const snippets = {
.getTables(options)
.then(result => {
console.log(`Tables:`);
let tables = result[0];
const tables = result[0];
tables.forEach(t => {
console.log(t.id);
});
Expand All @@ -286,7 +286,7 @@ const snippets = {
const instance = bigtable.instance(instanceId);

// [START bigtable_set_meta_data]
let metadata = {
const metadata = {
displayName: 'updated-name',
};

Expand Down
120 changes: 120 additions & 0 deletions samples/document-snippets/tests/instance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/**
* Copyright 2016 Google Inc. All Rights Reserved.
*
* 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
*
* http://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.
*/

'use strict';
const assert = require('assert');
const uuid = require(`uuid`);

const Bigtable = require(`@google-cloud/bigtable`);
const bigtable = new Bigtable();

const INSTANCE_ID = `nodejs-bigtable-samples-${uuid.v4()}`.substr(0, 30); // Bigtable naming rules
const CLUSTER_ID = `nodejs-bigtable-samples-${uuid.v4()}`.substr(0, 30); // Bigtable naming rules
// const APP_PROFILE_ID = `nodejs-bigtable-samples-${uuid.v4()}`.substr(0, 30); // Bigtable naming rules
const TABLE_ID = `nodejs-bigtable-samples-${uuid.v4()}`.substr(0, 30); // Bigtable naming rules

const instanceSnippets = require('../instance.js');

describe('Instance Snippets', function() {
after(function(done) {
const instance = bigtable.instance(INSTANCE_ID);
instance.delete(done);
});

it('should create an instance', function(done) {
instanceSnippets.createInstance(INSTANCE_ID, CLUSTER_ID, err => {
assert.ifError(err);
done();
});
});

// it('should create cluster', function(done) {
// instanceSnippets.createCluster(INSTANCE_ID, CLUSTER_ID, function(err, instance) {
// assert.ifError(err);
// done();
// });
// });

// it('should create an app-profile', function(done) {
// instanceSnippets.createAppProfile(INSTANCE_ID, APP_PROFILE_ID, function(err, appProfile) {
// assert.ifError(err);
// done();
// });
// });

it('should create table', function(done) {
instanceSnippets.createTable(INSTANCE_ID, TABLE_ID, err => {
assert.ifError(err);
done();
});
});

it('should check instance existance', function(done) {
instanceSnippets.existsInstance(INSTANCE_ID, err => {
assert.ifError(err);
done();
});
});

it('should get instance', function(done) {
instanceSnippets.getInstance(INSTANCE_ID, err => {
assert.ifError(err);
done();
});
});

it('should get Clusters', function(done) {
instanceSnippets.getClusters(INSTANCE_ID, err => {
assert.ifError(err);
done();
});
});

// it('should get appProfiles', function(done) {
// instanceSnippets.getAppProfiles(INSTANCE_ID, err => {
// assert.ifError(err);
// done();
// });
// });

it('should get MetaData', function(done) {
instanceSnippets.getMetaData(INSTANCE_ID, err => {
assert.ifError(err);
done();
});
});

it('should get tables', function(done) {
instanceSnippets.getTables(INSTANCE_ID, err => {
assert.ifError(err);
done();
});
});

it('should update instance', function(done) {
instanceSnippets.updateInstance(INSTANCE_ID, err => {
assert.ifError(err);
done();
});
});

it('should delete instance', function(done) {
instanceSnippets.delInstance(INSTANCE_ID, err => {
assert.ifError(err);
done();
});
});
});
4 changes: 2 additions & 2 deletions samples/hello-world/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (!GCLOUD_PROJECT) {
throw new Error('Environment variables GCLOUD_PROJECT must be set!');
}

var bigtableOptions = {
const bigtableOptions = {
projectId: GCLOUD_PROJECT,
};

Expand Down Expand Up @@ -83,7 +83,7 @@ const getRowGreeting = row => {
];

console.log('Reading a single row by row key');
let [singeRow] = await table.row('greeting0').get({filter});
const [singeRow] = await table.row('greeting0').get({filter});
console.log(`\tRead: ${getRowGreeting(singeRow)}`);

console.log('Reading the entire table');
Expand Down
4 changes: 2 additions & 2 deletions samples/hello-world/index.v6.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (!GCLOUD_PROJECT) {
throw new Error('Environment variables GCLOUD_PROJECT must be set!');
}

var bigtableOptions = {
const bigtableOptions = {
projectId: GCLOUD_PROJECT,
};

Expand Down Expand Up @@ -87,7 +87,7 @@ co(function*() {
];

console.log('Reading a single row by row key');
let [singeRow] = yield table.row('greeting0').get({filter});
const [singeRow] = yield table.row('greeting0').get({filter});
console.log(`\tRead: ${getRowGreeting(singeRow)}`);

console.log('Reading the entire table');
Expand Down
4 changes: 2 additions & 2 deletions samples/instances.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (!GCLOUD_PROJECT) {
throw new Error('Environment variables GCLOUD_PROJECT must be set!');
}

var bigtableOptions = {
const bigtableOptions = {
projectId: GCLOUD_PROJECT,
};

Expand Down Expand Up @@ -142,7 +142,7 @@ async function createDevInstance(instanceID, clusterID) {

// Create development instance with given options
try {
let [instance] = await bigtable.createInstance(instanceID, options);
const [instance] = await bigtable.createInstance(instanceID, options);
console.log(`Created development instance: ${instance.id}`);
} catch (err) {
console.error('Error creating dev-instance:', err);
Expand Down
4 changes: 2 additions & 2 deletions samples/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (!GCLOUD_PROJECT) {

(async () => {
try {
var bigtableOptions = {
const bigtableOptions = {
projectId: GCLOUD_PROJECT,
};

Expand All @@ -46,7 +46,7 @@ if (!GCLOUD_PROJECT) {
const table = instance.table(TABLE_ID);

// Read a row from my-table using a row key
let [singleRow] = await table.row('r1').get();
const [singleRow] = await table.row('r1').get();

// Print the row key and data (column value, labels, timestamp)
console.log(
Expand Down
4 changes: 2 additions & 2 deletions samples/tableadmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (!GCLOUD_PROJECT) {
throw new Error('Environment variables GCLOUD_PROJECT must be set!');
}

var bigtableOptions = {
const bigtableOptions = {
projectId: GCLOUD_PROJECT,
};

Expand Down Expand Up @@ -62,7 +62,7 @@ async function runTableOperations(instanceID, tableID) {
// [START bigtable_list_tables]
// List tables in current project
try {
let [tables] = await instance.getTables();
const [tables] = await instance.getTables();
tables.forEach(table => {
console.log(table.id);
});
Expand Down
2 changes: 1 addition & 1 deletion src/app-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AppProfile {
this.bigtable = instance.bigtable;
this.instance = instance;

var name;
let name;

if (id.includes('/')) {
if (id.startsWith(`${instance.name}/appProfiles/`)) {
Expand Down
2 changes: 1 addition & 1 deletion src/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Cluster {
this.bigtable = instance.bigtable;
this.instance = instance;

var name;
let name;

if (id.includes('/')) {
if (id.startsWith(`${instance.name}/clusters/`)) {
Expand Down
2 changes: 1 addition & 1 deletion src/family.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Family {
this.bigtable = table.bigtable;
this.table = table;

var name;
let name;
if (id.includes('/')) {
if (id.startsWith(`${table.name}/columnFamilies/`)) {
name = id;
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,14 @@ class Bigtable {

// Determine what scopes are needed.
// It is the union of the scopes on all three clients.
let scopes = [];
let clientClasses = [
const scopes = [];
const clientClasses = [
v2.BigtableClient,
v2.BigtableInstanceAdminClient,
v2.BigtableTableAdminClient,
];
for (let clientClass of clientClasses) {
for (let scope of clientClass.scopes) {
for (const clientClass of clientClasses) {
for (const scope of clientClass.scopes) {
if (!scopes.includes(scope)) {
scopes.push(scope);
}
Expand Down
2 changes: 1 addition & 1 deletion src/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Instance {
constructor(bigtable, id) {
this.bigtable = bigtable;

var name;
let name;
if (id.includes('/')) {
if (id.startsWith(`${bigtable.projectName}/instances/`)) {
name = id;
Expand Down
Loading

0 comments on commit daa0d4e

Please sign in to comment.