Skip to content
This repository was archived by the owner on Mar 8, 2022. It is now read-only.

Conversation

sergiught
Copy link
Collaborator

@sergiught sergiught commented Jan 25, 2022

Proposed Changes

In this PR we are introducing a wiremock container in order for us to not rely on digital ocean directly for verifying custom domains with tests.

We will now have the potential to apply the same strategy to multiple tests, specially ones that might require paid subscriptions.

Acceptance Test Output

$ make testacc TESTS=TestAccXXX

=== RUN   TestAccCustomDomainVerification
--- PASS: TestAccCustomDomainVerification (0.46s)
PASS

Process finished with the exit code 0

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

@sergiught sergiught force-pushed the patch/DXCDT-12-wiremock branch from a5f5b3a to 9b76d93 Compare January 26, 2022 08:33
@sergiught sergiught changed the base branch from master to patch/fix-logstream-tests January 26, 2022 09:28
@sergiught sergiught marked this pull request as ready for review January 26, 2022 09:28
@sergiught sergiught self-assigned this Jan 26, 2022
@sergiught sergiught force-pushed the patch/DXCDT-12-wiremock branch from 9b76d93 to 7a7ecd1 Compare January 26, 2022 09:44
Copy link
Collaborator

@willvedd willvedd left a comment

Choose a reason for hiding this comment

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

Great work, this definitely pushes us forward and will empower others to contribute with confidence.

I've made a bunch of small comments, mostly around naming and clarity. However the one major point I'd like to explore is the abstraction of the provider initialization so that we don't need to declare the schema twice to accommodate two sets of configuration. Instead, I think it would be wise to have a single provider initialization function that accepted some configuration. That way we are only defining and updating that schema in a single place and we don't need to hardcode any configuration.

CONTRIBUTING.md Outdated
@@ -40,11 +46,10 @@ AUTH0_CLIENT_ID=<your-auth0-client-id>
AUTH0_CLIENT_SECRET=<your-auth0-client-secret>
```

Then, run `make testacc`.
Then, run `docker-compose up -d && make testacc`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thoughts about bundling the docker-compose up directly into a separate command in the makefile? Perhaps make testacc_local? The makefile does a good job of hiding away a lot of the implementation details and we don't want to require folks to need to know to run the docker compose locally.

However, this would just be for local invocation, I do like that it's separated in the Github workflow above.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Further, you're omitting the --build arg here whereas it exists in the workflow, I forget if building the image is a default behavior of up but would think that we'd want to be consistent in both places.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, we can add a makefile command to bootstrap the dev env.

When docker-compose up is ran and the image is not available on the host machine it will always default to building it. The --build is there just to always force rebuilding and not use the one from cache.


**Note:** The acceptance tests make calls to a real Auth0 tenant, and create
real resources. Certain tests, for example for custom domains
(`TestAccCustomDomain`), also require a paid Auth0 subscription to be able to
real resources. Certain tests also require a paid Auth0 subscription to be able to
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we list which ones specifically so folks could know to expect those failing tests?

"github.com/hashicorp/terraform-plugin-sdk/terraform"

"gopkg.in/auth0.v5/management"
)

func providerWithWiremock() *schema.Provider {
Copy link
Collaborator

Choose a reason for hiding this comment

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

While Wiremock is a testing utility we're using, it may not be descriptive at first glance. Would you consider something like providerWithMockedRequests, mockedProvider or something similar?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated it to providerWithTestingConfiguration.

},
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

This entire function is awfully similar to the init function in provider.go. It appears that the only differences are in configuration being passed in. Would you consider introducing a function that instantiates a provider with the configuration as an argument? Doing so would allow us to only need to instantiate and modify the provider schema in one location, as opposed to two for any modifications of resources. It would also mean that we don't need to hardcode the mocked service's host.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

resource.Test(t, resource.TestCase{
Providers: map[string]terraform.ResourceProvider{
"auth0": Provider(),
"digitalocean": digitalocean.Provider(),
"auth0": providerWithWiremock(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Checking my understanding here, this is the exact spot where we'd swap the real provider with the provider with mocked requests, when we adjust the tests going forward?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, that's correct:)

## Getting started

To work on the provider, you'll need [Go](http://www.golang.org) installed on
your machine (version 1.10+ is *required*). You'll also need to correctly setup
your machine (version 1.13+ is *required*). You'll also need to correctly set up
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is updated to 1.13 to support the usage of modules, correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, that's the main reason I bumped it.

CONTRIBUTING.md Outdated
Comment on lines 11 to 15
## Prerequisites

- [Go 1.13+](https://go.dev/)
- [Docker](https://docs.docker.com/get-docker/)
- [Docker-Compose](https://docs.docker.com/compose/install/)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we framed these as dependencies for testing? Otherwise it may appear that docker and docker compose are fundamental to the contribution.

Copy link
Collaborator Author

@sergiught sergiught Jan 26, 2022

Choose a reason for hiding this comment

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

Well in a way they are fundamental to the contribution, to ensure that all tests are passing, or if we want to add new test cases for new functionality we will need the mocks as well.

Edit: Made it more clear tho that those are used within testing.

Base automatically changed from patch/fix-logstream-tests to master January 26, 2022 14:03
@sergiught sergiught requested a review from willvedd January 26, 2022 17:14
@sergiught sergiught force-pushed the patch/DXCDT-12-wiremock branch from eefc558 to b7096d5 Compare January 26, 2022 17:19
Copy link
Collaborator

@willvedd willvedd left a comment

Choose a reason for hiding this comment

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

Solid work!

@sergiught sergiught merged commit 29fbde4 into master Jan 26, 2022
@sergiught sergiught deleted the patch/DXCDT-12-wiremock branch January 26, 2022 21:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants