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

Enhance Logs readability of SDK Conformance Tests #1453

Merged
merged 3 commits into from
Apr 15, 2020
Merged
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
8 changes: 4 additions & 4 deletions build/build-sdk-images/node/build-sdk-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# limitations under the License.

cd /go/src/agones.dev/agones/test/sdk/nodejs
npm install
npm rebuild
npm install --quiet
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

npm rebuild --quiet

# If first 'npm install' attempt fails, which could occur for a variety of reasons,
# do one more attempt
Expand All @@ -27,6 +27,6 @@ then
rm -rf /go/src/agones.dev/agones/test/sdk/nodejs/node_modules
rm /go/src/agones.dev/agones/test/sdk/nodejs/package-lock.json
npm cache clean
npm rebuild
npm install
npm rebuild --quiet
npm install --quiet
fi
6 changes: 4 additions & 2 deletions build/build-sdk-images/restapi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ ENV GOPATH /go
RUN wget -q https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
tar -xzf go${GO_VERSION}.linux-amd64.tar.gz && rm go${GO_VERSION}.linux-amd64.tar.gz && mkdir -p ${GOPATH}

RUN echo '§' && apt-get -qy update
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
apt-get install -y nodejs
apt-get install -qq -y nodejs
Copy link
Member

Choose a reason for hiding this comment

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

Also nice! Good idea to reduce the noise!


RUN apt-get install -y openjdk-8-jre
#RUN apt-get install -qq -y openjdk-8-jre
RUN apt-get install -qq -y openjdk-8-jre > /dev/null

ENV PATH /usr/local/go/bin:/go/bin:$PATH

Expand Down
2 changes: 1 addition & 1 deletion build/includes/sdk.mk
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ run-sdk-conformance-no-build: FEATURE_GATES ?=
run-sdk-conformance-no-build: ensure-agones-sdk-image
run-sdk-conformance-no-build: ensure-build-sdk-image
DOCKER_RUN_ARGS="--net host -e AGONES_SDK_GRPC_PORT=$(GRPC_PORT) -e AGONES_SDK_HTTP_PORT=$(HTTP_PORT) -e FEATURE_GATES=$(FEATURE_GATES) $(DOCKER_RUN_ARGS)" COMMAND=sdktest $(MAKE) run-sdk-command & \
docker run -p $(GRPC_PORT):$(GRPC_PORT) -p $(HTTP_PORT):$(HTTP_PORT) -e "FEATURE_GATES=$(FEATURE_GATES)" -e "ADDRESS=" -e "TEST=$(TESTS)" -e "TIMEOUT=$(TIMEOUT)" -e "DELAY=$(DELAY)" \
docker run -p $(GRPC_PORT):$(GRPC_PORT) -p $(HTTP_PORT):$(HTTP_PORT) -e "FEATURE_GATES=$(FEATURE_GATES)" -e "ADDRESS=" -e "TEST=$(TESTS)" -e "SDK_NAME=$(SDK_FOLDER)" -e "TIMEOUT=$(TIMEOUT)" -e "DELAY=$(DELAY)" \
Copy link
Member

Choose a reason for hiding this comment

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

🙌

--net=host $(sidecar_tag) --grpc-port $(GRPC_PORT) --http-port $(HTTP_PORT)

# Run SDK conformance test for a specific SDK_FOLDER
Expand Down
55 changes: 31 additions & 24 deletions cmd/sdk-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ const (
podNamespaceEnv = "POD_NAMESPACE"

// Flags (that can also be env vars)
localFlag = "local"
fileFlag = "file"
testFlag = "test"
addressFlag = "address"
delayFlag = "delay"
timeoutFlag = "timeout"
grpcPortFlag = "grpc-port"
httpPortFlag = "http-port"
localFlag = "local"
fileFlag = "file"
testFlag = "test"
testSdkNameFlag = "sdk-name"
addressFlag = "address"
delayFlag = "delay"
timeoutFlag = "timeout"
grpcPortFlag = "grpc-port"
httpPortFlag = "http-port"
)

var (
Expand Down Expand Up @@ -208,6 +209,7 @@ func registerTestSdkServer(grpcServer *grpc.Server, ctlConf config) (func(), err
s.GenerateUID()
expectedFuncs := strings.Split(ctlConf.Test, ",")
s.SetExpectedSequence(expectedFuncs)
s.SetSdkName(ctlConf.TestSdkName)

sdk.RegisterSDKServer(grpcServer, s)
sdkalpha.RegisterSDKServer(grpcServer, s)
Expand Down Expand Up @@ -258,6 +260,7 @@ func parseEnvFlags() config {
viper.SetDefault(localFlag, false)
viper.SetDefault(fileFlag, "")
viper.SetDefault(testFlag, "")
viper.SetDefault(testSdkNameFlag, "")
viper.SetDefault(addressFlag, "localhost")
viper.SetDefault(delayFlag, 0)
viper.SetDefault(timeoutFlag, 0)
Expand All @@ -272,13 +275,15 @@ func parseEnvFlags() config {
pflag.Int(delayFlag, viper.GetInt(delayFlag), "Time to delay (in seconds) before starting to execute main. Useful for tests")
pflag.Int(timeoutFlag, viper.GetInt(timeoutFlag), "Time of execution (in seconds) before close. Useful for tests")
pflag.String(testFlag, viper.GetString(testFlag), "List functions which should be called during the SDK Conformance test run.")
pflag.String(testSdkNameFlag, viper.GetString(testSdkNameFlag), "SDK name which is tested by this SDK Conformance test.")
runtime.FeaturesBindFlags()
pflag.Parse()

viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
runtime.Must(viper.BindEnv(localFlag))
runtime.Must(viper.BindEnv(addressFlag))
runtime.Must(viper.BindEnv(testFlag))
runtime.Must(viper.BindEnv(testSdkNameFlag))
runtime.Must(viper.BindEnv(gameServerNameEnv))
runtime.Must(viper.BindEnv(podNamespaceEnv))
runtime.Must(viper.BindEnv(delayFlag))
Expand All @@ -291,25 +296,27 @@ func parseEnvFlags() config {
runtime.Must(runtime.ParseFeaturesFromEnv())

return config{
IsLocal: viper.GetBool(localFlag),
Address: viper.GetString(addressFlag),
LocalFile: viper.GetString(fileFlag),
Delay: viper.GetInt(delayFlag),
Timeout: viper.GetInt(timeoutFlag),
Test: viper.GetString(testFlag),
GRPCPort: viper.GetInt(grpcPortFlag),
HTTPPort: viper.GetInt(httpPortFlag),
IsLocal: viper.GetBool(localFlag),
Address: viper.GetString(addressFlag),
LocalFile: viper.GetString(fileFlag),
Delay: viper.GetInt(delayFlag),
Timeout: viper.GetInt(timeoutFlag),
Test: viper.GetString(testFlag),
TestSdkName: viper.GetString(testSdkNameFlag),
GRPCPort: viper.GetInt(grpcPortFlag),
HTTPPort: viper.GetInt(httpPortFlag),
}
}

// config is all the configuration for this program
type config struct {
Address string
IsLocal bool
LocalFile string
Delay int
Timeout int
Test string
GRPCPort int
HTTPPort int
Address string
IsLocal bool
LocalFile string
Delay int
Timeout int
Test string
TestSdkName string
GRPCPort int
HTTPPort int
}
38 changes: 38 additions & 0 deletions cmd/sdk-server/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2020 Google LLC 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.

package main

import (
"testing"

"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
"google.golang.org/grpc"
)

// TestRegisterTestSdkServer - test to verify
func TestRegisterTestSdkServer(t *testing.T) {
t.Parallel()
ctlConf := parseEnvFlags()
grpcServer := grpc.NewServer()
_, err := registerTestSdkServer(grpcServer, ctlConf)
assert.NoError(t, err)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx.Done()
ctlConf.LocalFile = "@@"
_, err = registerLocal(grpcServer, ctlConf)
assert.Error(t, err, "Wrong file name should produce an error")
}
Loading