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

test: add database connectivity test #295

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

test: add database connectivity test #295

wants to merge 20 commits into from

Conversation

Soaib024
Copy link
Member

@Soaib024 Soaib024 commented Oct 5, 2023

Description

https://github.ibm.com/goldeneye/issues/issues/5207

Release required?

  • No release
  • Patch release (x.x.X)
  • Minor release (x.X.x)
  • Major release (X.x.x)
Release notes content

Run the pipeline

If the CI pipeline doesn't run when you create the PR, the PR requires a user with GitHub collaborators access to run the pipeline.

Run the CI pipeline when the PR is ready for review and you expect tests to pass. Add a comment to the PR with the following text:

/run pipeline

Checklist for reviewers

  • If relevant, a test for the change is included or updated with this PR.
  • If relevant, documentation for the change is included or updated with this PR.

Merge actions for mergers

  • When merging, use a relevant conventional commit message that is based on the PR contents and any release notes provided by the PR author. The commit message determines whether a new version of the module is needed, and if so, which semver increment to use (major, minor, or patch).
  • Merge by using "Squash and merge".

@Soaib024
Copy link
Member Author

Soaib024 commented Oct 5, 2023

Screenshot 2023-10-05 at 11 40 20 PM

Table and rows created in postgresql instance

@Soaib024
Copy link
Member Author

Soaib024 commented Oct 6, 2023

/run pipeline

@Soaib024 Soaib024 changed the title [DRAFT] feat: exposed composed string for psql connection [DRAFT] chore: extend complete examples to connect to database Oct 6, 2023
@Soaib024
Copy link
Member Author

Soaib024 commented Oct 6, 2023

/run pipeline

@Soaib024
Copy link
Member Author

Soaib024 commented Oct 6, 2023

/run pipeline

@Soaib024 Soaib024 changed the title [DRAFT] chore: extend complete examples to connect to database [DRAFT] chore: extend complete example to connect to database Oct 6, 2023
@Soaib024 Soaib024 marked this pull request as ready for review October 6, 2023 09:43
@Soaib024 Soaib024 changed the title [DRAFT] chore: extend complete example to connect to database chore: extend complete example to connect to database Oct 6, 2023
@Soaib024
Copy link
Member Author

Soaib024 commented Oct 6, 2023

/run pipeline

@Soaib024
Copy link
Member Author

Soaib024 commented Oct 6, 2023

/run pipeline

@Soaib024
Copy link
Member Author

Soaib024 commented Oct 9, 2023

/run pipeline

@Soaib024 Soaib024 requested a review from shemau October 9, 2023 11:07
@shemau
Copy link
Contributor

shemau commented Oct 9, 2023

Does the test work? After running the apply locally, I see the db_connection created and complete before the VPE creation even starts. How would a connection work over private when there is no VPE gateway? (I am not sure DNS resolution works until this is live, but I may be wrong). If it does work and routes over the private network, it means that a VPE is not required/adds no value in the example. Additionally, my expectation of CBR is that they are not active immediately and the validation runs immediately after the CBR is created, possibly before it is in effect. Is there some way to confirm CBR is live before testing that the connection will run?

@Soaib024
Copy link
Member Author

Hi @shemau, I was occupied with some other work, so I couldn't look into this for a while.

Yes, as you rightly pointed out, db_creation has to wait for the creation of vpe. I was testing something different when I added depends_on module.postgresql_db instead of module.vpe in a later commit. I then missed reverting it back, but I have now made the required changes.

CBR appears to be working based on my limited testing. here in a different branch where Postgres is scoped to cbr-zone that allows traffic from vpc-1 only while all other infrastructure is deployed in a different vpc. As expected, this example fails after multiple retries of remote-exec where as in PR branch it executes successfully.

Additionally, I've added on_failure = fail to the remote-exec, which will throw an error explicitly in case any of the commands fail to execute.

@Soaib024
Copy link
Member Author

/run pipeline

@Soaib024 Soaib024 changed the title chore: extend complete example to connect to database test: add database connectivity test Oct 25, 2023
@Soaib024
Copy link
Member Author

@daniel-butler-irl @ocofaigh @shemau @toddgiguere

As discussed in the deep dive session, I have separated the logic for VSI creation and added it into tests/resources. It still relies on null_resources for executing commands against the Postgres instance. However, since this is now part of tests/resources, I believe it should be acceptable, especially considering it's not intended for consumers. Please let me know if we should eliminate the use of null_resources and execute commands directly from the test itself. Additionally, I have made some changes in example/complete to make it work. Thank you.

Here are the SQL query logs

@Soaib024
Copy link
Member Author

Soaib024 commented Nov 1, 2023

/run pipeline

@Soaib024
Copy link
Member Author

Soaib024 commented Nov 6, 2023

/run pipeline

@Soaib024
Copy link
Member Author

Soaib024 commented Nov 6, 2023

Screenshot 2023-11-06 at 9 44 31 PM

@Soaib024 Soaib024 requested a review from ocofaigh November 6, 2023 16:15
@Soaib024
Copy link
Member Author

Soaib024 commented Nov 6, 2023

Upgrade test is expected to fail, as this PR modifies default ACL rules created by vpc module and also security-group for postgresql will be created using module instead of resource block in example

there isn't any changes in root module

@Soaib024
Copy link
Member Author

/run pipeline

@ocofaigh ocofaigh mentioned this pull request Dec 19, 2023
13 tasks
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.

2 participants