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

test: end-to-end system test #471

Merged
merged 7 commits into from Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -12,4 +12,6 @@ build
.vscode
package-lock.json
.system-test-run/
.kitchen-sink/
__pycache__
doc/
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -29,6 +29,7 @@
"@types/lodash.at": "^4.6.4",
"@types/lodash.has": "^4.5.4",
"@types/mocha": "^5.2.1",
"@types/ncp": "^2.0.1",
"@types/node": "^10.3.2",
"@types/proxyquire": "^1.3.28",
"@types/pumpify": "^1.4.1",
Expand All @@ -48,6 +49,7 @@
"intelli-espower-loader": "^1.0.1",
"linkinator": "^1.1.2",
"mocha": "^6.1.0",
"ncp": "^2.0.0",
"nyc": "^13.1.0",
"pegjs": "~0.10.0",
"prettier": "^1.15.2",
Expand All @@ -72,7 +74,7 @@
"fix": "gts fix && eslint --fix samples/*.js samples/**/*.js",
"prepare": "npm run compile",
"posttest": "npm run lint",
"system-test": "nyc mocha build/system-test --timeout 120000",
"system-test": "nyc mocha build/system-test/test.*.js --timeout 120000",
"samples-test": "echo no sample tests 😱",
"docs-test": "linkinator docs -r --skip www.googleapis.com",
"predocs-test": "npm run docs"
Expand Down
@@ -0,0 +1,3 @@
node_modules/*
samples/node_modules/*
src/**/doc/*
14 changes: 14 additions & 0 deletions system-test/fixtures/google-gax-packaging-test-app/.eslintrc.yml
@@ -0,0 +1,14 @@
---
extends:
- 'eslint:recommended'
- 'plugin:node/recommended'
- prettier
plugins:
- node
- prettier
rules:
prettier/prettier: error
block-scoped-var: error
eqeqeq: error
no-warning-comments: warn
no-console: off
@@ -0,0 +1,3 @@
node_modules/*
samples/node_modules/*
src/**/doc/*
@@ -0,0 +1,8 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are the two prettier configs in this PR different?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad! Fixed.

bracketSpacing: false
printWidth: 80
semi: true
singleQuote: true
tabWidth: 2
trailingComma: es5
useTabs: false
19 changes: 19 additions & 0 deletions system-test/fixtures/google-gax-packaging-test-app/README.md
@@ -0,0 +1,19 @@
# Test application for google-gax

This test application is based on GAPIC Showcase API Client (automatically
generated by [gapic-generator](https://github.com/googleapis/gapic-generator).

[GAPIC Showcase](https://github.com/googleapis/gapic-showcase) Echo service is
the sample GAPIC service that shows all the features of generated API clients:

- retries
- timeouts
- long running operations
- client streaming
- server streaming
- bi-directional streaming
- automatic pagination

Since all these features are supported by GAX, the Showcase library is a great
use case for these features.

39 changes: 39 additions & 0 deletions system-test/fixtures/google-gax-packaging-test-app/package.json
@@ -0,0 +1,39 @@
{
"name": "google-gax-packaging-test-app",
"version": "0.0.1",
"description": "Test application for google-gax",
"main": "src/index.js",
"files": [
"src",
"protos"
],
"license": "Apache-2.0",
"keywords": [],
"scripts": {
"lint": "eslint src/ samples/ system-test/ test/",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For both of these, I've had a lot better luck just doing eslint '**/*.js'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

"prettier": "prettier --write src/*.js src/*/*.js samples/*.js samples/*/*.js test/*.js test/*/*.js system-test/*.js system-test/*/*.js",
"start": "node src/index.js",
"test": "mocha test/*.js"
},
"devDependencies": {
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-prettier": "^3.0.1",
"gts": "^1.0.0-0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just 1.0.0 now :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not TypeScript (yet) :( It's a leftover. No need to have any kind of gts here.

"mocha": "^6.1.4",
"prettier": "^1.17.0",
"through2": "^3.0.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really question why you need through2, it is mostly the same thing as new PassThrough but with a lot less dependencies

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure I don't need it and it will be taken care of in the micro-generator but I just decided not to change anything here in the test app.

"typescript": "~3.3.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to 3.4.0 now :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... but not needed here (yet) at all, so removed.

},
"dependencies": {
"@grpc/grpc-js": "^0.3.6",
"google-gax": "file:./google-gax.tgz",
"grpc": "^1.20.0",
"lodash.merge": "^4.6.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we carefully looked at why we need lodash.merge here? Are we doing something Object.assign can't?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need lodash.merge, micro-generators will emit Object.assign. https://github.com/googleapis/gapic-generator-typescript/blob/0080e041a9488a8976c94464e2cd75c25e9e1107/src/v1alpha3/echo_client.ts#L96 Again, this is just a generated code, which I will eventually replace with TypeScript generated code (when it's ready).

"protobufjs": "^6.8.8"
},
"engines": {
"node": ">=10.0.0"
}
}
@@ -0,0 +1,4 @@
module.exports = {
singleQuote: true,
trailingComma: 'es5',
};
@@ -0,0 +1,176 @@
// Copyright 2018 Google LLC
//
// 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
//
// https://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.

syntax = "proto3";

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "google/rpc/status.proto";

package google.showcase.v1beta1;

option go_package = "github.com/googleapis/gapic-showcase/server/genproto";
option java_package = "com.google.showcase.v1beta1";
option java_multiple_files = true;

// This service is used showcase the four main types of rpcs - unary, server
// side streaming, client side streaming, and bidirectional streaming. This
// service also exposes methods that explicitly implement server delay, and
// paginated calls.
service Echo {
// This service is meant to only run locally on the port 7469 (keypad digits
// for "show").
option (google.api.default_host) = "localhost:7469";

// This method simply echos the request. This method is showcases unary rpcs.
rpc Echo(EchoRequest) returns (EchoResponse) {
option (google.api.http) = {
post: "/v1beta1/echo:echo"
body: "*"
};
}

// This method split the given content into words and will pass each word back
// through the stream. This method showcases server-side streaming rpcs.
rpc Expand(ExpandRequest) returns (stream EchoResponse) {
option (google.api.http) = {
post: "/v1beta1/echo:expand"
body: "*"
};
// TODO(landrito): change this to be `fields: ["content", "error"]` once
// github.com/dcodeIO/protobuf.js/issues/1094 has been resolved.
option (google.api.method_signature) = "content,error";
}

// This method will collect the words given to it. When the stream is closed
// by the client, this method will return the a concatenation of the strings
// passed to it. This method showcases client-side streaming rpcs.
rpc Collect(stream EchoRequest) returns (EchoResponse) {
option (google.api.http) = {
post: "/v1beta1/echo:collect"
body: "*"
};
}

// This method, upon receiving a request on the stream, the same content will
// be passed back on the stream. This method showcases bidirectional
// streaming rpcs.
rpc Chat(stream EchoRequest) returns (stream EchoResponse);

// This is similar to the Expand method but instead of returning a stream of
// expanded words, this method returns a paged list of expanded words.
rpc PagedExpand(PagedExpandRequest) returns (PagedExpandResponse) {
option (google.api.http) = {
post: "/v1beta1/echo:pagedExpand"
body: "*"
};
}

// This method will wait the requested amount of and then return.
// This method showcases how a client handles a request timing out.
rpc Wait(WaitRequest) returns (google.longrunning.Operation) {
option (google.api.http) = {
post: "/v1beta1/echo:wait"
body: "*"
};
option (google.longrunning.operation_info) = {
response_type: "WaitResponse"
metadata_type: "WaitMetadata"
};
}
}

// The request message used for the Echo, Collect and Chat methods. If content
// is set in this message then the request will succeed. If a status is
message EchoRequest {
oneof response {
// The content to be echoed by the server.
string content = 1;

// The error to be thrown by the server.
google.rpc.Status error = 2;
}
}

// The response message for the Echo methods.
message EchoResponse {
// The content specified in the request.
string content = 1;
}

// The request message for the Expand method.
message ExpandRequest {
// The content that will be split into words and returned on the stream.
string content = 1;

// The error that is thrown after all words are sent on the stream.
google.rpc.Status error = 2;
}

// The request for the PagedExpand method.
message PagedExpandRequest {
// The string to expand.
string content = 1 [(google.api.field_behavior) = REQUIRED];

// The amount of words to returned in each page.
int32 page_size = 2;

// The position of the page to be returned.
string page_token = 3;
}

// The response for the PagedExpand method.
message PagedExpandResponse {
// The words that were expanded.
repeated EchoResponse responses = 1;

// The next page token.
string next_page_token = 2;
}

// The request for Wait method.
message WaitRequest {
oneof end {
// The time that this operation will complete.
google.protobuf.Timestamp end_time = 1;

// The duration of this operation.
google.protobuf.Duration ttl = 4;
}

oneof response {
// The error that will be returned by the server. If this code is specified
// to be the OK rpc code, an empty response will be returned.
google.rpc.Status error = 2;

// The response to be returned on operation completion.
WaitResponse success = 3;
}
}

// The result of the Wait operation.
message WaitResponse {
// This content of the result.
string content = 1;
}

// The metadata for Wait operation.
message WaitMetadata {
// The time that this operation will complete.
google.protobuf.Timestamp end_time =1;
}