Files
nomad/e2e/e2eutil/deployments.go
Tim Gross 2ec1eb4ec6 e2e: refactor CLI utils out of rescheduling test (#8905)
The CLI helpers in the rescheduling test were intended for shared use, but
until some other tests were written we didn't want to waste time making them
generic. This changeset refactors them and adds some new helpers associated
with the node drain tests (under separate PR).
2020-09-16 16:10:06 -04:00

39 lines
930 B
Go

package e2eutil
import (
"fmt"
"time"
"github.com/hashicorp/nomad/testutil"
)
func WaitForLastDeploymentStatus(jobID, status string, wc *WaitConfig) error {
var got string
var err error
interval, retries := wc.OrDefault()
testutil.WaitForResultRetries(retries, func() (bool, error) {
time.Sleep(interval)
out, err := Command("nomad", "job", "status", jobID)
if err != nil {
return false, fmt.Errorf("could not get job status: %v\n%v", err, out)
}
section, err := GetSection(out, "Latest Deployment")
if err != nil {
return false, fmt.Errorf("could not find Latest Deployment section: %w", err)
}
fields, err := ParseFields(section)
if err != nil {
return false, fmt.Errorf("could not parse Latest Deployment section: %w", err)
}
got = fields["Status"]
return got == status, nil
}, func(e error) {
err = fmt.Errorf("deployment status check failed: got %#v", got)
})
return err
}