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

Update Setup section of testing README #582

Merged
merged 3 commits into from
May 5, 2022
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
77 changes: 13 additions & 64 deletions integration_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ builds are split up by distro.

## Setup

You will need a GCP project to run VMs in and a GCS bucket that is used to
transfer files onto the testing VMs. These are referred to as `${PROJECT}`
and `${TRANSFERS_BUCKET}` in the following instructions.
You will need a GCP project to run VMs in. This is referred to as `${PROJECT}` in
the following instructions.

You will need gcloud installed. Run `gcloud auth login` if you haven't
done so already.
The project needs sufficient quota to run many tests in parallel. It also needs
(when testing Windows) a firewall that allows connections over port 5986. In the
case of Google-owned projects, such a firewall is difficult to obtain, so for this
reason and quota reasons it is recommended for Googlers to use our prebuilt testing
project. Ask a teammate (e.g. martijnvs@) for the project ID.

Next, follow the setup instructions for either User Credentials or
Service Account Credentials.
You will also need a GCS bucket that is used to transfer files onto the
testing VMs. This is referred to as `${TRANSFERS_BUCKET}`. For Googlers,
`stackdriver-test-143416-untrusted-file-transfers` is recommended.

### Setup (User Credentials)
You will need `gcloud` to be installed. Run `gcloud auth login` to set up `gcloud`
authentication (if you haven't done that already).

To give the tests credentials to be able to access Google APIs as you,
run the following command and do what it says (it may ask you to run
Expand All @@ -27,60 +31,7 @@ ability to open a browser window):
gcloud --billing-project="${PROJECT}" auth application-default login
```

That's it! Now the test commands should be able to authenticate as you.

NOTE: this way of using user credentials is new and may have unforeseen
problems.

### Setup (Service Account Credentials)

You will need a service account with permissions to run various
operations in the project. You can set up such a service account with
a few commands:

```
gcloud iam service-accounts create "service-account-$(whoami)" \
--project "${PROJECT}" \
--display-name "service-account-$(whoami)"
```

```
for ROLE in \
logging.logWriter \
monitoring.metricWriter \
stackdriver.resourceMetadata.writer \
logging.viewer \
monitoring.viewer \
stackdriver.resourceMetadata.viewer \
; do
gcloud projects add-iam-policy-binding "${PROJECT}" \
--member "serviceAccount:service-account-$(whoami)@${PROJECT}.iam.gserviceaccount.com" \
--role "roles/${ROLE}" > /dev/null
done
```

You will also need to give your service account read/write permissions on
`${TRANSFERS_BUCKET}`. To do this, register your service account as principal
with role "Storage Admin" to the bucket:

```
gsutil iam ch \
"serviceAccount:service-account-$(whoami)@${PROJECT}.iam.gserviceaccount.com:roles/storage.admin" \
"gs://${TRANSFERS_BUCKET}"
```

Finally, download your credentials as a JSON file:

```
gcloud iam service-accounts keys create $HOME/credentials.json \
--project "${PROJECT}" \
--iam-account "service-account-$(whoami)@${PROJECT}.iam.gserviceaccount.com"
```

When runninng the test commands below, you must also pass the
environment variable
`GOOGLE_APPLICATION_CREDENTIALS="${HOME}/credentials.json"` to the
test command.
Once these steps are complete, you should be able to run the below commands.

## Ops Agent Test

Expand Down Expand Up @@ -240,7 +191,6 @@ With `optional: true`, the metric will be skipped during the test. This can be u

```
PROJECT="${PROJECT}" \
GOOGLE_APPLICATION_CREDENTIALS="${HOME}/credentials.json" \
SCRIPTS_DIR=third_party_apps_data \
go run -tags=integration_test \
./cmd/generate_expected_metrics
Expand All @@ -250,7 +200,6 @@ This queries all metric descriptors under `workload.googleapis.com/`, `agent.goo

```
PROJECT="${PROJECT}" \
GOOGLE_APPLICATION_CREDENTIALS="${HOME}/credentials.json" \
SCRIPTS_DIR=third_party_apps_data \
FILTER='metric.type=starts_with("workload.googleapis.com/apache")' \
go run -tags=integration_test \
Expand Down