tools/run-cts: Use new 'load' server RPC
Can dramatically reduce latency for small test runs. Requires: https://github.com/gpuweb/cts/pull/2167 Change-Id: Ib5ff5d0fbcaf151ffe67bf30e97c9ccdf34443e0 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117200 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Kokoro: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
0eba1ca6b2
commit
330bc25322
|
@ -235,6 +235,7 @@ func run() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
r := runner{
|
r := runner{
|
||||||
|
query: query,
|
||||||
numRunners: numRunners,
|
numRunners: numRunners,
|
||||||
verbose: verbose,
|
verbose: verbose,
|
||||||
node: node,
|
node: node,
|
||||||
|
@ -328,8 +329,8 @@ func run() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if numRunners > 0 {
|
if numRunners > 0 {
|
||||||
// Find all the test cases that match the given queries.
|
// Find all the test cases that match r.query.
|
||||||
if err := r.gatherTestCases(query, verbose); err != nil {
|
if err := r.gatherTestCases(verbose); err != nil {
|
||||||
return fmt.Errorf("failed to gather test cases: %w", err)
|
return fmt.Errorf("failed to gather test cases: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,6 +417,7 @@ func (c *cache) save(path string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
type runner struct {
|
type runner struct {
|
||||||
|
query string
|
||||||
numRunners int
|
numRunners int
|
||||||
verbose bool
|
verbose bool
|
||||||
node string
|
node string
|
||||||
|
@ -486,9 +488,9 @@ func (r *runner) buildCTS(verbose bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// gatherTestCases() queries the CTS for all test cases that match the given
|
// gatherTestCases() queries the CTS for all test cases that match r.query.
|
||||||
// query. On success, gatherTestCases() populates r.testcases.
|
// On success, gatherTestCases() populates r.testcases.
|
||||||
func (r *runner) gatherTestCases(query string, verbose bool) error {
|
func (r *runner) gatherTestCases(verbose bool) error {
|
||||||
if verbose {
|
if verbose {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
fmt.Fprintln(r.stdout, "Gathering test cases...")
|
fmt.Fprintln(r.stdout, "Gathering test cases...")
|
||||||
|
@ -505,7 +507,7 @@ func (r *runner) gatherTestCases(query string, verbose bool) error {
|
||||||
// start at 1, so just inject a placeholder argument.
|
// start at 1, so just inject a placeholder argument.
|
||||||
"placeholder-arg",
|
"placeholder-arg",
|
||||||
"--list",
|
"--list",
|
||||||
}, query)
|
}, r.query)
|
||||||
|
|
||||||
cmd := exec.Command(r.node, args...)
|
cmd := exec.Command(r.node, args...)
|
||||||
cmd.Dir = r.cts
|
cmd.Dir = r.cts
|
||||||
|
@ -695,12 +697,27 @@ func (r *runner) runServer(ctx context.Context, id int, caseIndices <-chan int,
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case port = <-pl.port:
|
case port = <-pl.port:
|
||||||
return nil // success
|
break // success
|
||||||
case <-time.After(time.Second * 10):
|
case <-time.After(time.Second * 10):
|
||||||
return fmt.Errorf("timeout waiting for server port:\n%v", pl.buffer.String())
|
return fmt.Errorf("timeout waiting for server port:\n%v", pl.buffer.String())
|
||||||
case <-ctx.Done(): // cancelled
|
case <-ctx.Done(): // cancelled
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load the cases
|
||||||
|
postResp, postErr := http.Post(fmt.Sprintf("http://localhost:%v/load?%v", port, r.query), "", &bytes.Buffer{})
|
||||||
|
if postErr != nil || postResp.StatusCode != http.StatusOK {
|
||||||
|
msg := &strings.Builder{}
|
||||||
|
fmt.Println(msg, "failed to load test cases: ", postErr)
|
||||||
|
if body, err := ioutil.ReadAll(postResp.Body); err == nil {
|
||||||
|
fmt.Println(msg, string(body))
|
||||||
|
} else {
|
||||||
|
fmt.Println(msg, err)
|
||||||
|
}
|
||||||
|
return fmt.Errorf("%v", msg.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
stopServer = func() {
|
stopServer = func() {
|
||||||
if port > 0 {
|
if port > 0 {
|
||||||
|
|
Loading…
Reference in New Issue