Compare commits

..

2 Commits

Author SHA1 Message Date
HAOYUatHZ
54c28fa512 build: update version (#387) 2023-03-24 09:25:10 +08:00
maskpp
3c7c41e1bb fix(cmd test): add more log to handle error and remove serial execution test (#391) 2023-03-23 16:43:41 +08:00
7 changed files with 38 additions and 36 deletions

35
Jenkinsfile vendored
View File

@@ -61,44 +61,29 @@ pipeline {
}
stage('Parallel Test') {
parallel{
stage('Test bridge package') {
stage('Race test common package') {
steps {
sh 'go test -v -coverprofile=coverage.bridge.txt -covermode=atomic -p 1 scroll-tech/bridge/...'
}
}
stage('Test common package') {
steps {
sh 'go test -v -coverprofile=coverage.common.txt -covermode=atomic -p 1 scroll-tech/common/...'
}
}
stage('Test coordinator package') {
steps {
sh 'go test -v -coverprofile=coverage.coordinator.txt -covermode=atomic -p 1 scroll-tech/coordinator/...'
}
}
stage('Test database package') {
steps {
sh 'go test -v -coverprofile=coverage.db.txt -covermode=atomic -p 1 scroll-tech/database/...'
}
}
stage('Integration test') {
steps {
sh 'go test -v -tags="mock_prover mock_verifier" -coverprofile=coverage.integration.txt -covermode=atomic -p 1 scroll-tech/integration-test/...'
sh 'go test -v -race -coverprofile=coverage.common.txt -covermode=atomic scroll-tech/common/...'
}
}
stage('Race test bridge package') {
steps {
sh 'go test -v -race -coverprofile=coverage.txt -covermode=atomic scroll-tech/bridge/...'
sh 'go test -v -race -coverprofile=coverage.bridge.txt -covermode=atomic scroll-tech/bridge/...'
}
}
stage('Race test coordinator package') {
steps {
sh 'go test -v -race -coverprofile=coverage.txt -covermode=atomic scroll-tech/coordinator/...'
sh 'go test -v -race -coverprofile=coverage.coordinator.txt -covermode=atomic scroll-tech/coordinator/...'
}
}
stage('Race test database package') {
steps {
sh 'go test -v -race -coverprofile=coverage.txt -covermode=atomic scroll-tech/database/...'
sh 'go test -v -race -coverprofile=coverage.db.txt -covermode=atomic scroll-tech/database/...'
}
}
stage('Integration test') {
steps {
sh 'go test -v -tags="mock_prover mock_verifier" -p 1 scroll-tech/integration-test/...'
}
}
}

View File

@@ -4,7 +4,7 @@ ${GOROOT}/bin/bin/gocover-cobertura < coverage.bridge.txt > coverage.bridge.xml
${GOROOT}/bin/bin/gocover-cobertura < coverage.db.txt > coverage.db.xml
${GOROOT}/bin/bin/gocover-cobertura < coverage.common.txt > coverage.common.xml
${GOROOT}/bin/bin/gocover-cobertura < coverage.coordinator.txt > coverage.coordinator.xml
# ${GOROOT}/bin/bin/gocover-cobertura < coverage.integration.txt > coverage.integration.xml
#${GOROOT}/bin/bin/gocover-cobertura < coverage.integration.txt > coverage.integration.xml
npx cobertura-merge -o cobertura.xml \
package1=coverage.bridge.xml \

View File

@@ -31,8 +31,8 @@ type Cmd struct {
checkFuncs cmap.ConcurrentMap //map[string]checkFunc
//stdout bytes.Buffer
Err error
// error channel
ErrChan chan error
}
// NewCmd create Cmd instance.
@@ -41,6 +41,7 @@ func NewCmd(name string, args ...string) *Cmd {
checkFuncs: cmap.New(),
name: name,
args: args,
ErrChan: make(chan error, 10),
}
}
@@ -58,7 +59,7 @@ func (c *Cmd) runCmd() {
cmd := exec.Command(c.args[0], c.args[1:]...) //nolint:gosec
cmd.Stdout = c
cmd.Stderr = c
_ = cmd.Run()
c.ErrChan <- cmd.Run()
}
// RunCmd parallel running when parallel is true.

View File

@@ -38,9 +38,17 @@ func (c *Cmd) RunApp(waitResult func() bool) {
// WaitExit wait util process exit.
func (c *Cmd) WaitExit() {
// Wait all the check funcs are finished or test status is failed.
for !(c.Err != nil || c.checkFuncs.IsEmpty()) {
<-time.After(time.Millisecond * 500)
// Wait all the check functions are finished, interrupt loop when appear error.
var err error
for err == nil && !c.checkFuncs.IsEmpty() {
select {
case err = <-c.ErrChan:
if err != nil {
fmt.Printf("%s appear error durning running, err: %v\n", c.name, err)
}
default:
<-time.After(time.Millisecond * 500)
}
}
// Send interrupt signal.
@@ -56,7 +64,7 @@ func (c *Cmd) WaitExit() {
// Interrupt send interrupt signal.
func (c *Cmd) Interrupt() {
c.mu.Lock()
c.Err = c.cmd.Process.Signal(os.Interrupt)
c.ErrChan <- c.cmd.Process.Signal(os.Interrupt)
c.mu.Unlock()
}

View File

@@ -114,8 +114,12 @@ func (i *ImgDB) isOk() bool {
i.id = GetContainerID(i.name)
return i.id != ""
})
return i.id != ""
case err := <-i.cmd.ErrChan:
if err != nil {
fmt.Printf("failed to start %s, err: %v\n", i.name, err)
}
case <-time.After(time.Second * 20):
return false
}
return i.id != ""
}

View File

@@ -93,10 +93,14 @@ func (i *ImgGeth) isOk() bool {
i.id = GetContainerID(i.name)
return i.id != ""
})
return i.id != ""
case err := <-i.cmd.ErrChan:
if err != nil {
fmt.Printf("failed to start %s, err: %v\n", i.name, err)
}
case <-time.After(time.Second * 10):
return false
}
return i.id != ""
}
// Stop the docker container.

View File

@@ -5,7 +5,7 @@ import (
"runtime/debug"
)
var tag = "alpha-v2.5"
var tag = "v3.0.0"
var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {