diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 1cb9e4e0..93de0df4 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -36,5 +36,17 @@ jobs: - name: Build if: success() env: - BUILD_VERSION: ${{ steps.sha_short.outputs.SHA_SHORT }} + VERSION: ${{ steps.sha_short.outputs.SHA_SHORT }} run: make build + + - name: Test + if: success() + env: + CONTAINER: docker.io/namely/protoc-all:${{ steps.sha_short.outputs.SHA_SHORT }} + run: make test + + - name: Test Gateway + if: success() + env: + CONTAINER: docker.io/namely/gen-grpc-gateway:${{ steps.sha_short.outputs.SHA_SHORT }} + run: make test-gwy diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b2e100c4..a4e1b869 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -34,5 +34,17 @@ jobs: - name: Build if: success() env: - BUILD_VERSION: ${{ steps.sha_short.outputs.SHA_SHORT }} + VERSION: ${{ steps.sha_short.outputs.SHA_SHORT }} run: make build + + - name: Test + if: success() + env: + CONTAINER: docker.io/namely/protoc-all:${{ steps.sha_short.outputs.SHA_SHORT }} + run: make test + + - name: Test Gateway + if: success() + env: + CONTAINER: docker.io/namely/gen-grpc-gateway:${{ steps.sha_short.outputs.SHA_SHORT }} + run: make test-gwy diff --git a/Makefile b/Makefile index 9745c7df..109465dc 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,10 @@ build: test: bash ./all/test.sh +.PHONY: test-gwy +test-gwy: + bash ./gwy/test.sh + # Not for manual invocation. .PHONY: push push: build diff --git a/README.md b/README.md index e12889db..21b7e381 100755 --- a/README.md +++ b/README.md @@ -284,8 +284,7 @@ demonstrate that your new image can successfully build containers for each langu #### gRPC Gateway test ```sh -cd gwy -./test.sh namely/gen-grpc-gateway:VVV +CONTAINER=namely/gen-grpc-gateway:VVV make test-gwy ``` ### Release diff --git a/all/test.sh b/all/test.sh index e90558ee..b6b93d5d 100755 --- a/all/test.sh +++ b/all/test.sh @@ -1,10 +1,10 @@ -#!/bin/bash -e +#!/bin/bash -efx LANGS=("go" "ruby" "csharp" "java" "python" "objc" "node" "gogo" "php" "cpp" "descriptor_set" "web") CONTAINER=${CONTAINER} -if [ -z ${CONTAINER} ]; then +if [ -z "${CONTAINER}" ]; then echo "You must specify a build container with \${CONTAINER} to test (see my README.md)" exit 1 fi @@ -15,6 +15,8 @@ UNBOUND_METHOD="UnboundUnary" # Checks that directories were appropriately created, and deletes the generated directory. testGeneration() { + name=$1 + shift lang=$1 shift expected_output_dir=$1 @@ -22,23 +24,30 @@ testGeneration() { expectedExitCode=$1 shift extra_args=$@ - echo "Testing language $lang $expected_output_dir $extra_args" + + mkdir -p "$name" > /dev/null 2>&1 + cp -r ./all "./$name" > /dev/null 2>&1 + pushd "./$name" > /dev/null # Test calling a file directly. exitCode=0 - docker run --rm -v=`pwd`:/defs $CONTAINER -f all/test/test.proto -l $lang -i all/test/ $extra_args > /dev/null || exitCode=$? + docker run --rm -v="$PWD":/defs "$CONTAINER" -f all/test/test.proto -l "$lang" -i all/test/ $extra_args > /dev/null || exitCode=$? if [[ $expectedExitCode != $exitCode ]]; then - echo "exit code must be $expectedExitCode but is $exitCode instead" + echo >&2 "[Fail] $name" + echo >&2 "exit code must be $expectedExitCode but is $exitCode instead" exit 1 elif [[ "$expectedExitCode" != 0 ]]; then # no need to continue test of expected failure - echo "expected failure passed!" + popd > /dev/null + rm -rf "$name" > /dev/null 2>&1 + echo "[Pass] $name" return fi if [[ ! -d "$expected_output_dir" ]]; then - echo "generated directory $expected_output_dir does not exist" + echo >&2 "[Fail] $name" + echo >&2 "generated directory $expected_output_dir does not exist" exit 1 fi @@ -51,17 +60,29 @@ testGeneration() { expected_file_name="/test.pb.go" fi if [[ ! -f "$expected_output_dir$expected_file_name" ]]; then - echo "$expected_file_name file was not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 "$expected_file_name file was not generated in $expected_output_dir" exit 1 fi fi + if [[ "$lang" == "java" ]]; then + if [[ "$extra_args" == *"-o gen/test.jar" ]]; then + if [[ ! -f "gen/test.jar" ]]; then + echo >&2 "[Fail] $name" + echo >&2 "Expected gen/test.jar to be a jar file." + exit 1 + fi + fi + fi + if [[ "$lang" == "python" ]]; then # Test that we have generated the __init__.py files. current_path="$expected_output_dir" while [[ $current_path != "." ]]; do if [[ ! -f "$current_path/__init__.py" ]]; then - echo "__init__.py files were not generated in $current_path" + echo >&2 "[Fail] $name" + echo >&2 "__init__.py files were not generated in $current_path" exit 1 fi current_path=$(dirname $current_path) @@ -71,7 +92,8 @@ testGeneration() { # Test that we have generated the .d.ts files. rbi_file_count=$(find $expected_output_dir -type f -name "*.rbi" | wc -l) if [ $rbi_file_count -ne 2 ]; then - echo ".rbi files were not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 ".rbi files were not generated in $expected_output_dir" exit 1 fi fi @@ -79,7 +101,8 @@ testGeneration() { # Test that we have generated the .d.ts files. ts_file_count=$(find $expected_output_dir -type f -name "*.d.ts" | wc -l) if [ $ts_file_count -ne 2 ]; then - echo ".d.ts files were not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 ".d.ts files were not generated in $expected_output_dir" exit 1 fi fi @@ -88,7 +111,8 @@ testGeneration() { # Test that we have generated the test.pb.micro.go file. expected_file_name="/all/test.pb.micro.go" if [[ ! -f "$expected_output_dir$expected_file_name" ]]; then - echo "$expected_file_name file was not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 "$expected_file_name file was not generated in $expected_output_dir" exit 1 fi fi @@ -98,18 +122,21 @@ testGeneration() { expected_file_name1="/all/test.pb.gw.go" expected_file_name2="/all/test/test.swagger.json" if [[ ! -f "$expected_output_dir$expected_file_name1" ]]; then - echo "$expected_file_name1 file was not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 "$expected_file_name1 file was not generated in $expected_output_dir" exit 1 fi if [[ ! -f "$expected_output_dir$expected_file_name2" ]]; then - echo "$expected_file_name2 file was not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 "$expected_file_name2 file was not generated in $expected_output_dir" exit 1 fi if [[ "$extra_args" == *"--with-openapi-json-names"* ]]; then # Test that we have generated the test.swagger.json file with json params if ! grep -q $JSON_PARAM_NAME "$expected_output_dir$expected_file_name2" ; then - echo "$expected_file_name2 file was not generated with json names" + echo >&2 "[Fail] $name" + echo >&2 "$expected_file_name2 file was not generated with json names" exit 1 fi @@ -118,27 +145,31 @@ testGeneration() { expected_field_mask_property_type="array" actual_field_mask_property_type=$(cat $expected_output_dir$expected_file_name2 | jq '.definitions.MessagesUpdateMessageRequest.properties.updateMask.type' | tr -d "\042") if [ ! "$actual_field_mask_property_type" == "$expected_field_mask_property_type" ]; then - echo "expected field mask type not found ($actual_field_mask_property_type != $expected_field_mask_property_type)" + echo >&2 "[Fail] $name" + echo >&2 "expected field mask type not found ($actual_field_mask_property_type != $expected_field_mask_property_type)" exit 1 fi elif [[ "$extra_args" == *"--with-swagger-json-names"* ]]; then # Test that we have generated the test.swagger.json file with json params if ! grep -q $JSON_PARAM_NAME "$expected_output_dir$expected_file_name2" ; then - echo "$expected_file_name2 file was not generated with json names" + echo >&2 "[Fail] $name" + echo >&2 "$expected_file_name2 file was not generated with json names" exit 1 fi elif [[ "$extra_args" == *"--generate-unbound-methods"* ]]; then # Test that we have mapped the unbound method if ! grep -q $UNBOUND_METHOD "$expected_output_dir$expected_file_name1" ; then - echo "$expected_file_name1 does not contain the expected method $UNBOUND_METHOD" + echo >&2 "[Fail] $name" + echo >&2 "$expected_file_name1 does not contain the expected method $UNBOUND_METHOD" exit 1 fi else # No extra arguments # Test that we haven't mapped the unbound method if grep -q $UNBOUND_METHOD "$expected_output_dir$expected_file_name1" ; then - echo "$expected_file_name1 should not contain the unexpected method $UNBOUND_METHOD" + echo >&2 "[Fail] $name" + echo >&2 "$expected_file_name1 should not contain the unexpected method $UNBOUND_METHOD" exit 1 fi fi @@ -150,7 +181,8 @@ testGeneration() { expected_file_name="/doc/index.md" fi if [[ ! -f "$expected_output_dir$expected_file_name" ]]; then - echo "$expected_file_name file was not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 "$expected_file_name file was not generated in $expected_output_dir" exit 1 fi fi @@ -164,11 +196,13 @@ testGeneration() { expected_file_name2="/all/test/test.pb.validate.go" fi if [[ ! -f "$expected_output_dir$expected_file_name1" ]]; then - echo "$expected_file_name1 file was not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 "$expected_file_name1 file was not generated in $expected_output_dir" exit 1 fi if [[ ! -f "$expected_output_dir$expected_file_name2" ]]; then - echo "$expected_file_name2 file was not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 "$expected_file_name2 file was not generated in $expected_output_dir" exit 1 fi fi @@ -180,11 +214,13 @@ testGeneration() { expected_file_name2="/all/test/test.pb.validate.go" fi if [[ ! -f "$expected_output_dir$expected_file_name1" ]]; then - echo "$expected_file_name1 file was not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 "$expected_file_name1 file was not generated in $expected_output_dir" exit 1 fi if [[ ! -f "$expected_output_dir$expected_file_name2" ]]; then - echo "$expected_file_name2 file was not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 "$expected_file_name2 file was not generated in $expected_output_dir" exit 1 fi fi @@ -193,7 +229,8 @@ testGeneration() { # Test that we have generated the testlib.js file testlib_count=$(find $expected_output_dir -type f -name "testlib.js" | wc -l) if [ $testlib_count -ne 1 ]; then - echo "testlib.js file was not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 "testlib.js file was not generated in $expected_output_dir" exit 1 fi fi @@ -202,7 +239,8 @@ testGeneration() { # Test that we have generated the .d.ts files and .js files js_file_count=$(find $expected_output_dir -type f -name "*.js" | wc -l) if [ $js_file_count -ne 2 ]; then - echo ".js files were not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 ".js files were not generated in $expected_output_dir" exit 1 fi fi @@ -211,12 +249,14 @@ testGeneration() { # Test that we have generated the .d.ts files and .js files ts_file_count=$(find $expected_output_dir -type f -name "*.d.ts" | wc -l) if [ $ts_file_count -ne 2 ]; then - echo ".d.ts files were not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 ".d.ts files were not generated in $expected_output_dir" exit 1 fi js_file_count=$(find $expected_output_dir -type f -name "*.js" | wc -l) if [ $js_file_count -ne 2 ]; then - echo ".js files were not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 ".js files were not generated in $expected_output_dir" exit 1 fi fi @@ -224,81 +264,88 @@ testGeneration() { # Test that we have generated the .d.ts files, .ts files and .js files d_ts_file_count=$(find $expected_output_dir -type f -name "*.d.ts" | wc -l) if [ $d_ts_file_count -ne 1 ]; then - echo ".d.ts files were not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 ".d.ts files were not generated in $expected_output_dir" exit 1 fi ts_file_count=$(find $expected_output_dir -type f -name "*Pb.ts" | wc -l) if [ $ts_file_count -ne 1 ]; then - echo ".ts files were not generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 ".ts files were not generated in $expected_output_dir" exit 1 fi js_file_count=$(find $expected_output_dir -type f -name "*.js" | wc -l) if [ $js_file_count -ne 1 ]; then - echo "More than 1 .js file was generated in $expected_output_dir" + echo >&2 "[Fail] $name" + echo >&2 "More than 1 .js file was generated in $expected_output_dir" exit 1 fi fi - rm -rf `echo $expected_output_dir | cut -d '/' -f1` - echo "Generating for $lang passed!" + popd > /dev/null + rm -rf "$name" > /dev/null 2>&1 + echo "[Pass] $name" } # Test docs generation -testGeneration go "gen/pb-go" 0 --with-docs -testGeneration go "gen/pb-go" 0 --with-docs markdown,index.md +testGeneration "go_with_docs" go "gen/pb-go" 0 --with-docs +testGeneration "go_with_markdown_docs" go "gen/pb-go" 0 --with-docs markdown,index.md # Test grpc-gateway generation (only valid for Go) -testGeneration go "gen/pb-go" 0 --with-gateway +testGeneration "go_with_gateway" go "gen/pb-go" 0 --with-gateway # Test grpc-gateway generation + json (only valid for Go) -testGeneration go "gen/pb-go" 0 --with-gateway --with-openapi-json-names +testGeneration "go_with_gateway_and_openapi_json" go "gen/pb-go" 0 --with-gateway --with-openapi-json-names # Test grpc-gateway generation + json (deprecated) (only valid for Go) -testGeneration go "gen/pb-go" 0 --with-gateway --with-swagger-json-names +testGeneration "go_with_gateway_and_swagger_json" go "gen/pb-go" 0 --with-gateway --with-swagger-json-names # Test grpc-gateway generation with unbound methods (only valid for Go) -testGeneration go "gen/pb-go" 0 --with-gateway --generate-unbound-methods +testGeneration "go_with_unbound_methods" go "gen/pb-go" 0 --with-gateway --generate-unbound-methods # Test go source relative generation -testGeneration go "gen/pb-go" 0 --go-source-relative +testGeneration "go_with_source_relative" go "gen/pb-go" 0 --go-source-relative # Test go module prefix -testGeneration go "gen/pb-go" 0 --go-module-prefix all +testGeneration "go_with_module_prefixes" go "gen/pb-go" 0 --go-module-prefix all # Test expected failure for source relative and module prefix combination -testGeneration go "gen/pb-go" 1 --go-module-prefix all --go-source-relative -testGeneration go "gen/pb-go" 1 --go-source-relative --go-module-prefix all +testGeneration "go_with_module_prefixes_and_source_relative" go "gen/pb-go" 1 --go-module-prefix all --go-source-relative +testGeneration "go_with_module_prefixes_and_source_relative_swapped_args" go "gen/pb-go" 1 --go-source-relative --go-module-prefix all # Test go validator -testGeneration go "gen/pb-go" 0 --with-validator +testGeneration "go_with_validator" go "gen/pb-go" 0 --with-validator # Test go validator with source relative option -testGeneration go "gen/pb-go" 0 --with-validator --validator-source-relative +testGeneration "go_with_validator_and_source_relative" go "gen/pb-go" 0 --with-validator --validator-source-relative # Test the other go validator -testGeneration go "gen/pb-go" 0 --go-proto-validator +testGeneration "go_with_proto_validator" go "gen/pb-go" 0 --go-proto-validator # Test the other go validator with source relative option -testGeneration go "gen/pb-go" 0 ---go-proto-validator --validator-source-relative +testGeneration "go_with_proto_validator_and_source_relative" go "gen/pb-go" 0 ---go-proto-validator --validator-source-relative # Test go-micro generations -testGeneration go "gen/pb-go" 0 --go-plugin-micro +testGeneration "go_micro" go "gen/pb-go" 0 --go-plugin-micro # Test Sorbet RBI declaration file generation (only valid for Ruby) -testGeneration ruby "gen/pb-ruby" 0 --with-rbi +testGeneration "ruby_rbi" ruby "gen/pb-ruby" 0 --with-rbi # Test TypeScript declaration file generation (only valid for Node) -testGeneration node "gen/pb-node" 0 --with-typescript +testGeneration "node_with_typescript" node "gen/pb-node" 0 --with-typescript # Test node alternative import style (only valid for node and web) -testGeneration node "gen/pb-node" 0 --js-out library=testlib +testGeneration "node_with_alternative_imports" node "gen/pb-node" 0 --js-out library=testlib # Test node grpc-out alternative import style (only valid for node and web) -testGeneration node "gen/pb-node" 0 --grpc-out grpc-js +testGeneration "node_with_grpc_out" node "gen/pb-node" 0 --grpc-out grpc-js # Test grpc web alternative import style (only valid for web) -testGeneration web "gen/pb-web" 0 --grpc-web-out import_style=typescript -testGeneration web "gen/pb-web" 0 --grpc-web-out import_style=commonjs+dts +testGeneration "web_with_typescript_imports" web "gen/pb-web" 0 --grpc-web-out import_style=typescript +testGeneration "web_with_commonjs_imports" web "gen/pb-web" 0 --grpc-web-out import_style=commonjs+dts + +# Test java output +testGeneration "java_test_jar" java "gen" 0 -o gen/test.jar # Generate proto files for lang in ${LANGS[@]}; do @@ -310,18 +357,9 @@ for lang in ${LANGS[@]}; do fi # Test without an output directory. - testGeneration "$lang" "$expected_output_dir" 0 + testGeneration "$lang" "$lang" "$expected_output_dir" 0 # Test with an output directory. test_dir="gen/foo/bar" - testGeneration "$lang" "$test_dir" 0 -o "$test_dir" + testGeneration "${lang}_with_output_dir" "$lang" "$test_dir" 0 -o "$test_dir" done - - -# Test .jar generation for java -docker run --rm -v=`pwd`:/defs $CONTAINER -f all/test/test.proto -l java -i all/test/ -o gen/test.jar -if [[ ! -f gen/test.jar ]]; then - echo "Expected gen/test.jar to be a jar file." - exit 1 -fi -rm -rf gen diff --git a/gwy/templates/go.mod.tmpl b/gwy/templates/go.mod.tmpl index 22eb961a..0b0f4a4c 100644 --- a/gwy/templates/go.mod.tmpl +++ b/gwy/templates/go.mod.tmpl @@ -9,6 +9,6 @@ require ( github.com/sirupsen/logrus v1.7.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.7.1 - google.golang.org/grpc v1.42.0 + google.golang.org/grpc v1.43.0 google.golang.org/protobuf v1.27.1 ) diff --git a/gwy/test.sh b/gwy/test.sh index 655b3dc2..24d0f7c4 100755 --- a/gwy/test.sh +++ b/gwy/test.sh @@ -1,19 +1,19 @@ -#!/bin/bash -set -e -set -x +#!/bin/bash -ex -if [[ $# -ne 1 ]]; then - echo "Usage: test.sh container" - exit 1 -fi +CONTAINER=${CONTAINER} +if [ -z "${CONTAINER}" ]; then + echo "You must specify a build container with \${CONTAINER} to test (see my README.md)" + exit 1 +fi -CONTAINER=$1 HEADERS_FILE="./.headers" SOME_RESP_HEADER="SOME-RESPONSE-HEADER" +pushd "gwy" + # Test building the gateway. -docker run --rm -v=`pwd`:/defs $CONTAINER -f test/test.proto -i . -s Message +docker run --rm -v="$PWD":/defs "$CONTAINER" -f /defs/test/test.proto -i /defs -s Message # And make sure that we can build the test gateway too. docker build -t $CONTAINER-test-gateway gen/grpc-gateway/ @@ -32,44 +32,54 @@ status=`curl -i -s -o $HEADERS_FILE -w "%{http_code}" localhost:8080/api/message # running. In the future, if this was a real backend we should get a 200. However, # here we can use the 503 to indicate that the gateway tried to send the request # downstream. +echo "" if [ "$status" -ne "503" ]; then kill $! - echo "Invalid status: '$status' with /api/messages http request" + echo >&2 "[Fail] - Received expected response from gateway when no backend service running" + echo >&2 "Invalid status: '$status' with /api/messages http request" exit 1 fi if ! grep -qi "$SOME_RESP_HEADER" "$HEADERS_FILE"; then kill $! - echo "header $SOME_RESP_HEADER was not found in response" + echo >&2 "[Fail] - Received expected response from gateway when no backend service running" + echo >&2 "header $SOME_RESP_HEADER was not found in response" rm $HEADERS_FILE exit 1 fi +echo "[Pass] - Received expected response from gateway when no backend service running" rm $HEADERS_FILE # If we call an endpoint that does not exist (say just messages), we should # get a 404, since there's no handler for that endpoint. status=`curl -s -o /dev/null -w "%{http_code}" localhost:8080/messages` + +echo "" if [ "$status" -ne "404" ]; then kill $! - echo "Invalid status: '$status' with /messages http request" + echo >&2 "[Fail] - Received expected response from gateway when grpc method does not exist" + echo >&2 "Invalid status: '$status' with /messages http request" exit 1 fi +echo "[Pass] - Received expected response from gateway when grpc method does not exist" # UnboundUnary should not work # Unbound methods require the request payload as request body (curl --data 'payload') status=`curl -s -o /dev/null -w "%{http_code}" --data '{}' localhost:8080/api/Messages.Message/UnboundUnary` + +echo "" if [ "$status" -ne "404" ]; then kill $! - echo "Invalid status: '$status' with /api/Messages.Message/UnboundUnary http request" + echo >&2 "[Fail] - Received expected response from gateway when expected payload not passed in the http request body" + echo >&2 "Invalid status: '$status' with /api/Messages.Message/UnboundUnary http request" exit 1 fi +echo "[Pass] - Received expected response from gateway when expected payload not passed in the http request body" kill $! - - # Test building the gateway with unbound methods. -docker run --rm -v=`pwd`:/defs $CONTAINER -f test/test.proto -i . -s Message --generate-unbound-methods +docker run --rm -v="$PWD":/defs "$CONTAINER" -f test/test.proto -i . -s Message --generate-unbound-methods # And make sure that we can build the test gateway too. docker build -t $CONTAINER-test-gateway gen/grpc-gateway/ @@ -88,37 +98,48 @@ status=`curl -i -s -o $HEADERS_FILE -w "%{http_code}" localhost:8080/api/message # running. In the future, if this was a real backend we should get a 200. However, # here we can use the 503 to indicate that the gateway tried to send the request # downstream. +echo "" if [ "$status" -ne "503" ]; then kill $! - echo "Invalid status: '$status' with /api/messages http request" + echo >&2 "[Fail] - Received expected response from gateway when no backend service running, and unbound methods are generated" + echo >&2 "Invalid status: '$status' with /api/messages http request" exit 1 fi +echo "[Pass] - Received expected response from gateway when no backend service running, and unbound methods are generated" # UnboundUnary should work # Unbound methods require the request payload as request body (curl --data 'payload') status=`curl -i -s -o $HEADERS_FILE -w "%{http_code}" --data '{}' localhost:8080/api/Messages.Message/UnboundUnary` +echo "" if [ "$status" -ne "503" ]; then kill $! - echo "Invalid status: '$status' with /api/Messages.Message/UnboundUnary http request" + echo >&2 "[Fail] - Received expected response from gateway when no backend service running and calling an unbound method, and unbound methods are generated" + echo >&2 "Invalid status: '$status' with /api/Messages.Message/UnboundUnary http request" exit 1 fi if ! grep -qi "$SOME_RESP_HEADER" "$HEADERS_FILE"; then kill $! - echo "header $SOME_RESP_HEADER was not found in response" + echo >&2 "[Fail] - Received expected response from gateway when no backend service running and calling an unbound method, and unbound methods are generated" + echo >&2 "header $SOME_RESP_HEADER was not found in response" rm $HEADERS_FILE exit 1 fi rm $HEADERS_FILE +echo "[Pass] - Received expected response from gateway when no backend service running and calling an unbound method, and unbound methods are generated" # If we call an endpoint that does not exist (say just messages), we should # get a 404, since there's no handler for that endpoint. status=`curl -s -o /dev/null -w "%{http_code}" localhost:8080/messages` + +echo "" if [ "$status" -ne "404" ]; then kill $! - echo "Invalid status: '$status' with /messages http request" + echo >&2 "[Fail] - Received expected response from gateway when grpc method does not exist, and unbound methods are generated" + echo >&2 "Invalid status: '$status' with /messages http request" exit 1 fi +echo "[Pass] - Received expected response from gateway when grpc method does not exist, and unbound methods are generated" kill $! diff --git a/variables.sh b/variables.sh index 74e6ae19..46c553b0 100755 --- a/variables.sh +++ b/variables.sh @@ -7,8 +7,8 @@ CONTAINER=${DOCKER_REPO}${NAMESPACE} LATEST=${1:false} GO_VERSION=${GO_VERSION:-1.17} -GRPC_VERSION=${GRPC_VERSION:-1.42} -GRPC_JAVA_VERSION=${GRPC_JAVA_VERSION:-1.42} +GRPC_VERSION=${GRPC_VERSION:-1.43} +GRPC_JAVA_VERSION=${GRPC_JAVA_VERSION:-1.43} GRPC_WEB_VERSION=${GRPC_WEB_VERSION:-1.3.0} GRPC_GATEWAY_VERSION=${GRPC_GATEWAY_VERSION:-2.0.1} UBER_PROTOTOOL_VERSION=${UBER_PROTOTOOL_VERSION:-1.3.0}