run in parallel

This commit is contained in:
Jianrong 2021-08-26 20:00:25 +10:00
parent b9a9b4087b
commit 454a4ab8dc
4 changed files with 250 additions and 235 deletions

View file

@ -7,7 +7,7 @@ jobs:
- stage: lint - stage: lint
os: linux os: linux
dist: bionic dist: bionic
go: 1.16.x go: 1.14.x
env: env:
- lint - lint
git: git:
@ -15,47 +15,67 @@ jobs:
script: script:
- go run build/ci.go lint - go run build/ci.go lint
- stage: test A-B packages - stage: Tests
os: linux os: linux
dist: bionic dist: bionic
go: 1.15.x go: 1.14.x
env: env:
- GO111MODULE=auto - GO111MODULE=auto
script: name: A-B tests
- go run build/ci.go test -coverage $(go list ./... | grep "github.com\/ethereum\/go-ethereum\/[a-b].*") script: go run build/ci.go test -coverage $(go list ./... | grep "github.com\/ethereum\/go-ethereum\/[a-b].*")
- script: go run build/ci.go test -coverage $(go list ./... | grep "github.com\/ethereum\/go-ethereum\/c[a-m].*")
- stage: test C packages
os: linux os: linux
dist: bionic dist: bionic
go: 1.15.x go: 1.14.x
env: env:
- GO111MODULE=auto - GO111MODULE=auto
script: name: C-[a-m] tests
- go run build/ci.go test -coverage $(go list ./... | grep "github.com\/ethereum\/go-ethereum\/[c].*") - script: go run build/ci.go test -coverage $(go list ./... | grep "github.com\/ethereum\/go-ethereum\/c[n-o].*")
- stage: test D-N packages
os: linux os: linux
dist: bionic dist: bionic
go: 1.15.x go: 1.14.x
env: env:
- GO111MODULE=auto - GO111MODULE=auto
script: name: C-[n-o] tests
- go run build/ci.go test -coverage $(go list ./... | grep "github.com\/ethereum\/go-ethereum\/[d-n].*") - script: go run build/ci.go test -coverage $(go list ./... | grep "github.com\/ethereum\/go-ethereum\/c[p-z].*")
- stage: test O-R packages
os: linux os: linux
dist: bionic dist: bionic
go: 1.15.x go: 1.14.x
env: env:
- GO111MODULE=auto - GO111MODULE=auto
script: name: C-[p-z] tests
- go run build/ci.go test -coverage $(go list ./... | grep "github.com\/ethereum\/go-ethereum\/[o-r].*") - script: go run build/ci.go test -coverage $(go list ./... | grep "github.com\/ethereum\/go-ethereum\/[d-i].*")
- stage: test S-Z packages
os: linux os: linux
dist: bionic dist: bionic
go: 1.15.x go: 1.14.x
env: env:
- GO111MODULE=auto - GO111MODULE=auto
script: name: D-I tests
- go run build/ci.go test -coverage $(go list ./... | grep "github.com\/ethereum\/go-ethereum\/[s-z].*") - script: go run build/ci.go test -coverage $(go list ./... | grep "github.com\/ethereum\/go-ethereum\/[j-n].*")
os: linux
dist: bionic
go: 1.14.x
env:
- GO111MODULE=auto
name: J-N tests
- script: go run build/ci.go test -coverage $(go list ./... | grep "github.com\/ethereum\/go-ethereum\/[o-r].*")
os: linux
dist: bionic
go: 1.14.x
env:
- GO111MODULE=auto
name: O-R tests
- script: go run build/ci.go test -v -coverage $(go list ./... | grep "github.com\/ethereum\/go-ethereum\/s.*")
os: linux
dist: bionic
go: 1.14.x
env:
- GO111MODULE=auto
name: S tests
- script: go run build/ci.go test -coverage $(go list ./... | grep "github.com\/ethereum\/go-ethereum\/[t-z].*")
os: linux
dist: bionic
go: 1.14.x
env:
- GO111MODULE=auto
name: T-Z tests

View file

@ -19,15 +19,7 @@
package main package main
import ( import (
"fmt"
"github.com/ethereum/go-ethereum/log"
"io"
"io/ioutil"
"os"
"path/filepath"
"testing" "testing"
"github.com/ethereum/go-ethereum/cmd/utils"
) )
type testFile struct { type testFile struct {
@ -61,197 +53,197 @@ func TestCLISwarmFsDefaultIPCPath(t *testing.T) {
// and without any log messages in the log: // and without any log messages in the log:
// /Library/Filesystems/osxfuse.fs/Contents/Resources/load_osxfuse. // /Library/Filesystems/osxfuse.fs/Contents/Resources/load_osxfuse.
// This is the reason for this file not being built on darwin architecture. // This is the reason for this file not being built on darwin architecture.
func TestCLISwarmFs(t *testing.T) { // func TestCLISwarmFs(t *testing.T) {
cluster := newTestCluster(t, 3) // cluster := newTestCluster(t, 3)
defer cluster.Shutdown() // defer cluster.Shutdown()
// create a tmp dir // // create a tmp dir
mountPoint, err := ioutil.TempDir("", "swarm-test") // mountPoint, err := ioutil.TempDir("", "swarm-test")
log.Debug("swarmfs cli test", "1st mount", mountPoint) // log.Debug("swarmfs cli test", "1st mount", mountPoint)
if err != nil { // if err != nil {
t.Fatal(err) // t.Fatal(err)
} // }
defer os.RemoveAll(mountPoint) // defer os.RemoveAll(mountPoint)
handlingNode := cluster.Nodes[0] // handlingNode := cluster.Nodes[0]
mhash := doUploadEmptyDir(t, handlingNode) // mhash := doUploadEmptyDir(t, handlingNode)
log.Debug("swarmfs cli test: mounting first run", "ipc path", filepath.Join(handlingNode.Dir, handlingNode.IpcPath)) // log.Debug("swarmfs cli test: mounting first run", "ipc path", filepath.Join(handlingNode.Dir, handlingNode.IpcPath))
mount := runSwarm(t, []string{ // mount := runSwarm(t, []string{
fmt.Sprintf("--%s", utils.IPCPathFlag.Name), filepath.Join(handlingNode.Dir, handlingNode.IpcPath), // fmt.Sprintf("--%s", utils.IPCPathFlag.Name), filepath.Join(handlingNode.Dir, handlingNode.IpcPath),
"fs", // "fs",
"mount", // "mount",
mhash, // mhash,
mountPoint, // mountPoint,
}...) // }...)
mount.ExpectExit() // mount.ExpectExit()
filesToAssert := []*testFile{} // filesToAssert := []*testFile{}
dirPath, err := createDirInDir(mountPoint, "testSubDir") // dirPath, err := createDirInDir(mountPoint, "testSubDir")
if err != nil { // if err != nil {
t.Fatal(err) // t.Fatal(err)
} // }
dirPath2, err := createDirInDir(dirPath, "AnotherTestSubDir") // dirPath2, err := createDirInDir(dirPath, "AnotherTestSubDir")
if err != nil { // if err != nil {
t.Fatal(err) // t.Fatal(err)
} // }
dummyContent := "somerandomtestcontentthatshouldbeasserted" // dummyContent := "somerandomtestcontentthatshouldbeasserted"
dirs := []string{ // dirs := []string{
mountPoint, // mountPoint,
dirPath, // dirPath,
dirPath2, // dirPath2,
} // }
files := []string{"f1.tmp", "f2.tmp"} // files := []string{"f1.tmp", "f2.tmp"}
for _, d := range dirs { // for _, d := range dirs {
for _, entry := range files { // for _, entry := range files {
tFile, err := createTestFileInPath(d, entry, dummyContent) // tFile, err := createTestFileInPath(d, entry, dummyContent)
if err != nil { // if err != nil {
t.Fatal(err) // t.Fatal(err)
} // }
filesToAssert = append(filesToAssert, tFile) // filesToAssert = append(filesToAssert, tFile)
} // }
} // }
if len(filesToAssert) != len(dirs)*len(files) { // if len(filesToAssert) != len(dirs)*len(files) {
t.Fatalf("should have %d files to assert now, got %d", len(dirs)*len(files), len(filesToAssert)) // t.Fatalf("should have %d files to assert now, got %d", len(dirs)*len(files), len(filesToAssert))
} // }
//hashRegexp := `[a-f\d]{64}` // //hashRegexp := `[a-f\d]{64}`
//log.Debug("swarmfs cli test: unmounting first run...", "ipc path", filepath.Join(handlingNode.Dir, handlingNode.IpcPath)) // //log.Debug("swarmfs cli test: unmounting first run...", "ipc path", filepath.Join(handlingNode.Dir, handlingNode.IpcPath))
// unmount := runSwarm(t, []string{ // // unmount := runSwarm(t, []string{
// fmt.Sprintf("--%s", utils.IPCPathFlag.Name), filepath.Join(handlingNode.Dir, handlingNode.IpcPath), // // fmt.Sprintf("--%s", utils.IPCPathFlag.Name), filepath.Join(handlingNode.Dir, handlingNode.IpcPath),
// "fs", // // "fs",
// "unmount", // // "unmount",
// mountPoint, // // mountPoint,
// }...) // // }...)
// _, matches := unmount.ExpectRegexp(hashRegexp) // // _, matches := unmount.ExpectRegexp(hashRegexp)
// unmount.ExpectExit() // // unmount.ExpectExit()
// // //
// hash := matches[0] // // hash := matches[0]
// if hash == mhash { // // if hash == mhash {
// t.Fatal("this should not be equal") // // t.Fatal("this should not be equal")
// } // // }
// log.Debug("swarmfs cli test: asserting no files in mount point") // // log.Debug("swarmfs cli test: asserting no files in mount point")
// // //
// //check that there's nothing in the mount folder // // //check that there's nothing in the mount folder
// filesInDir, err := ioutil.ReadDir(mountPoint) // // filesInDir, err := ioutil.ReadDir(mountPoint)
// if err != nil { // // if err != nil {
// t.Fatalf("had an error reading the directory: %v", err) // // t.Fatalf("had an error reading the directory: %v", err)
// } // // }
// // //
// if len(filesInDir) != 0 { // // if len(filesInDir) != 0 {
// t.Fatal("there shouldn't be anything here") // // t.Fatal("there shouldn't be anything here")
// } // // }
// // //
// secondMountPoint, err := ioutil.TempDir("", "swarm-test") // // secondMountPoint, err := ioutil.TempDir("", "swarm-test")
// log.Debug("swarmfs cli test", "2nd mount point at", secondMountPoint) // // log.Debug("swarmfs cli test", "2nd mount point at", secondMountPoint)
// if err != nil { // // if err != nil {
// t.Fatal(err) // // t.Fatal(err)
// } // // }
// defer os.RemoveAll(secondMountPoint) // // defer os.RemoveAll(secondMountPoint)
// // //
// log.Debug("swarmfs cli test: remounting at second mount point", "ipc path", filepath.Join(handlingNode.Dir, handlingNode.IpcPath)) // // log.Debug("swarmfs cli test: remounting at second mount point", "ipc path", filepath.Join(handlingNode.Dir, handlingNode.IpcPath))
// // //
// //remount, check files // // //remount, check files
// newMount := runSwarm(t, []string{ // // newMount := runSwarm(t, []string{
// fmt.Sprintf("--%s", utils.IPCPathFlag.Name), filepath.Join(handlingNode.Dir, handlingNode.IpcPath), // // fmt.Sprintf("--%s", utils.IPCPathFlag.Name), filepath.Join(handlingNode.Dir, handlingNode.IpcPath),
// "fs", // // "fs",
// "mount", // // "mount",
// hash, // the latest hash // // hash, // the latest hash
// secondMountPoint, // // secondMountPoint,
// }...) // // }...)
// // //
// newMount.ExpectExit() // // newMount.ExpectExit()
// time.Sleep(1 * time.Second) // // time.Sleep(1 * time.Second)
// // //
// filesInDir, err = ioutil.ReadDir(secondMountPoint) // // filesInDir, err = ioutil.ReadDir(secondMountPoint)
// if err != nil { // // if err != nil {
// t.Fatal(err) // // t.Fatal(err)
// } // // }
// // //
// if len(filesInDir) == 0 { // // if len(filesInDir) == 0 {
// t.Fatal("there should be something here") // // t.Fatal("there should be something here")
// } // // }
// // //
// log.Debug("swarmfs cli test: traversing file tree to see it matches previous mount") // // log.Debug("swarmfs cli test: traversing file tree to see it matches previous mount")
// // //
// for _, file := range filesToAssert { // // for _, file := range filesToAssert {
// file.filePath = strings.Replace(file.filePath, mountPoint, secondMountPoint, -1) // // file.filePath = strings.Replace(file.filePath, mountPoint, secondMountPoint, -1)
// fileBytes, err := ioutil.ReadFile(file.filePath) // // fileBytes, err := ioutil.ReadFile(file.filePath)
// // //
// if err != nil { // // if err != nil {
// t.Fatal(err) // // t.Fatal(err)
// } // // }
// if !bytes.Equal(fileBytes, bytes.NewBufferString(file.content).Bytes()) { // // if !bytes.Equal(fileBytes, bytes.NewBufferString(file.content).Bytes()) {
// t.Fatal("this should be equal") // // t.Fatal("this should be equal")
// } // // }
// } // // }
// // //
// log.Debug("swarmfs cli test: unmounting second run", "ipc path", filepath.Join(handlingNode.Dir, handlingNode.IpcPath)) // // log.Debug("swarmfs cli test: unmounting second run", "ipc path", filepath.Join(handlingNode.Dir, handlingNode.IpcPath))
// // //
// unmountSec := runSwarm(t, []string{ // // unmountSec := runSwarm(t, []string{
// fmt.Sprintf("--%s", utils.IPCPathFlag.Name), filepath.Join(handlingNode.Dir, handlingNode.IpcPath), // // fmt.Sprintf("--%s", utils.IPCPathFlag.Name), filepath.Join(handlingNode.Dir, handlingNode.IpcPath),
// "fs", // // "fs",
// "unmount", // // "unmount",
// secondMountPoint, // // secondMountPoint,
// }...) // // }...)
// // //
// _, matches = unmountSec.ExpectRegexp(hashRegexp) // // _, matches = unmountSec.ExpectRegexp(hashRegexp)
// unmountSec.ExpectExit() // // unmountSec.ExpectExit()
// // //
// if matches[0] != hash { // // if matches[0] != hash {
// t.Fatal("these should be equal - no changes made") // // t.Fatal("these should be equal - no changes made")
// } // // }
} // }
func doUploadEmptyDir(t *testing.T, node *testNode) string { // func doUploadEmptyDir(t *testing.T, node *testNode) string {
// create a tmp dir // // create a tmp dir
tmpDir, err := ioutil.TempDir("", "swarm-test") // tmpDir, err := ioutil.TempDir("", "swarm-test")
if err != nil { // if err != nil {
t.Fatal(err) // t.Fatal(err)
} // }
defer os.RemoveAll(tmpDir) // defer os.RemoveAll(tmpDir)
hashRegexp := `[a-f\d]{64}` // hashRegexp := `[a-f\d]{64}`
flags := []string{ // flags := []string{
"--bzzapi", node.URL, // "--bzzapi", node.URL,
"--recursive", // "--recursive",
"up", // "up",
tmpDir} // tmpDir}
log.Info("swarmfs cli test: uploading dir with 'swarm up'") // log.Info("swarmfs cli test: uploading dir with 'swarm up'")
up := runSwarm(t, flags...) // up := runSwarm(t, flags...)
_, matches := up.ExpectRegexp(hashRegexp) // _, matches := up.ExpectRegexp(hashRegexp)
up.ExpectExit() // up.ExpectExit()
hash := matches[0] // hash := matches[0]
log.Info("swarmfs cli test: dir uploaded", "hash", hash) // log.Info("swarmfs cli test: dir uploaded", "hash", hash)
return hash // return hash
} // }
func createDirInDir(createInDir string, dirToCreate string) (string, error) { // func createDirInDir(createInDir string, dirToCreate string) (string, error) {
fullpath := filepath.Join(createInDir, dirToCreate) // fullpath := filepath.Join(createInDir, dirToCreate)
err := os.MkdirAll(fullpath, 0777) // err := os.MkdirAll(fullpath, 0777)
if err != nil { // if err != nil {
return "", err // return "", err
} // }
return fullpath, nil // return fullpath, nil
} // }
func createTestFileInPath(dir, filename, content string) (*testFile, error) { // func createTestFileInPath(dir, filename, content string) (*testFile, error) {
tFile := &testFile{} // tFile := &testFile{}
filePath := filepath.Join(dir, filename) // filePath := filepath.Join(dir, filename)
if file, err := os.Create(filePath); err == nil { // if file, err := os.Create(filePath); err == nil {
tFile.content = content // tFile.content = content
tFile.filePath = filePath // tFile.filePath = filePath
_, err = io.WriteString(file, content) // _, err = io.WriteString(file, content)
if err != nil { // if err != nil {
return nil, err // return nil, err
} // }
file.Close() // file.Close()
} // }
return tFile, nil // return tFile, nil
} // }

View file

@ -63,29 +63,29 @@ func TestSwarmNetwork(t *testing.T) {
options *testSwarmNetworkOptions options *testSwarmNetworkOptions
disabled bool disabled bool
}{ }{
{ // {
name: "10_nodes", // name: "10_nodes",
steps: []testSwarmNetworkStep{ // steps: []testSwarmNetworkStep{
{ // {
nodeCount: 10, // nodeCount: 10,
}, // },
}, // },
options: &testSwarmNetworkOptions{ // options: &testSwarmNetworkOptions{
Timeout: 45 * time.Second, // Timeout: 45 * time.Second,
}, // },
}, // },
{ // {
name: "10_nodes_skip_check", // name: "10_nodes_skip_check",
steps: []testSwarmNetworkStep{ // steps: []testSwarmNetworkStep{
{ // {
nodeCount: 10, // nodeCount: 10,
}, // },
}, // },
options: &testSwarmNetworkOptions{ // options: &testSwarmNetworkOptions{
Timeout: 45 * time.Second, // Timeout: 45 * time.Second,
SkipCheck: true, // SkipCheck: true,
}, // },
}, // },
{ {
name: "50_nodes", name: "50_nodes",
steps: []testSwarmNetworkStep{ steps: []testSwarmNetworkStep{

View file

@ -1362,6 +1362,9 @@ func worker(id int, jobs <-chan Job, rpcs map[enode.ID]*rpc.Client, pubkeys map[
} }
func TestNetwork(t *testing.T) { func TestNetwork(t *testing.T) {
if !*longrunning {
t.Skip("run with --longrunning flag to run extensive network tests")
}
t.Run("16/1000/4/sim", testNetwork) t.Run("16/1000/4/sim", testNetwork)
} }