Skip to content

Commit

Permalink
fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanxin committed Jul 18, 2024
1 parent 5815acf commit 5c942ea
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ issues:
linters: [ gci ] # Disable gci due to the test utilities dot import.
- path: tests/integration/declarative/declarative_test.go
linters: [ gci ] # Disable gci due to the test utilities dot import.
- path: tests/integration/controller/(controlplane|eventfilters|kyma|withwatcher|purge|mandatorymodule)/(.*)_test.go
- path: tests/integration/controller/(eventfilters|kyma|withwatcher|purge|mandatorymodule|kcp)/(.*)_test.go
linters: [ gci ] # Disable gci due to the test utilities dot import.
- linters:
- importas
Expand Down
5 changes: 5 additions & 0 deletions pkg/testutils/kyma.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ func EnableModule(ctx context.Context,
if err != nil {
return err
}
for _, enabledModule := range kyma.Spec.Modules {
if enabledModule.Name == module.Name {
return nil
}
}
kyma.Spec.Modules = append(
kyma.Spec.Modules, module)
err = clnt.Update(ctx, kyma)
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/controller/kcp/remote_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import (
"github.com/kyma-project/lifecycle-manager/internal/pkg/flags"
"github.com/kyma-project/lifecycle-manager/pkg/testutils/builder"

. "github.com/kyma-project/lifecycle-manager/pkg/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

. "github.com/kyma-project/lifecycle-manager/pkg/testutils"
)

var (
Expand Down Expand Up @@ -223,7 +224,7 @@ func buildSkrKyma() *v1beta2.Kyma {

func IsDescriptorCached(template *v1beta2.ModuleTemplate) bool {
key := cache.GenerateDescriptorKey(template)
result := descriptorCache.Get(key)
result := descriptorProvider.DescriptorCache.Get(key)
return result != nil
}

Expand Down
3 changes: 0 additions & 3 deletions tests/integration/controller/kcp/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"github.com/kyma-project/lifecycle-manager/internal"
"github.com/kyma-project/lifecycle-manager/internal/controller/kyma"
"github.com/kyma-project/lifecycle-manager/internal/crd"
"github.com/kyma-project/lifecycle-manager/internal/descriptor/cache"
"github.com/kyma-project/lifecycle-manager/internal/descriptor/provider"
"github.com/kyma-project/lifecycle-manager/internal/event"
"github.com/kyma-project/lifecycle-manager/internal/pkg/flags"
Expand Down Expand Up @@ -71,7 +70,6 @@ var (
ctx context.Context
cancel context.CancelFunc
cfg *rest.Config
descriptorCache *cache.DescriptorCache
descriptorProvider *provider.CachedDescriptorProvider
crdCache *crd.Cache
)
Expand Down Expand Up @@ -140,7 +138,6 @@ var _ = BeforeSuite(func() {

testEventRec := event.NewRecorderWrapper(mgr.GetEventRecorderFor(shared.OperatorName))
testSkrContextFactory = testskrcontext.NewDualClusterFactory(kcpClient.Scheme(), testEventRec)
descriptorCache = cache.NewDescriptorCache()
descriptorProvider = provider.NewCachedDescriptorProvider()
crdCache = crd.NewCache(nil)
err = (&kyma.Reconciler{
Expand Down

0 comments on commit 5c942ea

Please sign in to comment.