graphql-engine/server/test-manual
2023-03-28 09:20:51 +00:00
..
alloydb Document and automate spinning up AlloyDB for testing. 2022-11-24 14:16:21 +00:00
postgres-replicas server/test-manual: A way to start PostgreSQL with a read replica. 2023-03-28 09:20:51 +00:00
.gitignore Document and automate spinning up AlloyDB for testing. 2022-11-24 14:16:21 +00:00
README.md Document and automate spinning up AlloyDB for testing. 2022-11-24 14:16:21 +00:00

Manual testing helpers

The code in this directory will help you spin up manual testing environments.

It uses Terraform, which you can install using your package manager.

You will need to specify your name to use these, so that you don't step on the toes of other developers. We recommend using the name portion of your Hasura email address, without any dots.

You can either specify your name by passing -var <name> to each terraform command, or by setting the TF_VAR_name environment variable. If you do the latter, you might find it easiest to add it to .envrc.local in the repository root, and use direnv to load it automatically.

$ export TF_VAR_name='tanmaigopal'

Note that Terraform creates files locally to manage its internal state. Do not delete the state files or it will lose track of what you've created.

Once you've started something, it's your job to stop it too. Please don't leave it lying around.

Google Cloud

To spin up these resources, you will need a Google Cloud account and a project with billing enabled.

First, install the Google Cloud CLI.

Next, authenticate:

$ gcloud auth application-default login

Set your project (you can add this to .envrc.local if you want):

$ export GOOGLE_CLOUD_PROJECT='<project name>'

Then proceed.

AlloyDB

To spin up a test instance, cd into the alloydb directory, and run:

$ terraform init
$ terraform apply -var password='<a strong password>'

(You can generate a strong password by running openssl rand 32 | base64.)

If the plan looks good, type "yes".

You may have to wait a few minutes for things to start up, and then a couple more while the bastion instance comes online.

The URL can be found by running terraform output url (be warned, it includes your super-secret password).

Once everything is up and running, you can connect to the AlloyDB proxy as follows:

$ psql "$(terraform output -raw url)"

Test all you like. When you're done, run:

$ terraform destroy

Troubleshooting

If you're having trouble, you may want to debug the Bastion instance. View the auth proxy logs by SSHing in and reading the log file.

First of all, enable SSH by uncommenting the "ssh" tag in bastion.tf, and running terraform apply again.

Then take a peek:

$ gcloud compute ssh <name>-testing-alloydb-bastion
bastion$ cat /alloydb-auth-proxy.log

Modifying these files

You are advised to read the Terraform documentation.

When reading provider documentation, you might notice discrepancies between the pinned version here and the version documented. To mitigate this, upgrade first:

$ terraform get -update

Then fix any issues. After that, you can make your changes.

Once you're done, please run terraform fmt before committing.