samba-in-kubernetes / samba-operator

An operator for a Samba as a service on PVCs in kubernetes
Apache License 2.0
110 stars 24 forks source link

`mountPath` integration test fails when run alone #171

Closed anoopcs9 closed 2 years ago

anoopcs9 commented 2 years ago

If mountPath test happens to be the first or when run alone it fails as smbclient test pod is not present in the k8s cluster. Following is the error from one such occurrence from CentOS CI runs:

=== RUN   TestIntegration
=== RUN   TestIntegration/deploy
=== RUN   TestIntegration/deploy/default
=== RUN   TestIntegration/deploy/default/TestImageAndTag
=== RUN   TestIntegration/deploy/default/TestOperatorReady
=== RUN   TestIntegration/smbShares
=== RUN   TestIntegration/smbShares/mountPath
    mount_path_test.go:70: 
            Error Trace:    mount_path_test.go:70
                                        suite.go:118
                                        integration_test.go:15
            Error:          Received unexpected error:
                            failed to flush cache: ['rm' '-f' '/var/lib/samba/lock/gencache.tdb']: failed executing command (pod:samba-operator-system/smbclient container:client): pods "smbclient" not found [exit: 1; stdout: ; stderr: ]
            Test:           TestIntegration/smbShares/mountPath

We may have to create smbclient pod if missing in the cluster as part of SetupSuite()

spuiuk commented 2 years ago

The smbclient is automatically created by the deploy test which is the first test run in the integration suite. https://github.com/samba-in-kubernetes/samba-operator/blob/master/tests/integration/integration_test.go#L22

Therefore it is unlikely that the complete set of tests would fail because of ordering of the tests. However the individual tests will fail. The proposed set of patches fixes this issue.

spuiuk commented 2 years ago

To test:

Ensure no smbclient pod exists in testnamespace before running test.

Problematic:

[sprabhu@t10 samba-operator]$ SMBOP_TEST_RUN=TestIntegration/smbShares/mountPath tests/test.sh === RUN TestIntegration === RUN TestIntegration/smbShares === RUN TestIntegration/smbShares/mountPath mount_path_test.go:70: Error Trace: mount_path_test.go:70 suite.go:118 integration_test.go:15 Error: Received unexpected error: failed to flush cache: ['rm' '-f' '/var/lib/samba/lock/gencache.tdb']: failed executing command (pod:samba-operator-system/smbclient container:client): pods "smbclient" not found [exit: 1; stdout: ; stderr: ] Test: TestIntegration/smbShares/mountPath --- FAIL: TestIntegration (22.47s) --- FAIL: TestIntegration/smbShares (22.47s) --- FAIL: TestIntegration/smbShares/mountPath (22.47s) FAIL FAIL github.com/samba-in-kubernetes/samba-operator/tests/integration 22.490s FAIL

After fix:

[sprabhu@t10 samba-operator]$ make commitid CommitID: 4f6c8501f3466c83e578e5363adf2aba5bd46c3c [sprabhu@t10 samba-operator]$ SMBOP_TEST_RUN=TestIntegration/smbShares/mountPath tests/test.sh === RUN TestIntegration === RUN TestIntegration/smbShares === RUN TestIntegration/smbShares/mountPath === RUN TestIntegration/smbShares/mountPath/TestMountPath --- PASS: TestIntegration (48.75s) --- PASS: TestIntegration/smbShares (48.75s) --- PASS: TestIntegration/smbShares/mountPath (48.75s) --- PASS: TestIntegration/smbShares/mountPath/TestMountPath (0.28s) PASS ok github.com/samba-in-kubernetes/samba-operator/tests/integration 48.772s

spuiuk commented 2 years ago

The smbclient is automatically created by the deploy test which is the first test run in the integration suite. https://github.com/samba-in-kubernetes/samba-operator/blob/master/tests/integration/integration_test.go#L22

Therefore it is unlikely that the complete set of tests would fail because of ordering of the tests. However the individual tests will fail. The proposed set of patches fixes this issue.

Sorry, I got a few things mixed up here. The smbclient is created as part of the SmbShareSuite tests and that re-ordering could end up with calling mountPath tests before the smbclient has been started. The proposed patch fixes the issue in any case.