kurtosis-tech / kurtosis-testsuite-starter-pack

The Unlicense
1 stars 1 forks source link

Interface conversion error when error is returned in test setup method #122

Closed galenmarchetti closed 3 years ago

galenmarchetti commented 3 years ago

When using reporting an error in test setup, the user gives a nil value for networks.Network as their return object.

However, when receiving the network in https://github.com/kurtosis-tech/kurtosis-libs/blob/develop/golang/lib/execution/test_suite_service.go#L203 , there is no nil check. So when there's an error in setting up a test (service never became available), right now Kurtosis itself fails with:

ERRO[2021-07-17T21:15:47Z] Test myTest ERRORED               
ERRO[2021-07-17T21:15:47Z] An error occurred running the test
 --- at /build/initializer/test_execution/test_executor/test_executor.go:229 (RunTest) ---
Caused by: An error occurred running the test
 --- at /build/initializer/test_execution/test_executor/test_executor.go:306 (streamTestsuiteLogsWhileRunningTest) ---
Caused by: rpc error: code = Unknown desc = An error occurred running test 'myTest'
 --- at /go/pkg/mod/github.com/kurtosis-tech/kurtosis-libs/golang@v0.0.0-20210714233214-392fce3b8d2d/lib/execution/test_suite_service.go:220 (TestSuiteService.RunTest) ---
Caused by: interface conversion: networks.Network is nil, not *networks.NetworkContext 

This happens when reporting an error in setup like...

func (test MyTest) Setup(networkCtx *networks.NetworkContext) (networks.Network, error) {
    logrus.Infof("Setting up test.")
        // logic here etc etc
    if !firstNodeUp {
        return nil, stacktrace.Propagate(err, "First geth node failed to come up")
    }
    return networkCtx, nil
}
mieubrisse commented 3 years ago

Debugged - this had to do with an incorrect use of stacktrace.Propagate. We also added an extra sanity check for this