Skip to content

GitHub actions tests #293

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

Merged
merged 61 commits into from
Aug 27, 2020
Merged

GitHub actions tests #293

merged 61 commits into from
Aug 27, 2020

Conversation

coderGo93
Copy link
Contributor

@coderGo93 coderGo93 commented Aug 13, 2020

Description

Added a flag with env SKIP_TEST_EXTERNAL_CREDENTIALS where it's function is to skip acceptance tests that requires external credentials such as GCP,azure and aws

Added a github actions and has condition where it executes tests when the branch is master or is a pull request

Link to any related issue(s):

Type of change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the Terraform contribution guidelines
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirments
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code

Further comments

@coderGo93 coderGo93 changed the title WIP: GitHub actions tests GitHub actions tests Aug 14, 2020
@coderGo93
Copy link
Contributor Author

Sorry for many commits, I tried many times since I cannot try locally without using third apps. Commits related to travis can be ignored

@coderGo93 coderGo93 removed the request for review from shum August 14, 2020 00:38
@themantissa
Copy link
Collaborator

@coderGo93 just want to check - the tests errors will be fixed in another PR per our slack, correct?

@coderGo93
Copy link
Contributor Author

@coderGo93 just want to check - the tests errors will be fixed in another PR per our slack, correct?

That's correct, @themantissa . I'll fix the errors that is not API related like unauthorized error or similar

Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

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

Good progress! A few questions/comments - let me know if you have questions. Thanks!

MONGODB_ATLAS_PRIVATE_KEY: ${{ secrets.MONGODB_ATLAS_PRIVATE_KEY }}
MONGODB_ATLAS_PROJECT_ID: ${{ secrets.MONGODB_ATLAS_PROJECT_ID }}
MONGODB_ATLAS_ORG_ID: ${{ secrets.MONGODB_ATLAS_ORG_ID }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was not an env we created. It looked like, from the errors this was only for x509? Also, ideally any MongoDB Atlas specific variable keeps the MONGODB_ATLAS_ prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, the DB_USERNAME you meant, sure is for database user rule, you're right I'll add MONGODB_ATLAS_ at first

- name: Website
run: make tools && make website-lint
- name: Test
run: make test
Copy link
Collaborator

Choose a reason for hiding this comment

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

Linter picking up missing newlines^

@@ -10,6 +10,7 @@ import (
)

func TestAccDataSourceMongoDBAtlasCustomDBRole_basic(t *testing.T) {
SkipTestExtCred(t)
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 weird - why does custom db role have an external credential? Looking at the test it is it because the pre check has checkPeeringEnvAWS? Why is that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Totally agree, @coderGo93 you need to remove the checkPeeringEnvAWS because these tests don't need AWS Credentials, so these tests don't be skipped

Copy link
Contributor Author

@coderGo93 coderGo93 Aug 18, 2020

Choose a reason for hiding this comment

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

Understood, I only added the func that requires additional credentials in precheck or similar

@@ -10,6 +10,7 @@ import (
)

func TestAccDataSourceMongoDBAtlasCustomDBRoles_basic(t *testing.T) {
SkipTestExtCred(t)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as above, this shoulnd't depend on peering to test.

@@ -305,6 +305,7 @@ func TestAccResourceMongoDBAtlasCluster_basicAzure(t *testing.T) {
}

func TestAccResourceMongoDBAtlasCluster_basicGCP(t *testing.T) {
SkipTestExtCred(t)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting - this is another one I'm surprised to see peering in the pre check. If it's a basic GCP cluster I don't see why we'd have peering involved - i.e. TestAccResourceMongoDBAtlasCluster_withGCPNetworkPeering should cover it.

@coderGo93 coderGo93 requested a review from themantissa August 19, 2020 05:04
@coderGo93 coderGo93 force-pushed the github-actions-tests branch 2 times, most recently from 398bd53 to 76ba6c5 Compare August 19, 2020 18:16
Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

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

Just a couple questions and one nit on a missing EoF warning in the review view.

.travis.yml Outdated
script: make test
- name: "Test"
script:
- make test
Copy link
Collaborator

Choose a reason for hiding this comment

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

This still shows no newline at the end of the file, it passed the linter but should probably fix it up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

weird, I added newline, gotta check again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not realize that is the travis, I'm not sure if at the end we should keep the .travis.yml if Github actions can do the same work and "faster"

Copy link
Collaborator

Choose a reason for hiding this comment

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

We'll probably remove it once we get github actions working well but let's keep it for now.

Steps: []resource.TestStep{
{
Steps: []resource.TestStep{
/*{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why this so much in this test commented out?

Copy link
Contributor Author

@coderGo93 coderGo93 Aug 19, 2020

Choose a reason for hiding this comment

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

because I skip it, if you want I can delete the code related with ASAP? and if I don't comment it will give an error about lint unused code

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we don't need it then removing it is fine - much cleaner than leaving unused code.

@@ -245,7 +245,7 @@ func testAccMongoDBAtlasNetworkContainerConfigAzure(projectID, cidrBlock, provid
project_id = "%s"
atlas_cidr_block = "%s"
provider_name = "%s"
region = "US_EAST_2"
region = "US_EAST"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the change? (both are Azure regions https://docs.atlas.mongodb.com/reference/microsoft-azure/)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it fails with US_EAST_2 and I don't know how to delete it with mongodb ui, it doesn't appear that container the same can be said for GCP, that's why I changed it so it can pass, do you want me to change it back?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can't delete containers in the MongoDB UI because we don't show it there, only via API. I'm not sure I follow on why it might be failing, what's the actual error? Might be showing us a real problem.

@themantissa themantissa mentioned this pull request Aug 19, 2020
10 tasks
@coderGo93 coderGo93 force-pushed the github-actions-tests branch 6 times, most recently from 9ea2c06 to 1b73007 Compare August 22, 2020 01:12
@coderGo93 coderGo93 requested a review from themantissa August 26, 2020 15:54
Edgar López and others added 8 commits August 26, 2020 14:11
…hange to false in private ip mode to avoid error about deprecated and avoid lint errors
… instance scale and changed it back the region for container azure
…ort to rs primare attributes instead of decode state id
* chore: improved regex to allow to use a $ character

* chore: added a new test case to verify the  dabase name when it's imported
Copy link
Contributor

@PacoDw PacoDw left a comment

Choose a reason for hiding this comment

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

If all the above comments were attended is LGMT 👍

@coderGo93 coderGo93 force-pushed the github-actions-tests branch from 3f04316 to b60f105 Compare August 26, 2020 19:16
Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

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

Also looking good - similar to the other PR just would like a call out in the PR description if any bugs in the actual resources were fixed so that the tests would pass. thanks!

@@ -331,7 +331,7 @@ func resourceMongoDBAtlasCloudProviderSnapshotRestoreJobImportState(d *schema.Re

d.SetId(encodeStateID(map[string]string{
"project_id": *projectID,
"cluster_name": *clusterName,
"cluster_name": requestParameters.ClusterName,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I asked about similar fixes in the other pull requests. If we fix a bug while fixing the tests that should be noted in the PR, that way users know what was fixed. It's just a "nice to do" and makes understanding what happened easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an import that sometimes passes or fails, need to see why does happen, not sure if it's because there are many test acceptances running at same time. I changed this to verify it was the issue but it isn't, that's why I added a env var to skip test import if true in all test acceptance that imports because if you skip one another can appear with similar error.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay then if the change didn't fix anything and is not needed it shouldn't be included unless it's there for a reason since this isn't just the test but the actual resource code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll change it back for now, thank you

@coderGo93 coderGo93 requested a review from themantissa August 27, 2020 06:25
Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

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

LGTM

@coderGo93 coderGo93 merged commit c82481c into master Aug 27, 2020
@coderGo93 coderGo93 deleted the github-actions-tests branch August 27, 2020 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants