test(profiler): use go 1.18.4 in integration test
@@ -34,14 +34,28 @@ export GOOGLE_APPLICATION_CREDENTIALS="${KOKORO_KEYSTORE_DIR}/72935_cloud-profil
export GCLOUD_TESTS_GOLANG_PROJECT_ID="cloud-profiler-e2e"
# Ensure a newer version of Go is used so it is compatible with newer libraries.
-# Here we install v1.17.7 which is the current version as of when this code
-# was written, following instructions from https://go.dev/doc/manage-install.
-# Go modules might not be on for previous versions of Go, so we also have to
-# enable the module system explicitly.
-export GO111MODULE=on
-go install golang.org/dl/go1.17.7
-go1.17.7 download
+# Here we install v1.18.4 which is the current version as of July 2022.
+mkdir -p /tmp/bin
+GIMME=/tmp/bin/gimme
+retry curl -sL -o "$GIMME" https://raw.githubusercontent.com/travis-ci/gimme/master/gimme
+chmod +x "$GIMME"
+
+export GIMME_GO_VERSION=1.18.4
+export GIMME_ENV_PREFIX=/tmp/gimme_envs
+install_go() {
+ "$GIMME"
+ # If gimme was successful, an .env script that sets up proper environment
+ # variables will be created.
+ if [[ -f "${GIMME_ENV_PREFIX}/go${GIMME_GO_VERSION}.env" ]]
+ then
+ source "${GIMME_ENV_PREFIX}/go${GIMME_GO_VERSION}.env"
+ else
+ return 1
+ fi
+}
+retry install_go
# Run test.
-retry go1.17.7 mod download
-go1.17.7 test -run TestAgentIntegration -run_only_profiler_backoff_test -timeout 1h
+go version
+retry go mod download
+go test -run TestAgentIntegration -run_only_profiler_backoff_test -timeout 1h
