Skip to content

Commit

Permalink
get branch in sync with upstream main
Browse files Browse the repository at this point in the history
  • Loading branch information
leahecole committed May 17, 2023
1 parent 064e131 commit a804c37
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 14 deletions.
35 changes: 28 additions & 7 deletions test/showcase-echo-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"build/src",
"build/protos"
],
"types": "build/src/index.d.ts",
"keywords": [
"google apis client",
"google api client",
Expand All @@ -22,24 +21,46 @@
"cloud",
"google showcase",
"showcase",
"compliance",
"echo",
"identity",
"messaging",
"testing"
"sequence service"
],
"scripts": {
"compile": "tsc -p . && cp -r protos build/",
"compile-protos": "compileProtos src",
"docs": "jsdoc -c .jsdoc.js",
"predocs-test": "npm run docs",
"docs-test": "linkinator docs",
"fix": "gts fix",
"lint": "gts check",
"prepare": "npm run compile-protos && npm run compile",
"prefetch": "rm -rf node_modules package-lock.json google-gax*.tgz && cd ../.. && npm pack && mv google-gax*.tgz test/showcase-echo-client/google-gax.tgz",
"prepare": "npm run compile-protos && npm run compile"

"system-test": "c8 mocha build/system-test",
"test": "c8 mocha build/test"
},
"dependencies": {
"google-gax": "./google-gax.tgz"
},
"devDependencies": {
"@types/node": "^16.0.0",
"gapic-tools": "^0.1.7",
"typescript": "^4.5.5"
"@types/mocha": "^10.0.1",
"@types/node": "^18.11.18",
"@types/sinon": "^10.0.13",
"c8": "^7.13.0",
"gts": "^3.1.1",
"jsdoc": "^4.0.2",
"jsdoc-fresh": "^2.0.1",
"jsdoc-region-tag": "^2.0.1",
"linkinator": "^4.1.2",
"mocha": "^10.2.0",
"null-loader": "^4.0.1",
"pack-n-play": "^1.0.0-2",
"sinon": "^15.0.1",
"ts-loader": "^8.4.0",
"typescript": "^4.8.4",
"webpack": "^4.46.0",
"webpack-cli": "^4.10.0"
},
"engines": {
"node": ">=v14"
Expand Down
94 changes: 87 additions & 7 deletions test/test-application/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,76 @@ async function testShowcase() {
await testChatThrows(fallbackClient); // fallback does not support bidi streaming
await testWait(fallbackClient);

await testEcho(restClient);
await testExpand(restClient); // REGAPIC supports server streaming
await testPagedExpand(restClient);
await testPagedExpandAsync(restClient);
await testCollectThrows(restClient); // REGAPIC does not support client streaming
await testChatThrows(restClient); // REGAPIC does not support bidi streaming
await testWait(restClient);
// await testEcho(fallbackClient);
// await testEchoError(fallbackClient);
// await testExpandThrows(fallbackClient); // fallback does not support server streaming
// await testPagedExpand(fallbackClient);
// await testPagedExpandAsync(fallbackClient);
// await testCollectThrows(fallbackClient); // fallback does not support client streaming
// await testChatThrows(fallbackClient); // fallback does not support bidi streaming
// await testWait(fallbackClient);

// await testEcho(restClient);
// await testExpand(restClient); // REGAPIC supports server streaming
// await testPagedExpand(restClient);
// await testPagedExpandAsync(restClient);
// await testCollectThrows(restClient); // REGAPIC does not support client streaming
// await testChatThrows(restClient); // REGAPIC does not support bidi streaming
// await testWait(restClient);
}

function getStreamingSequenceRequest(){
const request = new protos.google.showcase.v1beta1.CreateStreamingSequenceRequest()

let firstDelay = new protos.google.protobuf.Duration();
firstDelay.nanos=150;

let firstStatus = new protos.google.rpc.Status();
firstStatus.code=14;
firstStatus.message="UNAVAILABLE";

let firstResponse = new protos.google.showcase.v1beta1.StreamingSequence.Response();
firstResponse.delay=firstDelay;
firstResponse.status=firstStatus;

// The Index you want the stream to fail or send the status
// This should be index + 1 so if you want to send status at index 0
// you would provide firstResponse.sendStatusAtIndex=1

firstResponse.sendStatusAtIndex=1;

let secondDelay = new protos.google.protobuf.Duration();
secondDelay.nanos=150;

let secondStatus = new protos.google.rpc.Status();
secondStatus.code= 4;
secondStatus.message="DEADLINE_EXCEEDED";

let secondResponse = new protos.google.showcase.v1beta1.StreamingSequence.Response();
secondResponse.delay=secondDelay;
secondResponse.status=secondStatus;
secondResponse.sendStatusAtIndex=2

let thirdDelay = new protos.google.protobuf.Duration();
thirdDelay.nanos=500000;

let thirdStatus = new protos.google.rpc.Status();
thirdStatus.code=0;
thirdStatus.message="OK";

let thirdResponse = new protos.google.showcase.v1beta1.StreamingSequence.Response();
thirdResponse.delay=thirdDelay;
thirdResponse.status=thirdStatus;
thirdResponse.sendStatusAtIndex=11;

let streamingSequence = new protos.google.showcase.v1beta1.StreamingSequence()
streamingSequence.responses = [firstResponse,secondResponse,thirdResponse];
// streamingSequence.responses = [];

streamingSequence.content = "This is testing the brand new and shiny StreamingSequence server 3";
request.streamingsequence = streamingSequence

return request
}

async function testEcho(client: EchoClient) {
Expand Down Expand Up @@ -245,6 +308,7 @@ async function testCollect(client: EchoClient) {
resolve(result.content ?? '');
}
});
<<<<<<< Updated upstream
for (const word of words) {
const request = {content: word};
stream.write(request);
Expand All @@ -259,6 +323,22 @@ async function testCollect(client: EchoClient) {
});
const result = await promise;
assert.strictEqual(result, words.join(' '));
=======
return attemptStream
}
let attemptStream;
//TODO(coleleah): handle this more elegantly
if (sequence.responses){
const numResponses = sequence.responses.length
console.log(numResponses);

attemptStream = await multipleSequenceAttempts(numResponses)
}else{
const numResponses = 3
attemptStream = await multipleSequenceAttempts(numResponses)

}
>>>>>>> Stashed changes
}

async function testCollectThrows(client: EchoClient) {
Expand Down

0 comments on commit a804c37

Please sign in to comment.