Skip to content

Tests fail against local Kubernetes clusters #38

@skoenig

Description

@skoenig

I tried to run the tests locally against minikube (minikube version: v1.31.2) and kind (kind v0.20.0 go1.20.4 linux/amd64) clusters using go version go1.21.6 linux/amd64. but I got the following errors with both:

$ make test
go vet
go test -race -v -cover ./...
?   	github.com/devtron-labs/silver-surfer	[no test files]
?   	github.com/devtron-labs/silver-surfer/pkg/log	[no test files]
=== RUN   TestValidateCluster
=== RUN   TestValidateCluster/check_cluster
    kubedd_test.go:45: ValidateCluster() error = <nil>, wantErr true
--- FAIL: TestValidateCluster (28.02s)
    --- FAIL: TestValidateCluster/check_cluster (27.98s)
FAIL
coverage: 32.4% of statements
FAIL	github.com/devtron-labs/silver-surfer/kubedd	28.095s
=== RUN   TestCluster_ServerVersion
=== RUN   TestCluster_ServerVersion/cluster_version
    Cluster_test.go:31: ServerVersion() got = 1.29, want 
--- FAIL: TestCluster_ServerVersion (0.06s)
    --- FAIL: TestCluster_ServerVersion/cluster_version (0.06s)
=== RUN   TestDownloadFile
=== RUN   TestDownloadFile/Positive_-_Test_deployment
=== RUN   TestDownloadFile/Negative_-_Test_deployment
=== RUN   TestDownloadFile/Positive_-_Test_Service
=== RUN   TestDownloadFile/Negative_-_Test_Service
=== RUN   TestDownloadFile/Positive_-_Test_Service#01
=== RUN   TestDownloadFile/Positive_-_Test_deployment_extension,_handled_via_apps/v1
    K8sSchemaParser_test.go:339: DownloadFile() error = <nil>, wantErr true
=== RUN   TestDownloadFile/Positive_-_Test_deployment_extension
    K8sSchemaParser_test.go:339: DownloadFile() error = <nil>, wantErr true
=== RUN   TestDownloadFile/Positive_-_Test_configmap
=== RUN   TestDownloadFile/Positive_-_Test_secret
=== RUN   TestDownloadFile/Positive_-_Test_secret_stringdata
--- FAIL: TestDownloadFile (193.01s)
    --- PASS: TestDownloadFile/Positive_-_Test_deployment (21.53s)
    --- PASS: TestDownloadFile/Negative_-_Test_deployment (18.52s)
    --- PASS: TestDownloadFile/Positive_-_Test_Service (16.74s)
    --- PASS: TestDownloadFile/Negative_-_Test_Service (18.15s)
    --- PASS: TestDownloadFile/Positive_-_Test_Service#01 (16.62s)
    --- FAIL: TestDownloadFile/Positive_-_Test_deployment_extension,_handled_via_apps/v1 (17.26s)
    --- FAIL: TestDownloadFile/Positive_-_Test_deployment_extension (19.10s)
    --- PASS: TestDownloadFile/Positive_-_Test_configmap (21.89s)
    --- PASS: TestDownloadFile/Positive_-_Test_secret (21.10s)
    --- PASS: TestDownloadFile/Positive_-_Test_secret_stringdata (22.08s)
=== RUN   Test_compareVersion
=== RUN   Test_compareVersion/compare_deployment
=== RUN   Test_compareVersion/compare_deployment#01
=== RUN   Test_compareVersion/compare_APIService
=== RUN   Test_compareVersion/compare_deployment#02
=== RUN   Test_compareVersion/compare_deployment#03
=== RUN   Test_compareVersion/compare_deployment#04
=== RUN   Test_compareVersion/compare_deployment#05
--- PASS: Test_compareVersion (0.00s)
    --- PASS: Test_compareVersion/compare_deployment (0.00s)
    --- PASS: Test_compareVersion/compare_deployment#01 (0.00s)
    --- PASS: Test_compareVersion/compare_APIService (0.00s)
    --- PASS: Test_compareVersion/compare_deployment#02 (0.00s)
    --- PASS: Test_compareVersion/compare_deployment#03 (0.00s)
    --- PASS: Test_compareVersion/compare_deployment#04 (0.00s)
    --- PASS: Test_compareVersion/compare_deployment#05 (0.00s)
=== RUN   Test_jsonOutputManager_put
=== RUN   Test_jsonOutputManager_put/empty_input
    Output_test.go:120: 
        	Error Trace:	/home/skoenig/workspace/silver-surfer/pkg/Output_test.go:120
        	Error:      	Not equal: 
        	            	expected: "[\n\t{\n\t\t\"filename\": \"\",\n\t\t\"kind\": \"\",\n\t\t\"status\": \"skipped\",\n\t\t\"errors\": []\n\t}\n]\n"
        	            	actual  : "[\n\t{\n\t\t\"FileName\": \"\",\n\t\t\"Kind\": \"\",\n\t\t\"APIVersion\": \"\",\n\t\t\"ResourceName\": \"\",\n\t\t\"ResourceNamespace\": \"\",\n\t\t\"Deleted\": false,\n\t\t\"Deprecated\": false,\n\t\t\"LatestAPIVersion\": \"\",\n\t\t\"IsVersionSupported\": 0,\n\t\t\"ErrorsForOriginal\": null,\n\t\t\"ErrorsForLatest\": null,\n\t\t\"DeprecationForOriginal\": null,\n\t\t\"DeprecationForLatest\": null\n\t}\n]\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -2,6 +2,15 @@
        	            	 	{
        	            	-		"filename": "",
        	            	-		"kind": "",
        	            	-		"status": "skipped",
        	            	-		"errors": []
        	            	+		"FileName": "",
        	            	+		"Kind": "",
        	            	+		"APIVersion": "",
        	            	+		"ResourceName": "",
        	            	+		"ResourceNamespace": "",
        	            	+		"Deleted": false,
        	            	+		"Deprecated": false,
        	            	+		"LatestAPIVersion": "",
        	            	+		"IsVersionSupported": 0,
        	            	+		"ErrorsForOriginal": null,
        	            	+		"ErrorsForLatest": null,
        	            	+		"DeprecationForOriginal": null,
        	            	+		"DeprecationForLatest": null
        	            	 	}
        	Test:       	Test_jsonOutputManager_put/empty_input
=== RUN   Test_jsonOutputManager_put/file_with_no_errors
    Output_test.go:120: 
        	Error Trace:	/home/skoenig/workspace/silver-surfer/pkg/Output_test.go:120
        	Error:      	Not equal: 
        	            	expected: "[\n\t{\n\t\t\"filename\": \"deployment.yaml\",\n\t\t\"kind\": \"deployment\",\n\t\t\"status\": \"valid\",\n\t\t\"errors\": []\n\t}\n]\n"
        	            	actual  : "[\n\t{\n\t\t\"FileName\": \"deployment.yaml\",\n\t\t\"Kind\": \"deployment\",\n\t\t\"APIVersion\": \"\",\n\t\t\"ResourceName\": \"\",\n\t\t\"ResourceNamespace\": \"\",\n\t\t\"Deleted\": false,\n\t\t\"Deprecated\": false,\n\t\t\"LatestAPIVersion\": \"\",\n\t\t\"IsVersionSupported\": 0,\n\t\t\"ErrorsForOriginal\": null,\n\t\t\"ErrorsForLatest\": null,\n\t\t\"DeprecationForOriginal\": null,\n\t\t\"DeprecationForLatest\": null\n\t}\n]\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -2,6 +2,15 @@
        	            	 	{
        	            	-		"filename": "deployment.yaml",
        	            	-		"kind": "deployment",
        	            	-		"status": "valid",
        	            	-		"errors": []
        	            	+		"FileName": "deployment.yaml",
        	            	+		"Kind": "deployment",
        	            	+		"APIVersion": "",
        	            	+		"ResourceName": "",
        	            	+		"ResourceNamespace": "",
        	            	+		"Deleted": false,
        	            	+		"Deprecated": false,
        	            	+		"LatestAPIVersion": "",
        	            	+		"IsVersionSupported": 0,
        	            	+		"ErrorsForOriginal": null,
        	            	+		"ErrorsForLatest": null,
        	            	+		"DeprecationForOriginal": null,
        	            	+		"DeprecationForLatest": null
        	            	 	}
        	Test:       	Test_jsonOutputManager_put/file_with_no_errors
=== RUN   Test_jsonOutputManager_put/file_with_errors
    Output_test.go:120: 
        	Error Trace:	/home/skoenig/workspace/silver-surfer/pkg/Output_test.go:120
        	Error:      	Not equal: 
        	            	expected: "[\n\t{\n\t\t\"filename\": \"service.yaml\",\n\t\t\"kind\": \"service\",\n\t\t\"status\": \"invalid\",\n\t\t\"errors\": [\n\t\t\t\"error: i am a error\",\n\t\t\t\"error: i am another error\"\n\t\t]\n\t}\n]\n"
        	            	actual  : "[\n\t{\n\t\t\"FileName\": \"service.yaml\",\n\t\t\"Kind\": \"service\",\n\t\t\"APIVersion\": \"\",\n\t\t\"ResourceName\": \"\",\n\t\t\"ResourceNamespace\": \"\",\n\t\t\"Deleted\": false,\n\t\t\"Deprecated\": false,\n\t\t\"LatestAPIVersion\": \"\",\n\t\t\"IsVersionSupported\": 0,\n\t\t\"ErrorsForOriginal\": null,\n\t\t\"ErrorsForLatest\": null,\n\t\t\"DeprecationForOriginal\": null,\n\t\t\"DeprecationForLatest\": null\n\t}\n]\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -2,9 +2,15 @@
        	            	 	{
        	            	-		"filename": "service.yaml",
        	            	-		"kind": "service",
        	            	-		"status": "invalid",
        	            	-		"errors": [
        	            	-			"error: i am a error",
        	            	-			"error: i am another error"
        	            	-		]
        	            	+		"FileName": "service.yaml",
        	            	+		"Kind": "service",
        	            	+		"APIVersion": "",
        	            	+		"ResourceName": "",
        	            	+		"ResourceNamespace": "",
        	            	+		"Deleted": false,
        	            	+		"Deprecated": false,
        	            	+		"LatestAPIVersion": "",
        	            	+		"IsVersionSupported": 0,
        	            	+		"ErrorsForOriginal": null,
        	            	+		"ErrorsForLatest": null,
        	            	+		"DeprecationForOriginal": null,
        	            	+		"DeprecationForLatest": null
        	            	 	}
        	Test:       	Test_jsonOutputManager_put/file_with_errors
--- FAIL: Test_jsonOutputManager_put (0.01s)
    --- FAIL: Test_jsonOutputManager_put/empty_input (0.01s)
    --- FAIL: Test_jsonOutputManager_put/file_with_no_errors (0.00s)
    --- FAIL: Test_jsonOutputManager_put/file_with_errors (0.00s)
=== RUN   Test_tapOutputManager_put
=== RUN   Test_tapOutputManager_put/file_with_no_errors
=== RUN   Test_tapOutputManager_put/file_with_errors
=== RUN   Test_tapOutputManager_put/file_with_no_errors_because_of_a_skip
--- PASS: Test_tapOutputManager_put (0.00s)
    --- PASS: Test_tapOutputManager_put/file_with_no_errors (0.00s)
    --- PASS: Test_tapOutputManager_put/file_with_errors (0.00s)
    --- PASS: Test_tapOutputManager_put/file_with_no_errors_because_of_a_skip (0.00s)
=== RUN   TestRegexMatch
=== RUN   TestRegexMatch/ends_with_match
|   foo|     b|
|   foo| bn|
1 issue(s): fix issues before migration
=== RUN   TestRegexMatch/starts_with_match
|   foo|     b|
|   foo| bn|
1 issue(s): fix issues before migration
=== RUN   TestRegexMatch/has_match
|   foo|     b|
|   foo| bn|
1 issue(s): fix issues before migration
--- PASS: TestRegexMatch (0.00s)
    --- PASS: TestRegexMatch/ends_with_match (0.00s)
    --- PASS: TestRegexMatch/starts_with_match (0.00s)
    --- PASS: TestRegexMatch/has_match (0.00s)
FAIL
coverage: 43.1% of statements
FAIL    github.com/devtron-labs/silver-surfer/pkg       193.173s
FAIL
make: *** [Makefile:53: test] Error 1

Could we document more detailed instructions for local testing and possibly also provide test data under 'fixtures'?
This would make it easier for new contributors to contribute to this project.

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