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

build: share some code for E2E tests #505

Merged
merged 1 commit into from
Jun 3, 2019
Merged
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
28 changes: 3 additions & 25 deletions system-test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,12 @@ var (
const cloudScope = "https://www.googleapis.com/auth/cloud-platform"

const startupTemplate = `
#! /bin/bash

(

# Signal any unexpected error.
trap 'echo "{{.ErrorString}}"' ERR

# Shut down the VM in 5 minutes after this script exits
# to stop accounting the VM for billing and cores quota.
trap "sleep 300 && poweroff" EXIT

retry() {
for i in {1..3}; do
"${@}" && return 0
done
return 1
}
{{- template "prologue" . }}

npm_install() {
timeout 60 npm install "${@}"
}

# Fail on any error
set -eo pipefail

# Display commands being run
set -x
# Install git
retry apt-get update >/dev/null
retry apt-get -y -q install git >/dev/null
Expand Down Expand Up @@ -120,8 +99,7 @@ GCLOUD_PROFILER_LOGLEVEL=5 GAE_SERVICE={{.Service}} node --trace-warnings build/
# Indicate to test that script has finished running
echo "{{.FinishString}}"

# Write output to serial port 2 with timestamp.
) 2>&1 | while read line; do echo "$(date): ${line}"; done >/dev/ttyS1
{{ template "epilogue" . -}}
`

type profileSummary struct {
Expand Down Expand Up @@ -193,7 +171,7 @@ func TestAgentIntegration(t *testing.T) {
t.Fatalf("failed to initialize compute Service: %v", err)
}

template, err := template.New("startupScript").Parse(startupTemplate)
template, err := proftest.BaseStartupTmpl.Parse(startupTemplate)
if err != nil {
t.Fatalf("failed to parse startup script template: %v", err)
}
Expand Down