Skip to content

Commit ee388a0

Browse files
committed
feat: remove reference validation
1 parent e0c08c8 commit ee388a0

5 files changed

Lines changed: 16 additions & 75 deletions

File tree

stackgres-k8s/e2e/spec/objectstorage-removal

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,20 @@ e2e_test() {
2424
}
2525

2626
delete_with_cluster() {
27-
if ERROR="$(kubectl delete -n "$CLUSTER_NAMESPACE" sgobjectstorages.stackgres.io backupconf 2>&1)"
27+
if ERROR="$(kubectl delete -n "$CLUSTER_NAMESPACE" --dry-run=server sgobjectstorages.stackgres.io backupconf 2>&1)"
2828
then
29-
fail "It should not be able to delete sgobjectstorage"
30-
else
31-
success "Good it has failed"
32-
fi
33-
34-
if echo "$ERROR" | grep -q "Can't delete sgobjectstorages.stackgres.io backupconf"
35-
then
36-
success "Error message was the expected"
37-
return 0
29+
success "Good. It has deleted the configuration"
3830
else
39-
ERROR="$(cat "$LOG_PATH/test1.log")"
40-
fail "Error is not what it should be. ERROR ${ERROR}"
31+
fail "It should be able to delete the posgresconf. ERROR ${ERROR}"
4132
fi
4233
}
4334

4435
delete_whitout_cluster() {
4536
kubectl get -n "$CLUSTER_NAMESPACE" sgclusters.stackgres.io "$CLUSTER_NAME" -o yaml | kubectl delete -f -
4637

47-
if ERROR="$(kubectl delete -n "$CLUSTER_NAMESPACE" sgobjectstorages.stackgres.io backupconf 2>&1)"
38+
if ERROR="$(kubectl delete -n "$CLUSTER_NAMESPACE" --dry-run=server sgobjectstorages.stackgres.io backupconf 2>&1)"
4839
then
4940
success "Good. It has deleted the configuration"
50-
return 0
5141
else
5242
fail "It should be able to delete the posgresconf. ERROR ${ERROR}"
5343
fi

stackgres-k8s/e2e/spec/operator-pgconfig-api

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -333,22 +333,9 @@ test_constraint_violation_api_error() {
333333

334334
local HTTP_STATUS
335335

336-
HTTP_STATUS="$(run_curl -r "stackgres/sgpgconfigs" -n "$CLUSTER_NAMESPACE" -d "$LOG_PATH/invalid-pgconfig.json" -e '-X POST -w %{http_code} -o /dev/null')"
336+
HTTP_STATUS="$(run_curl -r "stackgres/sgpgconfigs" -n "$CLUSTER_NAMESPACE" -d "$LOG_PATH/invalid-pgconfig.json" -e '-X POST -w %{http_code} -o /dev/null')"
337337

338-
assert_string_equal "422" "$HTTP_STATUS"
339-
340-
ERROR_RESPONSE="$(run_curl -r "stackgres/sgpgconfigs" -n "$CLUSTER_NAMESPACE" -d "$LOG_PATH/invalid-pgconfig.json" -e '-X POST')"
341-
342-
EXPECTED_ERROR_TYPE="constraint-violation"
343-
EXPECTED_ERROR_TITLE="do not comply with the syntactic rules"
344-
EXPECTED_ERROR_DETAIL="spec.postgresVersion in body"
345-
EXPECTED_ERROR_FIELD="postgresVersion"
346-
347-
if ! assert_api_error "$ERROR_RESPONSE"
348-
then
349-
EXPECTED_ERROR_DETAIL="Required value"
350-
assert_api_error "$ERROR_RESPONSE"
351-
fi
338+
assert_string_equal "200" "$HTTP_STATUS"
352339
}
353340

354341
test_authentication_api_error() {

stackgres-k8s/e2e/spec/operator-pgpooling-api

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -336,25 +336,14 @@ test_api_delete_pgpooling_is_invible() {
336336
}
337337

338338
test_dependency_api_error(){
339-
340339
remove_cluster "$CLUSTER_NAME" "$CLUSTER_NAMESPACE"
341340
create_or_replace_cluster "$CLUSTER_NAME" "$CLUSTER_NAMESPACE" 1
342341

343342
local HTTP_STATUS
344343

345344
HTTP_STATUS="$(run_curl -r "stackgres/sgpoolconfigs" -n "$CLUSTER_NAMESPACE" -d "$LOG_PATH/default-pgpooling.json" -e '-X DELETE -w %{http_code} -o /dev/null')"
346345

347-
assert_string_equal "409" "$HTTP_STATUS"
348-
349-
ERROR_RESPONSE="$(run_curl -r "stackgres/sgpoolconfigs" -n "$CLUSTER_NAMESPACE" -d "$LOG_PATH/default-pgpooling.json" -e '-X DELETE')"
350-
351-
EXPECTED_ERROR_TYPE="forbidden-configuration-deletion"
352-
EXPECTED_ERROR_TITLE="Forbidden configuration deletion"
353-
EXPECTED_ERROR_DETAIL="Can't delete sgpoolconfigs.stackgres.io $PGPOOLING"
354-
EXPECTED_ERROR_FIELD=""
355-
356-
assert_api_error "$ERROR_RESPONSE"
357-
346+
assert_string_equal "204" "$HTTP_STATUS"
358347
}
359348

360349
test_authentication_api_error() {
@@ -390,4 +379,4 @@ check_authentication_error() {
390379
echo "Request returned unexpected response status $HTTP_STATUS instead of the expected authentication error."
391380
return 1
392381
fi
393-
}
382+
}

stackgres-k8s/e2e/spec/pgbouncer-removal

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,21 @@ e2e_test() {
1515
}
1616

1717
delete_with_cluster() {
18-
if ERROR_MESSAGE="$( { kubectl delete -n "$CLUSTER_NAMESPACE" sgpoolconfigs.stackgres.io pgbouncerconf; } 2>&1 )"
18+
if ERROR="$(kubectl delete -n "$CLUSTER_NAMESPACE" --dry-run=server sgpoolconfigs.stackgres.io pgbouncerconf)"
1919
then
20-
echo "ERROR: It should not be able to delete pgbouncerconf"
21-
return 1
22-
else
23-
success "Good it has failed"
24-
fi
25-
26-
echo "$ERROR_MESSAGE" > "${LOG_PATH}/test1.log"
27-
28-
if grep -q "Can't delete sgpoolconfigs.stackgres.io pgbouncerconf" "$LOG_PATH/test1.log"
29-
then
30-
success "Error message was the expected"
31-
return 0
20+
success "Good. It has deleted the configuration"
3221
else
33-
ERROR="$(cat "$LOG_PATH/test1.log")"
34-
fail "Error is not what it should be. ERROR: ${ERROR}"
22+
fail "It should be able to delete the pgbouncerconf. ERROR $ERROR"
3523
fi
3624
}
3725

3826
delete_whitout_cluster() {
3927
kubectl get -n "$CLUSTER_NAMESPACE" sgclusters.stackgres.io "$CLUSTER_NAME" -o yaml | kubectl delete -f - > /dev/null
4028

41-
if kubectl delete -n "$CLUSTER_NAMESPACE" sgpoolconfigs.stackgres.io pgbouncerconf
29+
if ERROR="$(kubectl delete -n "$CLUSTER_NAMESPACE" --dry-run=server sgpoolconfigs.stackgres.io pgbouncerconf)"
4230
then
4331
success "Good. It has deleted the configuration"
44-
return 0
4532
else
46-
ERROR="$(kubectl delete -n "$CLUSTER_NAMESPACE" sgpoolconfigs.stackgres.io pgbouncerconf)"
4733
fail "It should be able to delete the pgbouncerconf. ERROR $ERROR"
4834
fi
4935
}

stackgres-k8s/e2e/spec/pgconfig-removal

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,20 @@ e2e_test() {
1515
}
1616

1717
delete_with_cluster() {
18-
if ERROR_MESSAGE="$(kubectl delete -n "$CLUSTER_NAMESPACE" sgpgconfigs.stackgres.io postgresconf 2>&1)"
18+
if ERROR="$(kubectl delete -n "$CLUSTER_NAMESPACE" --dry-run=server sgpgconfigs.stackgres.io postgresconf 2>&1)"
1919
then
20-
fail "It should not be able to delete sgspconfig"
21-
else
22-
success "Good it has failed"
23-
fi
24-
25-
echo "$ERROR_MESSAGE" > "$LOG_PATH/test1.log"
26-
if grep -q "Can't delete sgpgconfigs.stackgres.io postgresconf" "$LOG_PATH/test1.log"
27-
then
28-
success "Error message was the expected"
29-
return 0
20+
success "Good. It has deleted the configuration"
3021
else
31-
ERROR="$(cat "$LOG_PATH/test1.log")"
32-
fail "Error is not what it should be. ERROR ${ERROR}"
22+
fail "It should be able to delete the posgresconf. ERROR ${ERROR}"
3323
fi
3424
}
3525

3626
delete_whitout_cluster() {
3727
kubectl get -n "$CLUSTER_NAMESPACE" sgclusters.stackgres.io "$CLUSTER_NAME" -o yaml | kubectl delete -f -
3828

39-
if ERROR="$(kubectl delete -n "$CLUSTER_NAMESPACE" sgpgconfigs.stackgres.io postgresconf 2>&1)"
29+
if ERROR="$(kubectl delete -n "$CLUSTER_NAMESPACE" --dry-run=server sgpgconfigs.stackgres.io postgresconf 2>&1)"
4030
then
4131
success "Good. It has deleted the configuration"
42-
return 0
4332
else
4433
fail "It should be able to delete the posgresconf. ERROR ${ERROR}"
4534
fi

0 commit comments

Comments
 (0)