Running build tests without full TestIntegration

I want to verify basic functionality (unit tests) for my rclone build by running go test.
That kind of generic test fails with rclone 1.53.1 because of integration tests, which does make sense since I don't have servers configured. I just want to make sure local functions are working.

The tests for various backends (azureblob, b2, box, etc) run TestIntegration through fstest/testserver. testserver tries to find a nearby init.d directory, which is not present in the build dir. In the source tree there is fstest/testserver/init.d with some test server configurations available using docker. But I don't want to activate these test servers or install docker.

Hence the TestIntegration for each backend fails with the error message

couldn't find testserver config files - run from within rclone source

and go test returns a FAIL status.

I'd like to just skip these TestIntegration. It's sufficient for me to just confirm that local non-server functionality is working. I could skip each TestIntegration one by one by applying t.Skip() to it in the _test.go file for each backend.

What I'd like to know, is there are simpler way to skip TestIntegration once for all tests rather than hacking each backend test file? Or is there a way to treat couldn't find testserver config files as a warning or message (i.e. ignoring the problem and moving on) rather than as a failing error?

Previously in rclone 1.50.2, failure to find backend config files triggered a skip rather than a fail, e.g.

Didn't find "TestAzureBlob:" in config file - skipping tests

How can this error handling be reinstated?

The full error message for the azureblob backend, for example, is

=== RUN   TestIntegration
2020/09/28 23:10:08 NOTICE: Config file "/home/drew/projects/golang/build/rclone/buildtest/rclone/rclone.conf" not found - using defaults
    fstests.go:357: Using remote "TestAzureBlob:"
    fstests.go:367:.
        <------>Error Trace:<-->fstests.go:367
        <------>            <--><------><------><------>azureblob_test.go:16
        <------>Error:      <-->Received unexpected error:
        <------>            <-->couldn't find testserver config files - run from within rclone source
        <------>            <-->github.com/rclone/rclone/fstest/testserver.findConfig
        <------>            <--><------>/home/drew/projects/golang/build/rclone/obj-x86_64-linux-gnu/src/github.com/rclone/rclone/fstest/testserver/testserver.go:42
        <------>            <-->github.com/rclone/rclone/fstest/testserver.Start.func3
        <------>            <--><------>/home/drew/projects/golang/build/rclone/obj-x86_64-linux-gnu/src/github.com/rclone/rclone/fstest/testserver/testserver.go:137
        <------>            <-->sync.(*Once).doSlow
        <------>            <--><------>/usr/lib/go-1.15/src/sync/once.go:66
        <------>            <-->sync.(*Once).Do
        <------>            <--><------>/usr/lib/go-1.15/src/sync/once.go:57
        <------>            <-->github.com/rclone/rclone/fstest/testserver.Start
        <------>            <--><------>/home/drew/projects/golang/build/rclone/obj-x86_64-linux-gnu/src/github.com/rclone/rclone/fstest/testserver/testserver.go:136
        <------>            <-->github.com/rclone/rclone/fstest/fstests.Run
        <------>            <--><------>/home/drew/projects/golang/build/rclone/obj-x86_64-linux-gnu/src/github.com/rclone/rclone/fstest/fstests/fstests.go:366
        <------>            <-->github.com/rclone/rclone/backend/azureblob.TestIntegration
        <------>            <--><------>/home/drew/projects/golang/build/rclone/obj-x86_64-linux-gnu/src/github.com/rclone/rclone/backend/azureblob/azureblob_test.go:16
        <------>            <-->testing.tRunner
        <------>            <--><------>/usr/lib/go-1.15/src/testing/testing.go:1127
        <------>            <-->runtime.goexit
        <------>            <--><------>/usr/lib/go-1.15/src/runtime/asm_amd64.s:1374
        <------>Test:       <-->TestIntegration
--- FAIL: TestIntegration (0.00s)
FAIL
FAIL<-->github.com/rclone/rclone/backend/azureblob<---->0.021s

I want to either skip these TestIntegration tests or ignore their config error (again, skipping the test), so that they don't register as FAIL.

What you want is make quicktest from the root - that skips any integration tests.

Thanks @ncw. That almost works a charm. Inspecting the details of make quicktest suggests to me the key is setting RCLONE_CONFIG="/notfound" in the environment for the test command, which works with the Debian tools I'm using (RCLONE_CONFIG="/notfound" dh_auto_test).

The backends I reported on then pass cleanly, e.g.

=== RUN   TestIntegration
    fstests.go:302: quicktest only
--- SKIP: TestIntegration (0.00s)
PASS
ok      github.com/rclone/rclone/backend/azureblob      0.044s

Two backends don't recognise the quicktest condition though,
e.g. sftp,

        === RUN   TestIntegration
        2020/09/29 00:35:12 NOTICE: Config file "/notfound" not found - using defaults
            fstests.go:357: Using remote "sftptest:"
            fstests.go:367:
                        Error Trace:    fstests.go:367
                                                                sftp_test.go:17
                        Error:          Received unexpected error:
                                        couldn't find testserver config files - run from within rclone source
                                        github.com/rclone/rclone/fstest/testserver.findConfig
                                                /projects/golang/build/rclone/obj-x86_64-linux-gnu/src/github.com/rclone/rclone/fstest/testserver/testserver.go:42
                                        github.com/rclone/rclone/fstest/testserver.Start.func3
                                                /projects/golang/build/rclone/obj-x86_64-linux-gnu/src/github.com/rclone/rclone/fstest/testserver/testserver.go:137
                                        sync.(*Once).doSlow
                                                /usr/lib/go-1.15/src/sync/once.go:66
                                        sync.(*Once).Do
                                                /usr/lib/go-1.15/src/sync/once.go:57
                                        github.com/rclone/rclone/fstest/testserver.Start
                                                /projects/golang/build/rclone/obj-x86_64-linux-gnu/src/github.com/rclone/rclone/fstest/testserver/testserver.go:136
                                        github.com/rclone/rclone/fstest/fstests.Run
                                                /projects/golang/build/rclone/obj-x86_64-linux-gnu/src/github.com/rclone/rclone/fstest/fstests/fstests.go:366
                                        github.com/rclone/rclone/backend/sftp_test.TestIntegration
                                                /projects/golang/build/rclone/obj-x86_64-linux-gnu/src/github.com/rclone/rclone/backend/sftp/sftp_test.go:17
                                        testing.tRunner
                                                /usr/lib/go-1.15/src/testing/testing.go:1127
                                        runtime.goexit
                                                /usr/lib/go-1.15/src/runtime/asm_amd64.s:1374
                        Test:           TestIntegration
        --- FAIL: TestIntegration (0.00s)

Likewise in webdav.

Only sftp and webdav are giving this TestIntegration failure now. Other backends, including azureblob, b2, box, etc, recognise the "quicktest only" condition and pass the test. (note, this is output from RCLONE_CONFIG="/notfound" dh_auto_test rather than make quicktest)

Is this a bug in the sftp and webdav TestIntegrations ?

Hmm, possibly...

You are getting that strange error since you haven't cd-ed to the root of the rclone source I'm guessing.

When I try this it works as expected.

~/go/src/github.com/rclone/rclone/backend/sftp$ RCLONE_CONFIG="/notfound" go test -v
=== RUN   TestShellEscape
--- PASS: TestShellEscape (0.00s)
=== RUN   TestParseHash
--- PASS: TestParseHash (0.00s)
=== RUN   TestParseUsage
--- PASS: TestParseUsage (0.00s)
=== RUN   TestStringLock
--- PASS: TestStringLock (1.12s)
=== RUN   TestIntegration
    fstests.go:302: quicktest only
--- SKIP: TestIntegration (0.00s)
=== RUN   TestIntegration2
    fstests.go:302: quicktest only
--- SKIP: TestIntegration2 (0.00s)
PASS
ok  	github.com/rclone/rclone/backend/sftp	1.131s

This is probably fixable, but if you can cd to the source root before running the tests then it should work.

At the moment the test script is set up to run all tests from the toplevel, so not so convenient to cd down to the specific sftp and webdav dirs to get the failing tests to pass.

On the other hand, with only the two of them misbehaving, it's easy enough to apply the t.Skip() hack to skip TestIntegration for just those two backends. That, together with RCLONE_CONFIG="/notfound", will work for me. Thanks for your help!

Glad you got it working.

If you figure out how to make it work properly then I'd sure appreciate a pull request!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.