зеркало из https://github.com/github/vitess-gh.git
Address review comments
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
This commit is contained in:
Родитель
cab2a7e1ba
Коммит
dd042cf467
3
go.mod
3
go.mod
|
@ -83,6 +83,7 @@ require (
|
|||
github.com/stretchr/testify v1.7.0
|
||||
github.com/tchap/go-patricia v2.2.6+incompatible
|
||||
github.com/tebeka/selenium v0.9.9
|
||||
github.com/tidwall/gjson v1.12.1
|
||||
github.com/tinylib/msgp v1.1.1 // indirect
|
||||
github.com/uber-go/atomic v1.4.0 // indirect
|
||||
github.com/uber/jaeger-client-go v2.16.0+incompatible
|
||||
|
@ -174,6 +175,8 @@ require (
|
|||
github.com/spf13/cast v1.3.1 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/subosito/gotenv v1.2.0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.0.1 // indirect
|
||||
go.opencensus.io v0.23.0 // indirect
|
||||
|
|
6
go.sum
6
go.sum
|
@ -740,7 +740,13 @@ github.com/tchap/go-patricia v2.2.6+incompatible h1:JvoDL7JSoIP2HDE8AbDH3zC8QBPx
|
|||
github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ23RP/odRBOTVjwp2cDyi6I=
|
||||
github.com/tebeka/selenium v0.9.9 h1:cNziB+etNgyH/7KlNI7RMC1ua5aH1+5wUlFQyzeMh+w=
|
||||
github.com/tebeka/selenium v0.9.9/go.mod h1:5Fr8+pUvU6B1OiPfkdCKdXZyr5znvVkxuPd0NOdZCQc=
|
||||
github.com/tidwall/gjson v1.12.1 h1:ikuZsLdhr8Ws0IdROXUS1Gi4v9Z4pGqpX/CvJkxvfpo=
|
||||
github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tinylib/msgp v1.1.1 h1:TnCZ3FIuKeaIy+F45+Cnp+caqdXGy4z74HvwXN+570Y=
|
||||
github.com/tinylib/msgp v1.1.1/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
|
|
|
@ -22,6 +22,8 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"vitess.io/vitess/go/vt/log"
|
||||
|
@ -246,24 +248,43 @@ func TestBasicV2Workflows(t *testing.T) {
|
|||
log.Flush()
|
||||
}
|
||||
|
||||
const workflowStartTimeout = 5 * time.Second
|
||||
|
||||
func waitForWorkflowToStart(t *testing.T, ksWorkflow string) {
|
||||
done := false
|
||||
ticker := time.NewTicker(10 * time.Millisecond)
|
||||
ticker := time.NewTicker(100 * time.Millisecond)
|
||||
timer := time.NewTimer(workflowStartTimeout)
|
||||
log.Infof("Waiting for workflow %s to start", ksWorkflow)
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
if done {
|
||||
log.Infof("Workflow %s has started", ksWorkflow)
|
||||
return
|
||||
}
|
||||
output, err := vc.VtctlClient.ExecuteCommandWithOutput("Workflow", ksWorkflow, "show")
|
||||
require.NoError(t, err)
|
||||
if strings.Contains(output, "\"State\": \"Running\"") {
|
||||
done = true
|
||||
log.Infof("Workflow %s has started", ksWorkflow)
|
||||
}
|
||||
case <-time.After(5 * time.Second):
|
||||
require.FailNow(t, "workflow %s not yet started", ksWorkflow)
|
||||
done = true
|
||||
state := ""
|
||||
result := gjson.Get(output, "ShardStatuses")
|
||||
result.ForEach(func(tabletId, tabletStreams gjson.Result) bool { // for each participating tablet
|
||||
tabletStreams.ForEach(func(streamId, streamInfos gjson.Result) bool { // for each stream
|
||||
if streamId.String() == "PrimaryReplicationStatuses" {
|
||||
streamInfos.ForEach(func(attributeKey, attributeValue gjson.Result) bool { // for each attribute in the stream
|
||||
state = attributeValue.Get("State").String()
|
||||
if state != "Running" {
|
||||
done = false // we need to wait for all streams to start
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
return true
|
||||
})
|
||||
return true
|
||||
})
|
||||
|
||||
case <-timer.C:
|
||||
require.FailNowf(t, "workflow %s not yet started", ksWorkflow)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче