Skip to content

Commit

Permalink
chore: run flaky bot
Browse files Browse the repository at this point in the history
scripts were exiting early due to flags set. Now a test failure
will no longer exit the script which ensures flakybot can run.
  • Loading branch information
codyoss committed Aug 11, 2022
1 parent a90d802 commit 9f7ba8a
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions internal/kokoro/test.sh
Expand Up @@ -12,13 +12,13 @@ export GOOGLE_CLOUD_PROJECT="dulcet-port-762"
export GCLOUD_TESTS_IMPERSONATE_READER_KEY="${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-impersonate-reader-service-account"
export GCLOUD_TESTS_IMPERSONATE_READER_EMAIL="impersonate-reader@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com"
export GCLOUD_TESTS_IMPERSONATE_WRITER_EMAIL="impersonate-writer@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com"
export GCLOUD_TESTS_GOLANG_PROJECT_NUMBER=`cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-project-number`
export GCLOUD_TESTS_GOLANG_SERVICE_ACCOUNT_CLIENT_ID=`cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-byoid-client-id`
export GCLOUD_TESTS_GOLANG_AWS_ACCOUNT_ID=`cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-byoid-aws-acc-id`
export GCLOUD_TESTS_GOLANG_AWS_ROLE_NAME=`cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-byoid-aws-role-name`
export GCLOUD_TESTS_GOLANG_PROJECT_NUMBER=$(cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-project-number)
export GCLOUD_TESTS_GOLANG_SERVICE_ACCOUNT_CLIENT_ID=$(cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-byoid-client-id)
export GCLOUD_TESTS_GOLANG_AWS_ACCOUNT_ID=$(cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-byoid-aws-acc-id)
export GCLOUD_TESTS_GOLANG_AWS_ROLE_NAME=$(cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-byoid-aws-role-name)
export GCLOUD_TESTS_GOLANG_AWS_ROLE_ID="arn:aws:iam::$GCLOUD_TESTS_GOLANG_AWS_ACCOUNT_ID:role/$GCLOUD_TESTS_GOLANG_AWS_ROLE_NAME"
export GCLOUD_TESTS_GOLANG_AUDIENCE_OIDC=`cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-byoid-aud-oidc`
export GCLOUD_TESTS_GOLANG_AUDIENCE_AWS=`cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-byoid-aud-aws`
export GCLOUD_TESTS_GOLANG_AUDIENCE_OIDC=$(cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-byoid-aud-oidc)
export GCLOUD_TESTS_GOLANG_AUDIENCE_AWS=$(cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-byoid-aud-aws)

# Display commands being run
set -x
Expand Down Expand Up @@ -50,16 +50,27 @@ cd google-api-go-generator
go generate
cd ..

set +e # Run all tests, don't stop after the first failure.
exit_code=0

# Run tests and tee output to log file, to be pushed to GCS as artifact.
if [[ $KOKORO_JOB_NAME == *"continuous"* ]]; then
go test -race -v ./... 2>&1 | tee $KOKORO_ARTIFACTS_DIR/$KOKORO_GERRIT_CHANGE_NUMBER.txt
# Takes the kokoro output log (raw stdout) and creates a machine-parseable
# xUnit XML file.
cat $KOKORO_ARTIFACTS_DIR/$KOKORO_GERRIT_CHANGE_NUMBER.txt |
go-junit-report -set-exit-code >sponge_log.xml
exit_code=$(($?))
else
go test -race -v -short ./... 2>&1 | tee $KOKORO_ARTIFACTS_DIR/$KOKORO_GERRIT_CHANGE_NUMBER.txt
exit_code=$(($?))
fi

if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot -logs_dir=$GOCLOUD_HOME \
-repo=googleapis/google-api-go-client \
-commit_hash=$KOKORO_GITHUB_COMMIT_URL_google_api_go_client
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot -logs_dir=$GOCLOUD_HOME \
-repo=googleapis/google-api-go-client \
-commit_hash=$KOKORO_GITHUB_COMMIT_URL_google_api_go_client
fi

exit $exit_code

0 comments on commit 9f7ba8a

Please sign in to comment.