-
Notifications
You must be signed in to change notification settings - Fork 13
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
Require a Postgres version when creating a PostgresCluster #73
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
# Verify the error when the Postgres version given is too low. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since too low is just > 10, A user can still "create" a cluster with PG 12, even if they don't have a PG 12 available. No pods will be brought up, but for example:
It seems intuitive what to do here. Just thought I'd mention it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Yeah, with the existing event warning we have in place, it should be fairly clear what's going on, but we can definitely try to improve this in the future, especially if we make other updates. |
||
TOO_LOW=$(kubectl-pgo create postgrescluster --pg-major-version=1 toolow 2>&1) | ||
if [[ "${TOO_LOW}" != "Error:"*"Invalid value"* ]]; then | ||
printf 'Expected invalid value error, got %q\n' "${TOO_LOW}" | ||
exit 1 | ||
fi | ||
|
||
# Verify the error when the Postgres version given is too high. | ||
TOO_HIGH=$(kubectl-pgo create postgrescluster --pg-major-version=100 toohigh 2>&1) | ||
if [[ "${TOO_HIGH}" != "Error:"*"Invalid value"* ]]; then | ||
printf 'Expected invalid value error, got %q\n' "${TOO_HIGH}" | ||
exit 1 | ||
fi | ||
|
||
# Verify the error when the Postgres version is not an integer. | ||
NOT_INT=$(kubectl-pgo create postgrescluster --pg-major-version=15.1 notint 2>&1) | ||
if [[ "${NOT_INT}" != "Error: invalid argument"* ]]; then | ||
printf 'Expected invalid argument error, got %q\n' "${NOT_INT}" | ||
exit 1 | ||
fi | ||
|
||
# Verify the error when the Postgres version is not a number. | ||
NOT_NUM=$(kubectl-pgo create postgrescluster --pg-major-version=x notnum 2>&1) | ||
if [[ "${NOT_NUM}" != "Error: invalid argument"* ]]; then | ||
printf 'Expected invalid argument error, got %q\n' "${NOT_NUM}" | ||
exit 1 | ||
fi | ||
|
||
# Verify the error when the Postgres version flag is not provided. | ||
MISSING=$(kubectl-pgo create postgrescluster missing 2>&1) | ||
if [[ "${MISSING}" != "Error: required flag"* ]]; then | ||
printf 'Expected required flag error, got %q\n' "${MISSING}" | ||
exit 1 | ||
fi | ||
|
||
# Verify the error when the Postgres version value is empty. | ||
NOT_SET=$(kubectl-pgo create postgrescluster --pg-major-version= notset 2>&1) | ||
if [[ "${NOT_SET}" != "Error: invalid argument"* ]]; then | ||
printf 'Expected invalid argument error, got %q\n' "${NOT_SET}" | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could test these not through KUTTL: https://gianarb.it/blog/golang-mockmania-cli-command-with-cobra
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, no, these errors are being returned by PGO -- the cli isn't generating anything in most of these cases, just passing through... how much "passing through" should we test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, maybe drop the too-low/too-high tests -- that's just what we get from PGO -- and move the other tests into the unit-testing form?
(or could leave the too-low/too-high tests here: to me, we do a lot of relying on PGO in the pgo-client, and that's OK. I don't mind a belt-and-suspenders approach, where we trust but verify.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some testing it looks like testing this behavior elsewhere would take a good bit of effort and possibly some refactoring. I think it still may be worth dropping the 'pass-through' tests, but otherwise I think KUTTL makes the most sense for now. Happy to discuss further though if there are other options.