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

Add Docker Compose file for local testing #187

Merged
merged 4 commits into from
Jun 3, 2024
Merged

Conversation

mitchnielsen
Copy link
Contributor

@mitchnielsen mitchnielsen commented May 31, 2024

Summary

Adds a local Docker Compose file to start an instance of Prefect that we can reach with terraform commands.

Closes #186

Testing

Click to expand
$ terraform plan
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│  - prefecthq/prefect in /Users/mitch/go/bin
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with
│ published releases.
╵

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # prefect_work_pool.example will be created
  + resource "prefect_work_pool" "example" {
      + base_job_template = jsonencode({})
      + created           = (known after apply)
      + default_queue_id  = (known after apply)
      + id                = (known after apply)
      + name              = "my-work-pool"
      + paused            = true
      + type              = "kubernetes"
      + updated           = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply"
now.

~/code/github.com/prefecthq/terraform-provider-prefect/add-testing-in-docker/examples/provider-install-verification on  add-testing-in-docker *?!
$ terraform apply
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│  - prefecthq/prefect in /Users/mitch/go/bin
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with
│ published releases.
╵

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # prefect_work_pool.example will be created
  + resource "prefect_work_pool" "example" {
      + base_job_template = jsonencode({})
      + created           = (known after apply)
      + default_queue_id  = (known after apply)
      + id                = (known after apply)
      + name              = "my-work-pool"
      + paused            = true
      + type              = "kubernetes"
      + updated           = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

prefect_work_pool.example: Creating...
prefect_work_pool.example: Creation complete after 0s [id=c088c80f-9612-4912-b03b-d5bea4facac7]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
image

Adds a local Docker Compose file to start an instance of Prefect that we
can reach with `terraform` commands.

Closes #186
@mitchnielsen mitchnielsen self-assigned this May 31, 2024
@mitchnielsen mitchnielsen added the enhancement New feature or request label May 31, 2024
@github-actions github-actions bot added the docs label May 31, 2024
- Adds example Terraform configuration to provision a work pool
- Adds contribution docs on how to use it.
@mitchnielsen
Copy link
Contributor Author

@parkedwards - looking at the PREFECT_API_URL in the acceptance tests CI file, I suspect we could replace the value (which I think points to dev or staging) and instead spin up a Prefect server instance using this new Docker Compose setup. That'd give us fresh environments to test against in CI and might help with transient errors related to environment pollution.

Does that sound right/fair? If so I'll open an issue and we can look into it more in a separate PR.

@mitchnielsen mitchnielsen marked this pull request as ready for review June 3, 2024 19:10
@mitchnielsen mitchnielsen requested review from gabcoyne and a team as code owners June 3, 2024 19:10
@parkedwards
Copy link
Contributor

@parkedwards - looking at the PREFECT_API_URL in the acceptance tests CI file, I suspect we could replace the value (which I think points to dev or staging) and instead spin up a Prefect server instance using this new Docker Compose setup. That'd give us fresh environments to test against in CI and might help with transient errors related to environment pollution.

@mitchnielsen that sounds right - could be something like http://localhost:4200
https://github.com/PrefectHQ/terraform-provider-prefect/blob/main/internal/provider/provider.go#L116-L126

just a caveat - one wrinkle is that our OSS server isn't an exact match/port of our SaaS (which the current acceptance tests are mostly oriented towards supporting) - the OSS server has a subset of features and endpoints. so there may be some extra potholes we hit as we try to marry the tests<>this local prefect server instance. but i like where this is going

Copy link
Contributor

@parkedwards parkedwards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great idea

@mitchnielsen
Copy link
Contributor Author

just a caveat - one wrinkle is that our OSS server isn't an exact match/port of our SaaS (which the current acceptance tests are mostly oriented towards supporting) - the OSS server has a subset of features and endpoints. so there may be some extra potholes we hit as we try to marry the tests<>this local prefect server instance. but i like where this is going

Great point. I added this note in #192.

@mitchnielsen mitchnielsen merged commit 838df36 into main Jun 3, 2024
2 checks passed
@mitchnielsen mitchnielsen deleted the add-testing-in-docker branch June 3, 2024 19:54
@parkedwards parkedwards added maintenance Maintenance work - won't show in release notes and removed enhancement New feature or request labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs maintenance Maintenance work - won't show in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support local testing using Docker Compose
2 participants