Skip to content

Commit

Permalink
adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amritanshusikdar committed Jan 17, 2025
1 parent 5c696d6 commit c6f52c7
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 24 deletions.
4 changes: 2 additions & 2 deletions internal/declarative/v2/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const (
)

func NewFromManager(mgr manager.Manager, requeueIntervals queue.RequeueIntervals, metrics *metrics.ManifestMetrics,
mandatoryModulesMetrics *metrics.MandatoryModulesMetrics,
manifestAPIClient ManifestAPIClient, specResolver SpecResolver, options ...Option,
mandatoryModulesMetrics *metrics.MandatoryModulesMetrics, manifestAPIClient ManifestAPIClient,
specResolver SpecResolver, options ...Option,
) *Reconciler {
reconciler := &Reconciler{}
reconciler.ManifestMetrics = metrics
Expand Down
4 changes: 2 additions & 2 deletions internal/manifest/modulecr/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestClient_SyncModuleCR(t *testing.T) {
manifest.Spec.Resource = &moduleCR

// When syncing the module CR
_, err = skrClient.SyncModuleCR(ctx, manifest)
err = skrClient.SyncModuleCR(ctx, manifest)
require.NoError(t, err)

// Then the resource CR should be created
Expand All @@ -118,7 +118,7 @@ func TestClient_SyncModuleCR(t *testing.T) {
require.NoError(t, err)

// And syncing again, it should recreate the resource
_, err = skrClient.SyncModuleCR(ctx, manifest)
err = skrClient.SyncModuleCR(ctx, manifest)
require.NoError(t, err)

err = skrClient.Get(ctx, client.ObjectKey{Name: moduleName, Namespace: shared.DefaultRemoteNamespace}, resource)
Expand Down
16 changes: 2 additions & 14 deletions pkg/module/sync/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ func (m *KymaMockMetrics) RemoveModuleStateMetrics(kymaName, moduleName string)
m.callCount++
}

type ModuleMockMetrics struct {
callCount int
}

func (m *ModuleMockMetrics) RemoveModuleStateMetrics(kymaName, moduleName string) {
m.callCount++
}

func TestMetricsOnDeleteNoLongerExistingModuleStatus(t *testing.T) {
t.Parallel()
tests := []struct {
Expand Down Expand Up @@ -90,15 +82,12 @@ func TestMetricsOnDeleteNoLongerExistingModuleStatus(t *testing.T) {
kyma := testutils.NewTestKyma("test-kyma")
configureModuleInKyma(kyma, []string{ModuleShouldKeep}, []string{testCase.ModuleInStatus})
kymaMetrics := &KymaMockMetrics{}
moduleMetrics := &ModuleMockMetrics{}
sync.DeleteNoLongerExistingModuleStatus(context.TODO(), kyma, testCase.getModule,
kymaMetrics.RemoveModuleStateMetrics, moduleMetrics.RemoveModuleStateMetrics)
kymaMetrics.RemoveModuleStateMetrics)
if testCase.expectModuleMetricsGetCalled {
assert.Equal(t, 1, kymaMetrics.callCount)
assert.Equal(t, 1, moduleMetrics.callCount)
} else {
assert.Equal(t, 0, kymaMetrics.callCount)
assert.Equal(t, 0, moduleMetrics.callCount)
}
})
}
Expand Down Expand Up @@ -162,11 +151,10 @@ func TestDeleteNoLongerExistingModuleStatus(t *testing.T) {
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
kymaMetrics := &KymaMockMetrics{}
moduleMetrics := &ModuleMockMetrics{}
kyma := testutils.NewTestKyma("test-kyma")
configureModuleInKyma(kyma, testCase.ModulesInKymaSpec, testCase.ModulesInKymaStatus)
sync.DeleteNoLongerExistingModuleStatus(context.TODO(), kyma, testCase.getModule,
kymaMetrics.RemoveModuleStateMetrics, moduleMetrics.RemoveModuleStateMetrics)
kymaMetrics.RemoveModuleStateMetrics)
var modulesInFinalModuleStatus []string
for _, moduleStatus := range kyma.Status.Modules {
modulesInFinalModuleStatus = append(modulesInFinalModuleStatus, moduleStatus.Name)
Expand Down
1 change: 0 additions & 1 deletion tests/integration/controller/eventfilters/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ var _ = BeforeSuite(func() {
InKCPMode: false,
RemoteSyncNamespace: flags.DefaultRemoteSyncNamespace,
Metrics: metrics.NewKymaMetrics(metrics.NewSharedMetrics()),
ModuleMetrics: metrics.NewModuleMetrics(),
}).SetupWithManager(mgr, ctrlruntime.Options{},
kyma.SetupOptions{ListenerAddr: randomPort})
Expect(err).ToNot(HaveOccurred())
Expand Down
1 change: 0 additions & 1 deletion tests/integration/controller/kcp/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ var _ = BeforeSuite(func() {
RemoteSyncNamespace: flags.DefaultRemoteSyncNamespace,
IsManagedKyma: true,
Metrics: metrics.NewKymaMetrics(metrics.NewSharedMetrics()),
ModuleMetrics: metrics.NewModuleMetrics(),
RemoteCatalog: remote.NewRemoteCatalogFromKyma(kcpClient, testSkrContextFactory, flags.DefaultRemoteSyncNamespace),
}).SetupWithManager(mgr, ctrlruntime.Options{},
kyma.SetupOptions{ListenerAddr: UseRandomPort})
Expand Down
1 change: 0 additions & 1 deletion tests/integration/controller/kyma/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ var _ = BeforeSuite(func() {
InKCPMode: false,
RemoteSyncNamespace: flags.DefaultRemoteSyncNamespace,
Metrics: metrics.NewKymaMetrics(metrics.NewSharedMetrics()),
ModuleMetrics: metrics.NewModuleMetrics(),
}).SetupWithManager(mgr, ctrlruntime.Options{
RateLimiter: internal.RateLimiter(
1*time.Second, 5*time.Second,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ var _ = BeforeSuite(func() {
Busy: 1 * time.Second,
Error: 1 * time.Second,
Warning: 1 * time.Second,
}, metrics.NewManifestMetrics(metrics.NewSharedMetrics()), metrics.NewMandatoryModulesMetrics(), nil,
}, metrics.NewManifestMetrics(metrics.NewSharedMetrics()), metrics.NewMandatoryModulesMetrics(),
manifestClient, manifest.NewSpecResolver(keyChainLookup, extractor), declarativev2.WithRemoteTargetCluster(
func(_ context.Context, _ declarativev2.Object) (*declarativev2.ClusterInfo, error) {
return &declarativev2.ClusterInfo{Config: authUser.Config()}, nil
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/controller/manifest/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ var _ = BeforeSuite(func() {
Busy: 1 * time.Second,
Error: 1 * time.Second,
Warning: 1 * time.Second,
}, metrics.NewManifestMetrics(metrics.NewSharedMetrics()), metrics.NewMandatoryModulesMetrics(), nil,
}, metrics.NewManifestMetrics(metrics.NewSharedMetrics()), metrics.NewMandatoryModulesMetrics(),
manifestClient, manifest.NewSpecResolver(keyChainLookup, extractor), declarativev2.WithRemoteTargetCluster(
func(_ context.Context, _ declarativev2.Object) (*declarativev2.ClusterInfo, error) {
return &declarativev2.ClusterInfo{Config: authUser.Config()}, nil
Expand Down
1 change: 0 additions & 1 deletion tests/integration/controller/withwatcher/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ var _ = BeforeSuite(func() {
RemoteSyncNamespace: flags.DefaultRemoteSyncNamespace,
InKCPMode: true,
Metrics: metrics.NewKymaMetrics(metrics.NewSharedMetrics()),
ModuleMetrics: metrics.NewModuleMetrics(),
RemoteCatalog: remote.NewRemoteCatalogFromKyma(kcpClient, testSkrContextFactory, flags.DefaultRemoteSyncNamespace),
}).SetupWithManager(mgr, ctrlruntime.Options{}, kyma.SetupOptions{ListenerAddr: listenerAddr})
Expect(err).ToNot(HaveOccurred())
Expand Down

0 comments on commit c6f52c7

Please sign in to comment.