Skip to content

Commit

Permalink
[revert_gae] Revert "Remove Go 1.9 / AppEngine support; assume go1.12…
Browse files Browse the repository at this point in the history
… build tag (grpc#3767)"

This reverts commit bc714cd.
  • Loading branch information
menghanl committed Aug 27, 2020
1 parent d7c44fc commit dee7804
Show file tree
Hide file tree
Showing 50 changed files with 588 additions and 24 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Expand Up @@ -16,6 +16,8 @@ matrix:
env: GO111MODULE=on
- go: 1.12.x
env: GO111MODULE=on
- go: 1.9.x
env: GAE=1

go_import_path: google.golang.org/grpc

Expand All @@ -28,11 +30,13 @@ before_install:
install:
- try3() { eval "$*" || eval "$*" || eval "$*"; }
- try3 'if [[ "${GO111MODULE}" = "on" ]]; then go mod download; else make testdeps; fi'
- if [[ -n "${GAE}" ]]; then source ./install_gae.sh; make testappenginedeps; fi
- if [[ -n "${VET}" ]]; then ./vet.sh -install; fi

script:
- set -e
- if [[ -n "${TESTEXTRAS}" ]]; then examples/examples_test.sh; interop/interop_test.sh; make testsubmodule; exit 0; fi
- if [[ -n "${VET}" ]]; then ./vet.sh; fi
- if [[ -n "${GAE}" ]]; then make testappengine; exit 0; fi
- if [[ -n "${RACE}" ]]; then make testrace; exit 0; fi
- make test
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Expand Up @@ -57,5 +57,6 @@ How to get your contributions merged smoothly and quickly.
- `make vet` to catch vet errors
- `make test` to run the tests
- `make testrace` to run tests in race mode
- optional `make testappengine` to run tests with appengine

- Exceptions to the rules can be made if there's a compelling reason for doing so.
8 changes: 8 additions & 0 deletions Makefile
Expand Up @@ -23,6 +23,12 @@ testsubmodule: testdeps
cd security/advancedtls && go test -cpu 1,4 -timeout 7m google.golang.org/grpc/security/advancedtls/...
cd security/authorization && go test -cpu 1,4 -timeout 7m google.golang.org/grpc/security/authorization/...

testappengine: testappenginedeps
goapp test -cpu 1,4 -timeout 7m google.golang.org/grpc/...

testappenginedeps:
goapp get -d -v -t -tags 'appengine appenginevm' google.golang.org/grpc/...

testdeps:
go get -d -v -t google.golang.org/grpc/...

Expand All @@ -48,6 +54,8 @@ vetdeps:
deps \
proto \
test \
testappengine \
testappenginedeps \
testdeps \
testrace \
updatedeps \
Expand Down
2 changes: 2 additions & 0 deletions balancer/rls/internal/balancer.go
@@ -1,3 +1,5 @@
// +build go1.10

/*
*
* Copyright 2020 gRPC authors.
Expand Down
2 changes: 2 additions & 0 deletions balancer/rls/internal/balancer_test.go
@@ -1,3 +1,5 @@
// +build go1.10

/*
*
* Copyright 2020 gRPC authors.
Expand Down
2 changes: 2 additions & 0 deletions balancer/rls/internal/builder.go
@@ -1,3 +1,5 @@
// +build go1.10

/*
*
* Copyright 2020 gRPC authors.
Expand Down
2 changes: 2 additions & 0 deletions balancer/rls/internal/client_test.go
@@ -1,3 +1,5 @@
// +build go1.10

/*
*
* Copyright 2020 gRPC authors.
Expand Down
2 changes: 2 additions & 0 deletions balancer/rls/internal/config.go
@@ -1,3 +1,5 @@
// +build go1.10

/*
*
* Copyright 2020 gRPC authors.
Expand Down
2 changes: 2 additions & 0 deletions balancer/rls/internal/config_test.go
@@ -1,3 +1,5 @@
// +build go1.10

/*
*
* Copyright 2020 gRPC authors.
Expand Down
2 changes: 2 additions & 0 deletions balancer/rls/internal/keys/builder.go
@@ -1,3 +1,5 @@
// +build go1.10

/*
*
* Copyright 2020 gRPC authors.
Expand Down
2 changes: 2 additions & 0 deletions balancer/rls/internal/keys/builder_test.go
@@ -1,3 +1,5 @@
// +build go1.10

/*
*
* Copyright 2020 gRPC authors.
Expand Down
2 changes: 2 additions & 0 deletions balancer/rls/internal/picker.go
@@ -1,3 +1,5 @@
// +build go1.10

/*
*
* Copyright 2020 gRPC authors.
Expand Down
2 changes: 2 additions & 0 deletions balancer/rls/internal/picker_test.go
@@ -1,3 +1,5 @@
// +build go1.10

/*
*
* Copyright 2020 gRPC authors.
Expand Down
2 changes: 2 additions & 0 deletions channelz/service/func_linux.go
@@ -1,3 +1,5 @@
// +build !appengine

/*
*
* Copyright 2018 gRPC authors.
Expand Down
2 changes: 1 addition & 1 deletion channelz/service/func_nonlinux.go
@@ -1,4 +1,4 @@
// +build !linux
// +build !linux appengine

/*
*
Expand Down
2 changes: 1 addition & 1 deletion channelz/service/service_sktopt_test.go
@@ -1,4 +1,4 @@
// +build linux
// +build linux,!appengine
// +build 386 amd64

/*
Expand Down
2 changes: 1 addition & 1 deletion channelz/service/service_test.go
Expand Up @@ -58,7 +58,7 @@ type protoToSocketOptFunc func([]*channelzpb.SocketOption) *channelz.SocketOptio

// protoToSocketOpt is used in function socketProtoToStruct to extract socket option
// data from unmarshaled proto message.
// It is only defined under linux environment on x86 architecture.
// It is only defined under linux, non-appengine environment on x86 architecture.
var protoToSocketOpt protoToSocketOptFunc

// emptyTime is used for detecting unset value of time.Time type.
Expand Down
2 changes: 1 addition & 1 deletion channelz/service/util_sktopt_386_test.go
@@ -1,4 +1,4 @@
// +build 386,linux
// +build 386,linux,!appengine

/*
*
Expand Down
2 changes: 1 addition & 1 deletion channelz/service/util_sktopt_amd64_test.go
@@ -1,4 +1,4 @@
// +build amd64,linux
// +build amd64,linux,!appengine

/*
*
Expand Down
30 changes: 30 additions & 0 deletions credentials/go12.go
@@ -0,0 +1,30 @@
// +build go1.12

/*
*
* Copyright 2019 gRPC authors.
*
* 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 credentials

import "crypto/tls"

// This init function adds cipher suite constants only defined in Go 1.12.
func init() {
cipherSuiteLookup[tls.TLS_AES_128_GCM_SHA256] = "TLS_AES_128_GCM_SHA256"
cipherSuiteLookup[tls.TLS_AES_256_GCM_SHA384] = "TLS_AES_256_GCM_SHA384"
cipherSuiteLookup[tls.TLS_CHACHA20_POLY1305_SHA256] = "TLS_CHACHA20_POLY1305_SHA256"
}
4 changes: 0 additions & 4 deletions credentials/tls.go
Expand Up @@ -227,8 +227,4 @@ var cipherSuiteLookup = map[uint16]string{
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
// Go 1.12
tls.TLS_AES_128_GCM_SHA256: "TLS_AES_128_GCM_SHA256",
tls.TLS_AES_256_GCM_SHA384: "TLS_AES_256_GCM_SHA384",
tls.TLS_CHACHA20_POLY1305_SHA256: "TLS_CHACHA20_POLY1305_SHA256",
}
2 changes: 2 additions & 0 deletions examples/features/xds/client/main.go
@@ -1,3 +1,5 @@
// +build go1.11

/*
*
* Copyright 2020 gRPC authors.
Expand Down
2 changes: 2 additions & 0 deletions examples/features/xds/server/main.go
@@ -1,3 +1,5 @@
// +build go1.11

/*
*
* Copyright 2020 gRPC authors.
Expand Down
6 changes: 6 additions & 0 deletions install_gae.sh
@@ -0,0 +1,6 @@
#!/bin/bash

TMP=$(mktemp -d /tmp/sdk.XXX) \
&& curl -o $TMP.zip "https://storage.googleapis.com/appengine-sdks/featured/go_appengine_sdk_linux_amd64-1.9.68.zip" \
&& unzip -q $TMP.zip -d $TMP \
&& export PATH="$PATH:$TMP/go_appengine"
2 changes: 2 additions & 0 deletions internal/channelz/types_linux.go
@@ -1,3 +1,5 @@
// +build !appengine

/*
*
* Copyright 2018 gRPC authors.
Expand Down
4 changes: 2 additions & 2 deletions internal/channelz/types_nonlinux.go
@@ -1,4 +1,4 @@
// +build !linux
// +build !linux appengine

/*
*
Expand Down Expand Up @@ -37,6 +37,6 @@ type SocketOptionData struct {
// Windows OS doesn't support Socket Option
func (s *SocketOptionData) Getsockopt(fd uintptr) {
once.Do(func() {
logger.Warning("Channelz: socket options are not supported on non-linux os.")
logger.Warning("Channelz: socket options are not supported on non-linux os and appengine.")
})
}
2 changes: 1 addition & 1 deletion internal/channelz/util_linux.go
@@ -1,4 +1,4 @@
// +build linux
// +build linux,!appengine

/*
*
Expand Down
2 changes: 1 addition & 1 deletion internal/channelz/util_nonlinux.go
@@ -1,4 +1,4 @@
// +build !linux
// +build !linux appengine

/*
*
Expand Down
2 changes: 1 addition & 1 deletion internal/channelz/util_test.go
@@ -1,4 +1,4 @@
// +build linux
// +build linux,go1.10,!appengine

/*
*
Expand Down
@@ -1,3 +1,5 @@
// +build go1.10

/*
*
* Copyright 2020 gRPC authors.
Expand Down
@@ -1,3 +1,5 @@
// +build go1.10

/*
*
* Copyright 2020 gRPC authors.
Expand Down
31 changes: 31 additions & 0 deletions internal/credentials/gobefore110.go
@@ -0,0 +1,31 @@
// +build !go1.10

/*
*
* Copyright 2020 gRPC authors.
*
* 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 credentials

import (
"crypto/tls"
"net/url"
)

//TODO(ZhenLian): delete this file when we remove Go 1.9 tests.
func SPIFFEIDFromState(state tls.ConnectionState) *url.URL {
return nil
}
2 changes: 2 additions & 0 deletions internal/credentials/syscallconn.go
@@ -1,3 +1,5 @@
// +build !appengine

/*
*
* Copyright 2018 gRPC authors.
Expand Down
30 changes: 30 additions & 0 deletions internal/credentials/syscallconn_appengine.go
@@ -0,0 +1,30 @@
// +build appengine

/*
*
* Copyright 2018 gRPC authors.
*
* 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 internal

import (
"net"
)

// WrapSyscallConn returns newConn on appengine.
func WrapSyscallConn(rawConn, newConn net.Conn) net.Conn {
return newConn
}
2 changes: 2 additions & 0 deletions internal/credentials/syscallconn_test.go
@@ -1,3 +1,5 @@
// +build !appengine

/*
*
* Copyright 2018 gRPC authors.
Expand Down
2 changes: 2 additions & 0 deletions internal/profiling/buffer/buffer.go
@@ -1,3 +1,5 @@
// +build !appengine

/*
*
* Copyright 2019 gRPC authors.
Expand Down
43 changes: 43 additions & 0 deletions internal/profiling/buffer/buffer_appengine.go
@@ -0,0 +1,43 @@
// +build appengine

/*
*
* Copyright 2019 gRPC authors.
*
* 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 buffer

// CircularBuffer is a no-op implementation for appengine builds.
//
// Appengine does not support stats because of lack of the support for unsafe
// pointers, which are necessary to efficiently store and retrieve things into
// and from a circular buffer. As a result, Push does not do anything and Drain
// returns an empty slice.
type CircularBuffer struct{}

// NewCircularBuffer returns a no-op for appengine builds.
func NewCircularBuffer(size uint32) (*CircularBuffer, error) {
return nil, nil
}

// Push returns a no-op for appengine builds.
func (cb *CircularBuffer) Push(x interface{}) {
}

// Drain returns a no-op for appengine builds.
func (cb *CircularBuffer) Drain() []interface{} {
return nil
}
2 changes: 2 additions & 0 deletions internal/profiling/buffer/buffer_test.go
@@ -1,3 +1,5 @@
// +build !appengine

/*
*
* Copyright 2019 gRPC authors.
Expand Down
2 changes: 2 additions & 0 deletions internal/profiling/profiling_test.go
@@ -1,3 +1,5 @@
// +build !appengine

/*
*
* Copyright 2019 gRPC authors.
Expand Down

0 comments on commit dee7804

Please sign in to comment.