Skip to content

Commit

Permalink
Use Go 1.13.1 runtime on GCP for cloud functions (#17180)
Browse files Browse the repository at this point in the history
## What does this PR do?

This PR changes the runtime of Google Cloud Functions provided by Functionbeat to 1.13.1. Furthermore, a test is added to the CIs to check if the cloud functions can be built using Go 1.13.1.

## Why is it important?

Previously, we had no check to catch if we had broken something in the GCP functions.


## Related issues

- Closes #16827
  • Loading branch information
kvch committed Mar 24, 2020
1 parent 50d8656 commit b82b9db
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ jobs:
env: TARGETS="TEST_ENVIRONMENT=0 -C x-pack/functionbeat testsuite"
go: $TRAVIS_GO_VERSION
stage: test
- os: linux
before_install: .ci/scripts/travis_has_changes.sh x-pack/functionbeat libbeat || travis_terminate 0
env: TARGETS="-C x-pack/functionbeat test-gcp-functions"
go: 1.13.1
stage: test

# Docker Log Driver
- os: linux
Expand Down
3 changes: 3 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ pipeline {
stage('Functionbeat x-pack'){
steps {
mageTarget("Functionbeat x-pack Linux", "x-pack/functionbeat", "update build test")
withEnv(["GO_VERSION=1.13.1"]){
makeTarget("Functionbeat x-pack Linux", "-C x-pack/functionbeat test-gcp-functions")
}
}
}
stage('Functionbeat Mac OS X x-pack'){
Expand Down
3 changes: 3 additions & 0 deletions x-pack/functionbeat/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ ES_BEATS?=../../
#
include $(ES_BEATS)/dev-tools/make/xpack.mk

.PHONY: test-gcp-functions
test-gcp-functions: mage
mage testGCPFunctions
23 changes: 23 additions & 0 deletions x-pack/functionbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,29 @@ func BuildPkgForFunctions() error {
return nil
}

// TestGCPFunctions are used by the CI to test if the GCP functions can be built with
// the selected Go version.
// The version is 1.13.1 (Ref: https://cloud.google.com/functions/docs/concepts/go-runtime)
func TestGCPFunctions() error {
for _, f := range []string{"pubsub", "storage"} {
params := devtools.DefaultBuildArgs()
inputFiles := filepath.Join("provider", "gcp", f, f+".go")
params.InputFiles = []string{inputFiles}
params.Name = f
params.CGO = false
params.Env = map[string]string{
"GOOS": "linux",
"GOARCH": "amd64",
}

err := devtools.Build(params)
if err != nil {
return fmt.Errorf("error while building %s for GCP: %+v", f, err)
}
}
return nil
}

// BuildSystemTestBinary build a binary for testing that is instrumented for
// testing and measuring code coverage. The binary is only instrumented for
// coverage when TEST_COVERAGE=true (default is false).
Expand Down
2 changes: 1 addition & 1 deletion x-pack/functionbeat/manager/gcp/template_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

const (
runtime = "go111" // Golang 1.11
runtime = "go113" // Golang 1.13
archiveURL = "gs://%s/%s" // path to the function archive
locationTemplate = "projects/%s/locations/%s" // full name of the location
functionName = locationTemplate + "/functions/%s" // full name of the functions
Expand Down

0 comments on commit b82b9db

Please sign in to comment.