Browse Source

functional/tester: handle "process already finished"

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Gyuho Lee 7 years ago
parent
commit
7facfde6fd
2 changed files with 25 additions and 13 deletions
  1. 21 8
      functional/tester/cluster.go
  2. 4 5
      functional/tester/cluster_run.go

+ 21 - 8
functional/tester/cluster.go

@@ -18,6 +18,7 @@ import (
 	"context"
 	"context"
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
+	"io"
 	"io/ioutil"
 	"io/ioutil"
 	"math/rand"
 	"math/rand"
 	"net/http"
 	"net/http"
@@ -318,15 +319,27 @@ func (clus *Cluster) broadcastOperation(op rpcpb.Operation) error {
 			continue
 			continue
 		}
 		}
 
 
-		if err != nil &&
-			op == rpcpb.Operation_DestroyEtcdAgent &&
-			strings.Contains(err.Error(), "rpc error: code = Unavailable desc = transport is closing") {
-			// agent server has already closed;
-			// so this error is expected
-			clus.lg.Info("successfully destroyed all")
-			continue
+		if err != nil {
+			destroyed := false
+			if op == rpcpb.Operation_DestroyEtcdAgent {
+				if err == io.EOF {
+					destroyed = true
+				}
+				if strings.Contains(err.Error(),
+					"rpc error: code = Unavailable desc = transport is closing") {
+					// agent server has already closed;
+					// so this error is expected
+					destroyed = true
+				}
+				if strings.Contains(err.Error(),
+					"desc = os: process already finished") {
+					destroyed = true
+				}
+			}
+			if !destroyed {
+				errs = append(errs, err.Error())
+			}
 		}
 		}
-		errs = append(errs, err.Error())
 	}
 	}
 
 
 	if len(errs) == 0 {
 	if len(errs) == 0 {

+ 4 - 5
functional/tester/cluster_run.go

@@ -292,10 +292,6 @@ func (clus *Cluster) compact(rev int64, timeout time.Duration) (err error) {
 }
 }
 
 
 func (clus *Cluster) failed() {
 func (clus *Cluster) failed() {
-	if !clus.Tester.ExitOnFailure {
-		return
-	}
-
 	clus.lg.Info(
 	clus.lg.Info(
 		"functional-tester FAIL",
 		"functional-tester FAIL",
 		zap.Int("round", clus.rd),
 		zap.Int("round", clus.rd),
@@ -303,11 +299,14 @@ func (clus *Cluster) failed() {
 		zap.Int("case-total", len(clus.failures)),
 		zap.Int("case-total", len(clus.failures)),
 	)
 	)
 	clus.DestroyEtcdAgents()
 	clus.DestroyEtcdAgents()
+
 	os.Exit(2)
 	os.Exit(2)
 }
 }
 
 
 func (clus *Cluster) cleanup() error {
 func (clus *Cluster) cleanup() error {
-	defer clus.failed()
+	if clus.Tester.ExitOnFailure {
+		defer clus.failed()
+	}
 
 
 	roundFailedTotalCounter.Inc()
 	roundFailedTotalCounter.Inc()
 	desc := "compact/defrag"
 	desc := "compact/defrag"