Skip to content

Commit

Permalink
e2e: Improve rendering status validation (#310)
Browse files Browse the repository at this point in the history
- Test RSync status, instead of using an internal nomos CLI
  function.
- Validate source, rendering, and sync status, not just rendering,
  to ensure no other errors are being returned.
- Validate Syncing status condition too.

Change-Id: I127929f45aa672ddf66dc7db354025c5d1a7cd44
  • Loading branch information
karlkfi authored Dec 19, 2024
1 parent 911016f commit 2416e37
Show file tree
Hide file tree
Showing 2 changed files with 320 additions and 57 deletions.
23 changes: 0 additions & 23 deletions e2e/nomostest/testpredicates/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
nomosstatus "kpt.dev/configsync/cmd/nomos/status"
"kpt.dev/configsync/e2e/nomostest/retry"
"kpt.dev/configsync/e2e/nomostest/testkubeclient"
"kpt.dev/configsync/e2e/nomostest/testlogger"
Expand Down Expand Up @@ -1497,28 +1496,6 @@ func ValidateError(errs []v1beta1.ConfigSyncError, code, message string, resourc
return fmt.Errorf("error %s not present: %s", code, log.AsJSON(errs))
}

// RootSyncHasNomosStatus returns an error if the RootSync does not have the
// specified commit or status according to `nomos status` (RootRepoStatus).
func RootSyncHasNomosStatus(expectedCommit, expectedStatus string) Predicate {
return func(o client.Object) error {
if o == nil {
return ErrObjectNotFound
}
rs, ok := o.(*v1beta1.RootSync)
if !ok {
return WrongTypeErr(o, &v1beta1.RootSync{})
}
repoStatus := nomosstatus.RootRepoStatus(rs, nil, false)
commit := repoStatus.GetCommit()
status := repoStatus.GetStatus()
if commit != expectedCommit || status != expectedStatus {
return fmt.Errorf("expected RepoStatus commit %q and status %q, but found %q and %q: error summary: %v",
expectedCommit, expectedStatus, commit, status, repoStatus.GetErrorSummary())
}
return nil
}
}

// ConfigMapHasData returns an error if the ConfigMap doesn't contain the given key value pair
func ConfigMapHasData(key string, value string) Predicate {
return func(o client.Object) error {
Expand Down
Loading

0 comments on commit 2416e37

Please sign in to comment.