Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set timeout conformance test #1385

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .kokoro/conformance.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"pretest": "npm run compile",
"test": "c8 mocha build/test",
"test:snap": "SNAPSHOT_UPDATE=1 npm test",
"testproxy": "npm run compile && node testproxy/index.js",
"testproxy": "npm run compile && GRPC_TRACE=all GRPC_VERBOSITY=DEBUG node testproxy/index.js",
"clean": "gts clean",
"precompile": "gts clean"
},
Expand Down
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -866,9 +866,18 @@

gaxStream = requestFn!();
gaxStream
.on('error', stream.destroy.bind(stream))
.on('error', (err: ServiceError) => {

Check warning on line 869 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint

'err' is defined but never used
console.log('getting error');
stream.destroy.bind(stream);
})
.on('metadata', stream.emit.bind(stream, 'metadata'))
.on('request', stream.emit.bind(stream, 'request'))
.on('end', () => {
console.log('gax stream ended');
})
.on('data', (err: ServiceError) => {

Check warning on line 878 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint

'err' is defined but never used
console.log('received data from gax stream');
})
.pipe(stream);
});
}
Expand All @@ -882,6 +891,7 @@
gaxStream = requestFn!();
gaxStream
.on('error', (err: Error) => {
console.log('getting error 2');
stream.destroy(err);
})
.on('metadata', metadata => {
Expand Down
12 changes: 9 additions & 3 deletions src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@
// Handling retries in this client. Specify the retry options to
// make sure nothing is retried in retry-request.
noResponseRetries: 0,
shouldRetryFn: (_: any) => {

Check warning on line 813 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

'_' is defined but never used

Check warning on line 813 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
return false;
},
};
Expand Down Expand Up @@ -969,7 +969,7 @@
userStream.emit('error', error);
}
})
.on('data', _ => {

Check warning on line 972 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

'_' is defined but never used
// Reset error count after a successful read so the backoff
// time won't keep increasing when as stream had multiple errors
numConsecutiveErrors = 0;
Expand Down Expand Up @@ -1575,6 +1575,7 @@
};

const makeNextBatchRequest = () => {
console.log('making mutate rows request');
const entryBatch = entries.filter((entry: Entry, index: number) => {
return pendingEntryIndices.has(index);
});
Expand All @@ -1597,7 +1598,7 @@
},
};

options.gaxOptions = populateAttemptHeader(
const gaxOpts = populateAttemptHeader(
numRequestsMade,
options.gaxOptions
);
Expand All @@ -1607,13 +1608,15 @@
client: 'BigtableClient',
method: 'mutateRows',
reqOpts,
gaxOpts: options.gaxOptions,
gaxOpts,
retryOpts,
})
.on('error', (err: ServiceError) => {
console.log('received an error');
onBatchResponse(err);
})
.on('data', (obj: google.bigtable.v2.IMutateRowsResponse) => {
console.log('received data');
obj.entries!.forEach(entry => {
const originalEntry = entryBatch[entry.index as number];
const originalEntriesIndex = entryToIndex.get(originalEntry)!;
Expand All @@ -1633,7 +1636,10 @@
mutationErrorsByEntryIndex.set(originalEntriesIndex, errorDetails);
});
})
.on('end', onBatchResponse);
.on('end', () => {
console.log('closed the stream');
onBatchResponse(null);
});
numRequestsMade++;
};

Expand Down
10 changes: 9 additions & 1 deletion testproxy/services/create-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const normalizeCallback = require('./utils/normalize-callback.js');

const grpc = require('@grpc/grpc-js');
const {Bigtable} = require('../../build/src/index.js');
const {PreciseDate} = require('@google-cloud/precise-date');
const {BigtableClient} = require('../../build/src/index.js').v2;

const v2 = Symbol.for('v2');
Expand Down Expand Up @@ -54,12 +55,19 @@ const createClient = ({clientMap}) =>
if (callCredential && callCredential.jsonServiceAccount) {
authClient = JSON.parse(request.callCredential.jsonServiceAccount);
}
const clientConfig = require('../../src/v2/bigtable_client_config.json');
clientConfig.interfaces['google.bigtable.v2.Bigtable'].methods[
'MutateRows'
].timeout_millis = parseInt(
parseInt(new PreciseDate(request.perOperationTimeout).getFullTime()) /
1000000
);
const bigtable = new Bigtable({
projectId,
apiEndpoint,
authClient,
appProfileId,
clientConfig: require('../../src/v2/bigtable_client_config.json'),
clientConfig,
});
bigtable[v2] = new BigtableClient(bigtable.options.BigtableClient);
clientMap.set(clientId, bigtable);
Expand Down
Loading