Skip to content

Commit

Permalink
🐛 Fetch more assets from upstream (#931)
Browse files Browse the repository at this point in the history
This fixes the failing OLM tests where we have more workloads than for other tests.
The default number of assets fetched from upstream is 25. That wasn't enough for OLM clusters.

Signed-off-by: Christian Zunker <[email protected]>
  • Loading branch information
czunker authored Nov 10, 2023
1 parent 78042ca commit 60192c0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ test/integration: manifests generate generate-manifests load-k3d
else
test/integration: manifests generate generate-manifests load-minikube
endif
go test -ldflags $(LDFLAGS) -v -timeout 35m -p 1 ./tests/integration/...
go test -ldflags $(LDFLAGS) -v -timeout 45m -p 1 ./tests/integration/...

ifeq ($(K8S_DISTRO),gke)
test/integration/ci: manifests generate generate-manifests gotestsum
Expand All @@ -157,7 +157,7 @@ test/integration/ci: manifests generate generate-manifests gotestsum load-k3d
else
test/integration/ci: manifests generate generate-manifests gotestsum load-minikube
endif
$(GOTESTSUM) --junitfile integration-tests.xml -- ./tests/integration/... -ldflags $(LDFLAGS) -v -timeout 35m -p 1
$(GOTESTSUM) --junitfile integration-tests.xml -- ./tests/integration/... -ldflags $(LDFLAGS) -v -timeout 45m -p 1

##@ Build

Expand Down
4 changes: 2 additions & 2 deletions tests/framework/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func (i *MondooInstaller) InstallOperator() error {
zap.S().Info("The Mondoo operator is installed externally. Skipping installation...")
// We had race conditions were the integration wasn't ready when the operator tried to exchange the token
// for a service account. This sleep should give the integration enough time to get ready.
zap.S().Infof("Sleeping for 30 seconds to allow the token to get active")
time.Sleep(30 * time.Second)
zap.S().Infof("Sleeping for 10 seconds to allow the token to get active")
time.Sleep(10 * time.Second)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion tests/framework/nexus/assets/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func ListAssetsWithScores(
AssetType string `graphql:"asset_type"`
}
}
} `graphql:"assets(spaceMrn: $spaceMrn)"`
} `graphql:"assets(spaceMrn: $spaceMrn, first: 100)"`
}

err := gqlClient.Query(ctx, &q, map[string]interface{}{"spaceMrn": mondoogql.String(spaceMrn)})
Expand Down
9 changes: 9 additions & 0 deletions tests/integration/audit_config_base_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func (s *AuditConfigBaseSuite) SetupSuite() {
s.Require().NoError(err, "Failed to create Nexus client")
s.spaceClient, err = nexusClient.CreateSpace()
s.Require().NoError(err, "Failed to create Nexus space")
log.Log.Info("Created Nexus space", "space", s.spaceClient.Mrn())

// TODO: this is only needed because the integration creation is not part of the MondooInstaller struct.
// That code will move there once all tests are migrated to use the E2E approach.
Expand Down Expand Up @@ -192,11 +193,15 @@ func (s *AuditConfigBaseSuite) testMondooAuditConfigKubernetesResources(auditCon
// Verify the workloads have been sent upstream and have scores.
workloadNames, err := s.testCluster.K8sHelper.GetWorkloadNames(s.ctx)
s.NoError(err, "Failed to get workload names.")
zap.S().Info("number of workload", " amount ", len(workloadNames))

time.Sleep(10 * time.Second)

// The number of assets from upstream is limited by paganiation.
// In case we have more than 100 workloads, we need to call this mutlple times, with different page numbers.
assets, err := s.spaceClient.ListAssetsWithScores(s.ctx)
s.NoError(err, "Failed to list assets with scores.")
zap.S().Info("number of assets from upstream: ", len(assets))

// TODO: the cluster name is non-deterministic currently so we cannot test for it
assetsExceptCluster := utils.ExcludeClusterAsset(assets)
Expand Down Expand Up @@ -267,6 +272,8 @@ func (s *AuditConfigBaseSuite) testMondooAuditConfigContainers(auditConfig mondo
time.Sleep(10 * time.Second)

// Verify the container images have been sent upstream and have scores.
// The number of assets from upstream is limited by paganiation.
// In case we have more than 100 workloads, we need to call this mutlple times, with different page numbers.
assets, err := s.spaceClient.ListAssetsWithScores(s.ctx)
s.NoError(err, "Failed to list assets with scores")

Expand Down Expand Up @@ -372,6 +379,8 @@ func (s *AuditConfigBaseSuite) testMondooAuditConfigNodes(auditConfig mondoov2.M

time.Sleep(10 * time.Second)

// The number of assets from upstream is limited by paganiation.
// In case we have more than 100 workloads, we need to call this mutlple times, with different page numbers.
assets, err := s.spaceClient.ListAssetsWithScores(s.ctx)
s.NoError(err, "Failed to list assets")
assetNames := utils.AssetNames(assets)
Expand Down

0 comments on commit 60192c0

Please sign in to comment.