Skip to content

Cannot run tests #73

@porridge

Description

@porridge

I tried make test-all but it fails for mysterious reason:

output
[roxie]$ make test-all 
🧪 Running unit tests...
go test -v -race -coverprofile=coverage.out ./...
# github.com/stackrox/roxie/internal/deployer
go: no such tool "covdata"
# github.com/stackrox/roxie/cmd
go: no such tool "covdata"
# github.com/stackrox/roxie/internal/component
go: no such tool "covdata"
# github.com/stackrox/roxie/internal/logger
go: no such tool "covdata"
# github.com/stackrox/roxie/internal/portforward
go: no such tool "covdata"
=== RUN   TestDefaultDetector_Detect
=== RUN   TestDefaultDetector_Detect/kind_cluster_with_standard_prefix
=== RUN   TestDefaultDetector_Detect/kind_cluster_simple_name
=== RUN   TestDefaultDetector_Detect/kind_cluster_with_uppercase
--- PASS: TestDefaultDetector_Detect (0.00s)
    --- PASS: TestDefaultDetector_Detect/kind_cluster_with_standard_prefix (0.00s)
    --- PASS: TestDefaultDetector_Detect/kind_cluster_simple_name (0.00s)
    --- PASS: TestDefaultDetector_Detect/kind_cluster_with_uppercase (0.00s)
=== RUN   TestDefaultApplicator_Apply
=== RUN   TestDefaultApplicator_Apply/kind_cluster_with_default_params
=== RUN   TestDefaultApplicator_Apply/kind_cluster_with_already_correct_params
=== RUN   TestDefaultApplicator_Apply/kind_cluster_with_partial_match
=== RUN   TestDefaultApplicator_Apply/unknown_cluster_type
=== RUN   TestDefaultApplicator_Apply/minikube_cluster
--- PASS: TestDefaultApplicator_Apply (0.00s)
    --- PASS: TestDefaultApplicator_Apply/kind_cluster_with_default_params (0.00s)
    --- PASS: TestDefaultApplicator_Apply/kind_cluster_with_already_correct_params (0.00s)
    --- PASS: TestDefaultApplicator_Apply/kind_cluster_with_partial_match (0.00s)
    --- PASS: TestDefaultApplicator_Apply/unknown_cluster_type (0.00s)
    --- PASS: TestDefaultApplicator_Apply/minikube_cluster (0.00s)
=== RUN   TestManager_ApplyConvenienceDefaults
=== RUN   TestManager_ApplyConvenienceDefaults/kind_cluster_detection_and_defaults
00:00 Detected kind cluster: using --resources=small --exposure=none with port-forwarding
=== RUN   TestManager_ApplyConvenienceDefaults/gke_cluster_no_changes
--- PASS: TestManager_ApplyConvenienceDefaults (0.00s)
    --- PASS: TestManager_ApplyConvenienceDefaults/kind_cluster_detection_and_defaults (0.00s)
    --- PASS: TestManager_ApplyConvenienceDefaults/gke_cluster_no_changes (0.00s)
=== RUN   TestClusterType_String
=== RUN   TestClusterType_String/kind
=== RUN   TestClusterType_String/minikube
=== RUN   TestClusterType_String/k3s
=== RUN   TestClusterType_String/unknown
--- PASS: TestClusterType_String (0.00s)
    --- PASS: TestClusterType_String/kind (0.00s)
    --- PASS: TestClusterType_String/minikube (0.00s)
    --- PASS: TestClusterType_String/k3s (0.00s)
    --- PASS: TestClusterType_String/unknown (0.00s)
PASS
coverage: 88.6% of statements
ok  	github.com/stackrox/roxie/internal/clusterdefaults	1.017s	coverage: 88.6% of statements
=== RUN   TestIsRunningInContainer
    detect_test.go:14: IsRunningInContainer() = false
    detect_test.go:21: Detected running on host (not in container)
--- PASS: TestIsRunningInContainer (0.00s)
PASS
coverage: 75.0% of statements
ok  	github.com/stackrox/roxie/internal/containerutil	1.012s	coverage: 75.0% of statements
=== RUN   TestGetAndVerifyCredentialsFromEnv
--- PASS: TestGetAndVerifyCredentialsFromEnv (0.00s)
=== RUN   TestGetAndVerifyCredentialsNoCredentials
00:00 REGISTRY_USERNAME/REGISTRY_PASSWORD unset. Trying to obtain Docker credentials from config file: /tmp/nix-shell.OAKtwZ/nix-shell.bWk6oH/TestGetAndVerifyCredentialsNoCredentials1602006680/001/.docker/config.json
--- PASS: TestGetAndVerifyCredentialsNoCredentials (0.00s)
PASS
coverage: 25.9% of statements
ok  	github.com/stackrox/roxie/internal/dockerauth	1.013s	coverage: 25.9% of statements
=== RUN   TestDetectClusterType_GKE
--- PASS: TestDetectClusterType_GKE (0.00s)
=== RUN   TestDetectClusterType_GKE_ExactMatch
--- PASS: TestDetectClusterType_GKE_ExactMatch (0.00s)
=== RUN   TestDetectClusterType_OpenShift4
--- PASS: TestDetectClusterType_OpenShift4 (0.00s)
=== RUN   TestDetectClusterType_OpenShift4_WrongHostname
--- PASS: TestDetectClusterType_OpenShift4_WrongHostname (0.00s)
=== RUN   TestDetectClusterType_OpenShift4_NoAPIResources
--- PASS: TestDetectClusterType_OpenShift4_NoAPIResources (0.00s)
=== RUN   TestDetectClusterType_Kind
--- PASS: TestDetectClusterType_Kind (0.00s)
=== RUN   TestDetectClusterType_Kind_CaseInsensitive
--- PASS: TestDetectClusterType_Kind_CaseInsensitive (0.00s)
=== RUN   TestDetectClusterType_EmptyContext
--- PASS: TestDetectClusterType_EmptyContext (0.00s)
=== RUN   TestDetectClusterType_Unknown
--- PASS: TestDetectClusterType_Unknown (0.00s)
=== RUN   TestDetectClusterType_GKE_DifferentProject
--- PASS: TestDetectClusterType_GKE_DifferentProject (0.00s)
=== RUN   TestIsOpenShift4
=== RUN   TestIsOpenShift4/OpenShift_4_with_clusterversions
=== RUN   TestIsOpenShift4/OpenShift_4_with_other_config_resources
=== RUN   TestIsOpenShift4/No_OpenShift_resources
=== RUN   TestIsOpenShift4/Empty_list
--- PASS: TestIsOpenShift4 (0.00s)
    --- PASS: TestIsOpenShift4/OpenShift_4_with_clusterversions (0.00s)
    --- PASS: TestIsOpenShift4/OpenShift_4_with_other_config_resources (0.00s)
    --- PASS: TestIsOpenShift4/No_OpenShift_resources (0.00s)
    --- PASS: TestIsOpenShift4/Empty_list (0.00s)
=== RUN   TestGetServerURL
=== RUN   TestGetServerURL/Single_cluster
=== RUN   TestGetServerURL/Multiple_clusters_-_returns_first
=== RUN   TestGetServerURL/No_clusters
--- PASS: TestGetServerURL (0.00s)
    --- PASS: TestGetServerURL/Single_cluster (0.00s)
    --- PASS: TestGetServerURL/Multiple_clusters_-_returns_first (0.00s)
    --- PASS: TestGetServerURL/No_clusters (0.00s)
=== RUN   TestClusterTypeString
=== RUN   TestClusterTypeString/InfraGKE
=== RUN   TestClusterTypeString/InfraOpenShift4
=== RUN   TestClusterTypeString/LocalKind
=== RUN   TestClusterTypeString/ClusterTypeUnknown
--- PASS: TestClusterTypeString (0.00s)
    --- PASS: TestClusterTypeString/InfraGKE (0.00s)
    --- PASS: TestClusterTypeString/InfraOpenShift4 (0.00s)
    --- PASS: TestClusterTypeString/LocalKind (0.00s)
    --- PASS: TestClusterTypeString/ClusterTypeUnknown (0.00s)
PASS
coverage: 24.4% of statements
ok  	github.com/stackrox/roxie/internal/env	1.017s	coverage: 24.4% of statements
=== RUN   TestMergeMaps
--- PASS: TestMergeMaps (0.00s)
=== RUN   TestMergeMapsMultipleOverlays
--- PASS: TestMergeMapsMultipleOverlays (0.00s)
=== RUN   TestLoadYAMLFileValid
--- PASS: TestLoadYAMLFileValid (0.00s)
=== RUN   TestLoadYAMLFileEmpty
--- PASS: TestLoadYAMLFileEmpty (0.00s)
=== RUN   TestLoadYAMLFileNonExistent
--- PASS: TestLoadYAMLFileNonExistent (0.00s)
=== RUN   TestLoadYAMLFileInvalidYAML
--- PASS: TestLoadYAMLFileInvalidYAML (0.00s)
=== RUN   TestDeepCopy
--- PASS: TestDeepCopy (0.00s)
PASS
coverage: 40.6% of statements
ok  	github.com/stackrox/roxie/internal/helpers	1.013s	coverage: 40.6% of statements
=== RUN   TestImageCacheLoadSaveRoundtrip
--- PASS: TestImageCacheLoadSaveRoundtrip (0.00s)
=== RUN   TestImageCacheHandlesOldFormat
--- PASS: TestImageCacheHandlesOldFormat (0.00s)
=== RUN   TestImageCacheMaxEntries
--- PASS: TestImageCacheMaxEntries (0.00s)
=== RUN   TestImageCacheMoveToEnd
--- PASS: TestImageCacheMoveToEnd (0.00s)
PASS
coverage: 33.7% of statements
ok  	github.com/stackrox/roxie/internal/imagecache	1.018s	coverage: 33.7% of statements
?   	github.com/stackrox/roxie/tests/testhelpers	[no test files]
make: *** [Makefile:91: test] Error 1

Perhaps it's the missing covdata? I tried in nix develop as advised by the README, but this fails for another reason that I don't understand:

`nix develop` output
[roxie]$ nix develop
error: experimental Nix feature 'nix-command' is disabled; add '--extra-experimental-features nix-command' to enable it
[roxie]$ nix --extra-experimental-features nix-command develop
error: experimental Nix feature 'flakes' is disabled; add '--extra-experimental-features flakes' to enable it
[roxie]$ nix --extra-experimental-features nix-command --extra-experimental-features flakes develop
warning: Ignoring setting 'auto-allocate-uids' because experimental feature 'auto-allocate-uids' is not enabled
warning: Ignoring setting 'impure-env' because experimental feature 'configurable-impure-env' is not enabled
error: hash mismatch in fixed-output derivation '/nix/store/1qacmncwjilm31lm7zgh51dkhpkgw85g-roxie-0.1-f0550a0-go-modules.drv':
         specified: sha256-bIlSwBh8WJtscEtjQIvxdIK9sFR7aQNV2BUeVNj8qbA=
            got:    sha256-Fb+hKW5Wr8Wusc2iCSI6AmMIof0lAKCSFU80IZ0+UtQ=
error: 1 dependencies of derivation '/nix/store/za9jv7p2jyg8k585ib98cx508ssz4q3x-roxie-0.1-f0550a0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/nm399yq6y0ylwdzd0i6r60m68xijjx34-nix-shell-env.drv' failed to build

I think covdata is only available in go newer than the 1.22 I had installed. TIL the auto-fetching of go versions by the go tool does not cover all cases. So I upgraded to go 1.26 and now make test-all fails for some other reason:

=== RUN   TestDetectClusterType_Integration
00:00 Using kubeconfig /home/mowsiany/.kube/config
    env_integration_test.go:12: Initialize() failed: failed to initialize environment: failed to retrieve API resources: exit status 1
--- FAIL: TestDetectClusterType_Integration (0.52s)
FAIL
FAIL	github.com/stackrox/roxie/internal/env	0.519s
full `make test-all` ouput
[roxie]$ make test-all
🧪 Running unit tests...
go test -v -race -coverprofile=coverage.out ./...
	github.com/stackrox/roxie/cmd		coverage: 0.0% of statements
=== RUN   TestDefaultDetector_Detect
=== RUN   TestDefaultDetector_Detect/kind_cluster_with_standard_prefix
=== RUN   TestDefaultDetector_Detect/kind_cluster_simple_name
=== RUN   TestDefaultDetector_Detect/kind_cluster_with_uppercase
--- PASS: TestDefaultDetector_Detect (0.00s)
    --- PASS: TestDefaultDetector_Detect/kind_cluster_with_standard_prefix (0.00s)
    --- PASS: TestDefaultDetector_Detect/kind_cluster_simple_name (0.00s)
    --- PASS: TestDefaultDetector_Detect/kind_cluster_with_uppercase (0.00s)
=== RUN   TestDefaultApplicator_Apply
=== RUN   TestDefaultApplicator_Apply/kind_cluster_with_default_params
=== RUN   TestDefaultApplicator_Apply/kind_cluster_with_already_correct_params
=== RUN   TestDefaultApplicator_Apply/kind_cluster_with_partial_match
=== RUN   TestDefaultApplicator_Apply/unknown_cluster_type
=== RUN   TestDefaultApplicator_Apply/minikube_cluster
--- PASS: TestDefaultApplicator_Apply (0.00s)
    --- PASS: TestDefaultApplicator_Apply/kind_cluster_with_default_params (0.00s)
    --- PASS: TestDefaultApplicator_Apply/kind_cluster_with_already_correct_params (0.00s)
    --- PASS: TestDefaultApplicator_Apply/kind_cluster_with_partial_match (0.00s)
    --- PASS: TestDefaultApplicator_Apply/unknown_cluster_type (0.00s)
    --- PASS: TestDefaultApplicator_Apply/minikube_cluster (0.00s)
=== RUN   TestManager_ApplyConvenienceDefaults
=== RUN   TestManager_ApplyConvenienceDefaults/kind_cluster_detection_and_defaults
00:00 Detected kind cluster: using --resources=small --exposure=none with port-forwarding
=== RUN   TestManager_ApplyConvenienceDefaults/gke_cluster_no_changes
--- PASS: TestManager_ApplyConvenienceDefaults (0.00s)
    --- PASS: TestManager_ApplyConvenienceDefaults/kind_cluster_detection_and_defaults (0.00s)
    --- PASS: TestManager_ApplyConvenienceDefaults/gke_cluster_no_changes (0.00s)
=== RUN   TestClusterType_String
=== RUN   TestClusterType_String/kind
=== RUN   TestClusterType_String/minikube
=== RUN   TestClusterType_String/k3s
=== RUN   TestClusterType_String/unknown
--- PASS: TestClusterType_String (0.00s)
    --- PASS: TestClusterType_String/kind (0.00s)
    --- PASS: TestClusterType_String/minikube (0.00s)
    --- PASS: TestClusterType_String/k3s (0.00s)
    --- PASS: TestClusterType_String/unknown (0.00s)
PASS
coverage: 88.6% of statements
ok  	github.com/stackrox/roxie/internal/clusterdefaults	1.015s	coverage: 88.6% of statements
	github.com/stackrox/roxie/internal/component		coverage: 0.0% of statements
=== RUN   TestIsRunningInContainer
    detect_test.go:14: IsRunningInContainer() = false
    detect_test.go:21: Detected running on host (not in container)
--- PASS: TestIsRunningInContainer (0.00s)
PASS
coverage: 75.0% of statements
ok  	github.com/stackrox/roxie/internal/containerutil	1.018s	coverage: 75.0% of statements
	github.com/stackrox/roxie/internal/deployer		coverage: 0.0% of statements
=== RUN   TestGetAndVerifyCredentialsFromEnv
--- PASS: TestGetAndVerifyCredentialsFromEnv (0.00s)
=== RUN   TestGetAndVerifyCredentialsNoCredentials
00:00 REGISTRY_USERNAME/REGISTRY_PASSWORD unset. Trying to obtain Docker credentials from config file: /tmp/nix-shell.OAKtwZ/nix-shell.RbIcT2/TestGetAndVerifyCredentialsNoCredentials3856234508/001/.docker/config.json
--- PASS: TestGetAndVerifyCredentialsNoCredentials (0.00s)
PASS
coverage: 25.9% of statements
ok  	github.com/stackrox/roxie/internal/dockerauth	1.014s	coverage: 25.9% of statements
=== RUN   TestDetectClusterType_GKE
--- PASS: TestDetectClusterType_GKE (0.00s)
=== RUN   TestDetectClusterType_GKE_ExactMatch
--- PASS: TestDetectClusterType_GKE_ExactMatch (0.00s)
=== RUN   TestDetectClusterType_OpenShift4
--- PASS: TestDetectClusterType_OpenShift4 (0.00s)
=== RUN   TestDetectClusterType_OpenShift4_WrongHostname
--- PASS: TestDetectClusterType_OpenShift4_WrongHostname (0.00s)
=== RUN   TestDetectClusterType_OpenShift4_NoAPIResources
--- PASS: TestDetectClusterType_OpenShift4_NoAPIResources (0.00s)
=== RUN   TestDetectClusterType_Kind
--- PASS: TestDetectClusterType_Kind (0.00s)
=== RUN   TestDetectClusterType_Kind_CaseInsensitive
--- PASS: TestDetectClusterType_Kind_CaseInsensitive (0.00s)
=== RUN   TestDetectClusterType_EmptyContext
--- PASS: TestDetectClusterType_EmptyContext (0.00s)
=== RUN   TestDetectClusterType_Unknown
--- PASS: TestDetectClusterType_Unknown (0.00s)
=== RUN   TestDetectClusterType_GKE_DifferentProject
--- PASS: TestDetectClusterType_GKE_DifferentProject (0.00s)
=== RUN   TestIsOpenShift4
=== RUN   TestIsOpenShift4/OpenShift_4_with_clusterversions
=== RUN   TestIsOpenShift4/OpenShift_4_with_other_config_resources
=== RUN   TestIsOpenShift4/No_OpenShift_resources
=== RUN   TestIsOpenShift4/Empty_list
--- PASS: TestIsOpenShift4 (0.00s)
    --- PASS: TestIsOpenShift4/OpenShift_4_with_clusterversions (0.00s)
    --- PASS: TestIsOpenShift4/OpenShift_4_with_other_config_resources (0.00s)
    --- PASS: TestIsOpenShift4/No_OpenShift_resources (0.00s)
    --- PASS: TestIsOpenShift4/Empty_list (0.00s)
=== RUN   TestGetServerURL
=== RUN   TestGetServerURL/Single_cluster
=== RUN   TestGetServerURL/Multiple_clusters_-_returns_first
=== RUN   TestGetServerURL/No_clusters
--- PASS: TestGetServerURL (0.00s)
    --- PASS: TestGetServerURL/Single_cluster (0.00s)
    --- PASS: TestGetServerURL/Multiple_clusters_-_returns_first (0.00s)
    --- PASS: TestGetServerURL/No_clusters (0.00s)
=== RUN   TestClusterTypeString
=== RUN   TestClusterTypeString/InfraGKE
=== RUN   TestClusterTypeString/InfraOpenShift4
=== RUN   TestClusterTypeString/LocalKind
=== RUN   TestClusterTypeString/ClusterTypeUnknown
--- PASS: TestClusterTypeString (0.00s)
    --- PASS: TestClusterTypeString/InfraGKE (0.00s)
    --- PASS: TestClusterTypeString/InfraOpenShift4 (0.00s)
    --- PASS: TestClusterTypeString/LocalKind (0.00s)
    --- PASS: TestClusterTypeString/ClusterTypeUnknown (0.00s)
PASS
coverage: 24.4% of statements
ok  	github.com/stackrox/roxie/internal/env	1.022s	coverage: 24.4% of statements
=== RUN   TestMergeMaps
--- PASS: TestMergeMaps (0.00s)
=== RUN   TestMergeMapsMultipleOverlays
--- PASS: TestMergeMapsMultipleOverlays (0.00s)
=== RUN   TestLoadYAMLFileValid
--- PASS: TestLoadYAMLFileValid (0.00s)
=== RUN   TestLoadYAMLFileEmpty
--- PASS: TestLoadYAMLFileEmpty (0.00s)
=== RUN   TestLoadYAMLFileNonExistent
--- PASS: TestLoadYAMLFileNonExistent (0.00s)
=== RUN   TestLoadYAMLFileInvalidYAML
--- PASS: TestLoadYAMLFileInvalidYAML (0.00s)
=== RUN   TestDeepCopy
--- PASS: TestDeepCopy (0.00s)
PASS
coverage: 40.6% of statements
ok  	github.com/stackrox/roxie/internal/helpers	1.018s	coverage: 40.6% of statements
=== RUN   TestImageCacheLoadSaveRoundtrip
--- PASS: TestImageCacheLoadSaveRoundtrip (0.00s)
=== RUN   TestImageCacheHandlesOldFormat
--- PASS: TestImageCacheHandlesOldFormat (0.00s)
=== RUN   TestImageCacheMaxEntries
--- PASS: TestImageCacheMaxEntries (0.00s)
=== RUN   TestImageCacheMoveToEnd
--- PASS: TestImageCacheMoveToEnd (0.00s)
PASS
coverage: 33.7% of statements
ok  	github.com/stackrox/roxie/internal/imagecache	1.019s	coverage: 33.7% of statements
	github.com/stackrox/roxie/internal/logger		coverage: 0.0% of statements
	github.com/stackrox/roxie/internal/portforward		coverage: 0.0% of statements
?   	github.com/stackrox/roxie/tests/testhelpers	[no test files]
🔨 Building roxie...
go build -ldflags "-X main.version=0.1.1-4-gf0550a0 -X main.gitCommit=f0550a00778fea55e4c772be82a15627c27b5821 -X main.buildDate=2026-03-26T07:49:56Z" -o ./roxie ./cmd
✅ Build complete: ./roxie
🧪 Running integration tests...
go test -v -tags=integration -run=_Integration$ -timeout=120m -parallel=1 ./...
?   	github.com/stackrox/roxie/cmd	[no test files]
testing: warning: no tests to run
PASS
ok  	github.com/stackrox/roxie/internal/clusterdefaults	0.002s [no tests to run]
?   	github.com/stackrox/roxie/internal/component	[no test files]
testing: warning: no tests to run
PASS
ok  	github.com/stackrox/roxie/internal/containerutil	0.002s [no tests to run]
?   	github.com/stackrox/roxie/internal/deployer	[no test files]
testing: warning: no tests to run
PASS
ok  	github.com/stackrox/roxie/internal/dockerauth	0.002s [no tests to run]
=== RUN   TestDetectClusterType_Integration
00:00 Using kubeconfig /home/mowsiany/.kube/config
    env_integration_test.go:12: Initialize() failed: failed to initialize environment: failed to retrieve API resources: exit status 1
--- FAIL: TestDetectClusterType_Integration (0.52s)
FAIL
FAIL	github.com/stackrox/roxie/internal/env	0.519s
testing: warning: no tests to run
PASS
ok  	github.com/stackrox/roxie/internal/helpers	0.002s [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/stackrox/roxie/internal/imagecache	0.001s [no tests to run]
?   	github.com/stackrox/roxie/internal/logger	[no test files]
?   	github.com/stackrox/roxie/internal/portforward	[no test files]
?   	github.com/stackrox/roxie/tests/testhelpers	[no test files]
FAIL
make: *** [Makefile:122: test-integration] Error 1
[roxie]$ 

Alright, reading the code revealed that integration tests expect a configured k8s cluster connection. It seems the existence of integration tests is not even mentioned in the README.

And then I realized that end-to-end tests require OLM to be installed on the cluster, it is also not mentioned in the README. Might be useful to link to https://github.com/operator-framework/operator-lifecycle-manager/releases from there.

To sum up, the README should mention:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions