Skip to content

Commit

Permalink
add comments to crunchy unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pooknull committed Jan 30, 2025
1 parent 942c3fd commit d193b9e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
- name: Basic tests
run: make check
- name: envtest
run: ENVTEST_K8S_VERSION=1.28 make check-envtest
run: ENVTEST_K8S_VERSION=1.32 make check-envtest
5 changes: 4 additions & 1 deletion internal/controller/postgrescluster/pgbackrest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/utils/ptr"
"k8s.io/utils/ptr" // K8SPG-714
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/manager"
Expand Down Expand Up @@ -2993,13 +2993,15 @@ func TestObserveRestoreEnv(t *testing.T) {
},
},
},
// K8SPG-714: ENVTEST_K8S_VERSION=1.32

Check failure on line 2996 in internal/controller/postgrescluster/pgbackrest_test.go

View workflow job for this annotation

GitHub Actions / runner / suggester / golangci-lint

File is not properly formatted (gofmt)
Status: batchv1.JobStatus{
StartTime: ptr.To(metav1.NewTime(time.Now().Add(-time.Minute))),
},
}

if completed != nil {
if *completed {
// K8SPG-714: ENVTEST_K8S_VERSION=1.32
restoreJob.Status.CompletionTime = ptr.To(metav1.Now())
restoreJob.Status.Succeeded = 1
restoreJob.Status.Conditions = append(restoreJob.Status.Conditions, batchv1.JobCondition{
Expand All @@ -3024,6 +3026,7 @@ func TestObserveRestoreEnv(t *testing.T) {
}
} else if failed != nil {
if *failed {
// K8SPG-714: ENVTEST_K8S_VERSION=1.32
restoreJob.Status.Conditions = append(restoreJob.Status.Conditions, batchv1.JobCondition{
Type: batchv1.JobFailureTarget,
Status: corev1.ConditionTrue,
Expand Down
18 changes: 13 additions & 5 deletions internal/controller/postgrescluster/snapshots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/discovery"
"k8s.io/utils/ptr"
"k8s.io/utils/ptr" // K8SPG-714
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/percona/percona-postgresql-operator/internal/controller/runtime"
Expand Down Expand Up @@ -501,10 +501,11 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) {

currentTime := metav1.Now()
backupJob.Status = batchv1.JobStatus{
StartTime: ptr.To(metav1.NewTime(currentTime.Add(-time.Minute))),
StartTime: ptr.To(metav1.NewTime(currentTime.Add(-time.Minute))), // K8SPG-714: ENVTEST_K8S_VERSION=1.32

Check failure on line 504 in internal/controller/postgrescluster/snapshots_test.go

View workflow job for this annotation

GitHub Actions / runner / suggester / golangci-lint

File is not properly formatted (gofmt)
Succeeded: 1,
CompletionTime: &currentTime,
}
// K8SPG-714: ENVTEST_K8S_VERSION=1.32

Check failure on line 508 in internal/controller/postgrescluster/snapshots_test.go

View workflow job for this annotation

GitHub Actions / runner / suggester / golangci-lint

File is not properly formatted (goimports)
backupJob.Status.Conditions = append(backupJob.Status.Conditions, batchv1.JobCondition{
Type: batchv1.JobSuccessCriteriaMet,
Status: corev1.ConditionTrue,
Expand Down Expand Up @@ -569,9 +570,10 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) {

backupJob.Status = batchv1.JobStatus{
Succeeded: 1,
StartTime: ptr.To(metav1.NewTime(earlierTime.Add(-time.Minute))),
StartTime: ptr.To(metav1.NewTime(earlierTime.Add(-time.Minute))), // K8SPG-714: ENVTEST_K8S_VERSION=1.32
CompletionTime: &earlierTime,
}
// K8SPG-714: ENVTEST_K8S_VERSION=1.32
backupJob.Status.Conditions = append(backupJob.Status.Conditions, batchv1.JobCondition{
Type: batchv1.JobSuccessCriteriaMet,
Status: corev1.ConditionTrue,
Expand Down Expand Up @@ -600,6 +602,7 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) {
restoreJob.Status = batchv1.JobStatus{
Succeeded: 1,
CompletionTime: &currentTime,
// K8SPG-714: ENVTEST_K8S_VERSION=1.32
StartTime: ptr.To(metav1.NewTime(currentTime.Add(-time.Minute))),
Conditions: []batchv1.JobCondition{
{
Expand Down Expand Up @@ -671,8 +674,9 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) {
backupJob.Status = batchv1.JobStatus{
Succeeded: 1,
CompletionTime: &earlierTime,
StartTime: ptr.To(metav1.NewTime(earlierTime.Add(-time.Minute))),
StartTime: ptr.To(metav1.NewTime(earlierTime.Add(-time.Minute))), // K8SPG-714: ENVTEST_K8S_VERSION=1.32
}
// K8SPG-714: ENVTEST_K8S_VERSION=1.32
backupJob.Status.Conditions = append(backupJob.Status.Conditions, batchv1.JobCondition{
Type: batchv1.JobSuccessCriteriaMet,
Status: corev1.ConditionTrue,
Expand Down Expand Up @@ -702,8 +706,9 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) {
Succeeded: 0,
Failed: 1,
CompletionTime: &currentTime,
StartTime: ptr.To(metav1.NewTime(currentTime.Add(-time.Minute))),
StartTime: ptr.To(metav1.NewTime(currentTime.Add(-time.Minute))), // K8SPG-714: ENVTEST_K8S_VERSION=1.32
}
// K8SPG-714: ENVTEST_K8S_VERSION=1.32
restoreJob.Status.Conditions = append(backupJob.Status.Conditions, batchv1.JobCondition{
Type: batchv1.JobSuccessCriteriaMet,
Status: corev1.ConditionTrue,
Expand Down Expand Up @@ -983,6 +988,7 @@ func TestGetLatestCompleteBackupJob(t *testing.T) {
job1.Status = batchv1.JobStatus{
Succeeded: 1,
CompletionTime: &currentTime,
// K8SPG-714: ENVTEST_K8S_VERSION=1.32
StartTime: ptr.To(metav1.NewTime(currentTime.Add(-time.Minute))),
Conditions: []batchv1.JobCondition{
{
Expand Down Expand Up @@ -1032,6 +1038,7 @@ func TestGetLatestCompleteBackupJob(t *testing.T) {
job1.Status = batchv1.JobStatus{
Succeeded: 1,
CompletionTime: &currentTime,
// K8SPG-714: ENVTEST_K8S_VERSION=1.32
StartTime: ptr.To(metav1.NewTime(currentTime.Add(-time.Minute))),
Conditions: []batchv1.JobCondition{
{
Expand All @@ -1058,6 +1065,7 @@ func TestGetLatestCompleteBackupJob(t *testing.T) {
job2.Status = batchv1.JobStatus{
Succeeded: 1,
CompletionTime: &earlierTime,
// K8SPG-714: ENVTEST_K8S_VERSION=1.32
StartTime: ptr.To(metav1.NewTime(earlierTime.Add(-time.Minute))),
Conditions: []batchv1.JobCondition{
{
Expand Down

0 comments on commit d193b9e

Please sign in to comment.