Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-5426] Fix unit-tests on vagrant/windows
This change adds several error checks on removal of temporary files it copies files instead of creating symlinks that don't work on Windows, it uses files in local volumes when chmod is involved and adds stopping of the server and/or closing of the DB to avoid leaving the database dangling in the ether. Patch-set #2: minor simplification Patch-set #3: limits changes to test files leaving to FAB-6085 the changes related to the lib code. Before the change: fabric-ca/lib $ go test --- FAIL: TestCAInit (0.09s) ca_test.go:200: ====== orgwd /opt/gopath/src/github.com/hyperl edger/fabric-ca/lib ca_test.go:211: confDir: TestCAInit514958420 ca_test.go:216: Working dir /opt/gopath/src/github.com/hyperle dger/fabric-ca/testdata/TestCAInit514958420 ca_test.go:236: ca.init error: Failed to get BCCSP with opts: Could not initialize BCCSP PKCS11 [Failed initializing configuration [ Hash Family not supported []]] ca_test.go:253: changed to /opt/gopath/src/github.com/hyperle dger/fabric-ca/testdata/TestCaInit209323427 ca_test.go:272: symlink error: link ../ec256-1-key.pem ca-key .pem: operation not permitted ca_test.go:259: Removed all: /opt/gopath/src/github.com/hyperl edger/fabric-ca/testdata/TestCaInit209323427 ca_test.go:222: Removed all: /opt/gopath/src/github.com/hyperl edger/fabric-ca/testdata/TestCAInit514958420 --- FAIL: TestSRVMultiCAConfigs (0.95s) server_test.go:785: TestMultiCA... server_test.go:791: Server configuration: &{Port:7075 Address: ... server_test.go:810: Starting 3 CAs with a duplicated CN name: Please modify CSR in /opt/gopath/src/github.com/hyperledger/fabric-ca/ testdata/ca/rootca/ca3/ca-cert.pem and try adding CA again: Both issue r and subject distinguished name are already in use server_test.go:817: Create err: <nil> server_test.go:822: Create err: <nil> server_test.go:828: srv.Start ERROR Validation of certificate and key failed: Invalid certificate in file '/opt/gopath/src/github.co m/hyperledger/fabric-ca/testdata/ca/rootca/ca1/ca-cert.pem': Failed to PEM decode certificate server_test.go:842: srv.Start ERROR Validation of certificate a nd key failed: Invalid certificate in file '/opt/gopath/src/github.com/ hyperledger/fabric-ca/testdata/ca/rootca/ca1/ca-cert.pem': Failed to PE M decode certificate server_test.go:2236: symlink expired cert to ../testdata/expire dcert.pem failed: link ../testdata/expiredcert.pem ../testdata/ca/root ca/ca1/ca-cert.pem: file exists server_test.go:2240: symlink key to ../testdata/tls_client-key. pem failed: link ../testdata/tls_client-key.pem ../testdata/ca/rootca/ ca1/ca-key.pem: file exists server_test.go:2244: srvStart ERROR Validation of certificate a nd key failed: Invalid certificate in file '/opt/gopath/src/github.com/ hyperledger/fabric-ca/testdata/ca/rootca/ca1/ca-cert.pem': Failed to PE M decode certificate server_test.go:2236: symlink expired cert to ../testdata/noKeyU sage.cert.pem failed: link ../testdata/noKeyUsage.cert.pem ../testdata /ca/rootca/ca1/ca-cert.pem: file exists server_test.go:2240: symlink key to ../testdata/noKeyUsage.key. pem failed: link ../testdata/noKeyUsage.key.pem ../testdata/ca/rootca/ ca1/ca-key.pem: file exists server_test.go:2244: srvStart ERROR Validation of certificate a nd key failed: Invalid certificate in file '/opt/gopath/src/github.com/ hyperledger/fabric-ca/testdata/ca/rootca/ca1/ca-cert.pem': Failed to PE M decode certificate server_test.go:2236: symlink expired cert to ../testdata/caFals e.cert.pem failed: link ../testdata/caFalse.cert.pem ../testdata/ca/ro otca/ca1/ca-cert.pem: file exists server_test.go:2240: symlink key to ../testdata/caFalse.key.pem failed: link ../testdata/caFalse.key.pem ../testdata/ca/rootca/ca1/ca -key.pem: file exists server_test.go:2244: srvStart ERROR Validation of certificate a nd key failed: Invalid certificate in file '/opt/gopath/src/github.com/ hyperledger/fabric-ca/testdata/ca/rootca/ca1/ca-cert.pem': Failed to PE M decode certificate server_test.go:2236: symlink expired cert to ../testdata/dsaCa- cert.pem failed: link ../testdata/dsaCa-cert.pem ../testdata/ca/rootca /ca1/ca-cert.pem: file exists server_test.go:2240: symlink key to ../testdata/dsaCa-key.pem f ailed: link ../testdata/dsaCa-key.pem ../testdata/ca/rootca/ca1/ca-key .pem: file exists server_test.go:2244: srvStart ERROR Validation of certificate a nd key failed: Invalid certificate in file '/opt/gopath/src/github.com/ hyperledger/fabric-ca/testdata/ca/rootca/ca1/ca-cert.pem': Failed to PE M decode certificate server_test.go:2236: symlink expired cert to ../testdata/dsaCa- cert.pem failed: link ../testdata/dsaCa-cert.pem ../testdata/ca/rootca /ca1/ca-cert.pem: file exists server_test.go:2240: symlink key to ../testdata/dsaCa-key.pem f ailed: link ../testdata/dsaCa-key.pem ../testdata/ca/rootca/ca1/ca-key .pem: file exists server_test.go:2244: srvStart ERROR Validation of certificate a nd key failed: Invalid certificate in file '/opt/gopath/src/github.com/ hyperledger/fabric-ca/testdata/ca/rootca/ca1/ca-cert.pem': Failed to PE M decode certificate server_test.go:2236: symlink expired cert to ../testdata/rsa512 -cert.pem failed: link ../testdata/rsa512-cert.pem ../testdata/ca/root ca/ca1/ca-cert.pem: file exists server_test.go:2240: symlink key to ../testdata/rsa512-key.pem failed: link ../testdata/rsa512-key.pem ../testdata/ca/rootca/ca1/ca-k ey.pem: file exists server_test.go:2244: srvStart ERROR Validation of certificate a nd key failed: Invalid certificate in file '/opt/gopath/src/github.com/ hyperledger/fabric-ca/testdata/ca/rootca/ca1/ca-cert.pem': Failed to PE M decode certificate server_test.go:2236: symlink expired cert to ../testdata/ec256- 1-cert.pem failed: link ../testdata/ec256-1-cert.pem ../testdata/ca/ro otca/ca1/ca-cert.pem: file exists server_test.go:2240: symlink key to ../testdata/ec256-2-key.pem failed: link ../testdata/ec256-2-key.pem ../testdata/ca/rootca/ca1/ca -key.pem: file exists server_test.go:2244: srvStart ERROR Validation of certificate a nd key failed: Invalid certificate in file '/opt/gopath/src/github.com/ hyperledger/fabric-ca/testdata/ca/rootca/ca1/ca-cert.pem': Failed to PE M decode certificate server_test.go:2236: symlink expired cert to ../testdata/rsa204 8-1-cert.pem failed: link ../testdata/rsa2048-1-cert.pem ../testdata/c a/rootca/ca1/ca-cert.pem: file exists server_test.go:2240: symlink key to ../testdata/rsa2048-2-key.p em failed: link ../testdata/rsa2048-2-key.pem ../testdata/ca/rootca/ca 1/ca-key.pem: file exists server_test.go:2244: srvStart ERROR Validation of certificate a nd key failed: Invalid certificate in file '/opt/gopath/src/github.com/ hyperledger/fabric-ca/testdata/ca/rootca/ca1/ca-cert.pem': Failed to PE M decode certificate server_test.go:2236: symlink expired cert to ../testdata/ec256- 1-cert.pem failed: link ../testdata/ec256-1-cert.pem ../testdata/ca/ro otca/ca1/ca-cert.pem: file exists server_test.go:2240: symlink key to ../testdata/rsa2048-1-cert. pem failed: link ../testdata/rsa2048-1-cert.pem ../testdata/ca/rootca/ ca1/ca-key.pem: file exists server_test.go:2244: srvStart ERROR Validation of certificate a ... --- FAIL: TestSRVMultiCAWithIntermediate (0.03s) server_test.go:997: Server configuration: &{Port:7075 Address: ... server_test.go:1002: Failed to start server: Validation of certi ficate and key failed: Invalid certificate in file '/opt/gopath/src/gith ub.com/hyperledger/fabric-ca/testdata/ca/rootca/ca1/ca-cert.pem': Failed to PEM decode certificate --- FAIL: TestSRVMaxEnrollmentInfinite (1.76s) server_test.go:1154: RemoveAll failed: remove rootDir/fabric_ca. db: text file busy server_test.go:1156: Test max enrollment infinite server_test.go:1224: RemoveAll failed: remove rootDir/fabric_ca. db: text file busy --- FAIL: TestSRVMaxEnrollmentDisabled (1.38s) server_test.go:1231: RemoveAll failed: remove rootDir/fabric_ca. db: text file busy server_test.go:1233: Test max enrollment disabled server_test.go:1272: RemoveAll failed: remove rootDir/fabric_ca. db: text file busy --- FAIL: TestSRVMaxEnrollmentLimited (1.65s) server_test.go:1279: RemoveAll failed: remove rootDir/fabric_ca. db: text file busy server_test.go:1281: Test max enrollment limited server_test.go:1358: RemoveAll failed: remove rootDir/fabric_ca. db: text file busy FAIL exit status 1 FAIL github.com/hyperledger/fabric-ca/lib 111.445s After the change: fabric-ca/lib$ go test PASS ok github.com/hyperledger/fabric-ca/lib 128.416s Change-Id: I6e037cf65df6b61ad556824d72c6e7c7ba64f815 Signed-off-by: Arnaud J Le Hors <[email protected]>
- Loading branch information