mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
E2e/fix periodic (#10047)
* fix periodic * update periodic to not use template nomad job inspect no longer returns an apiliststub so the required fields to query job summary are no longer there, parse cli output instead * rm tmp makefile entry * fix typo * revert makefile change
This commit is contained in:
@@ -93,3 +93,41 @@ func RegisterFromJobspec(jobID, jobspec string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ChildrenJobSummary(jobID string) ([]map[string]string, error) {
|
||||
out, err := Command("nomad", "job", "status", jobID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("nomad job status failed: %w", err)
|
||||
}
|
||||
|
||||
section, err := GetSection(out, "Children Job Summary")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not find children job summary section: %w", err)
|
||||
}
|
||||
|
||||
summary, err := ParseColumns(section)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not parse children job summary section: %w", err)
|
||||
}
|
||||
|
||||
return summary, nil
|
||||
}
|
||||
|
||||
func PreviouslyLaunched(jobID string) ([]map[string]string, error) {
|
||||
out, err := Command("nomad", "job", "status", jobID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("nomad job status failed: %w", err)
|
||||
}
|
||||
|
||||
section, err := GetSection(out, "Previously Launched Jobs")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not find previously launched jobs section: %w", err)
|
||||
}
|
||||
|
||||
summary, err := ParseColumns(section)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not parse previously launched jobs section: %w", err)
|
||||
}
|
||||
|
||||
return summary, nil
|
||||
}
|
||||
|
||||
@@ -53,39 +53,26 @@ func (tc *PeriodicTest) TestPeriodicDispatch_Basic(f *framework.F) {
|
||||
// force dispatch
|
||||
require.NoError(t, e2eutil.PeriodicForce(jobID))
|
||||
|
||||
// Get the child job ID
|
||||
testutil.WaitForResult(func() (bool, error) {
|
||||
childID, err := e2eutil.JobInspectTemplate(jobID, `{{with index . 1}}{{printf "%s" .ID}}{{end}}`)
|
||||
children, err := e2eutil.PreviouslyLaunched(jobID)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if childID != "" {
|
||||
return true, nil
|
||||
}
|
||||
return false, fmt.Errorf("expected non-empty periodic child jobID for job %s", jobID)
|
||||
}, func(err error) {
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
testutil.WaitForResult(func() (bool, error) {
|
||||
status, err := e2eutil.JobInspectTemplate(jobID, `{{with index . 1}}{{printf "%s" .Status}}{{end}}`)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, status)
|
||||
if status == "dead" {
|
||||
return true, nil
|
||||
for _, c := range children {
|
||||
if c["Status"] == "dead" {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, fmt.Errorf("expected periodic job to be dead, got %s", status)
|
||||
return false, fmt.Errorf("expected periodic job to be dead")
|
||||
}, func(err error) {
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
// Assert there are no pending children
|
||||
pending, err := e2eutil.JobInspectTemplate(jobID, `{{with index . 0}}{{printf "%d" .JobSummary.Children.Pending}}{{end}}`)
|
||||
summary, err := e2eutil.ChildrenJobSummary(jobID)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "0", pending)
|
||||
|
||||
// Assert there are no pending children
|
||||
dead, err := e2eutil.JobInspectTemplate(jobID, `{{with index . 0}}{{printf "%d" .JobSummary.Children.Dead}}{{end}}`)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "1", dead)
|
||||
require.Len(t, summary, 1)
|
||||
require.Equal(t, summary[0]["Pending"], "0")
|
||||
require.Equal(t, summary[0]["Dead"], "1")
|
||||
}
|
||||
|
||||
1
e2e/terraform/.terraform.lock.hcl
generated
1
e2e/terraform/.terraform.lock.hcl
generated
@@ -23,6 +23,7 @@ provider "registry.terraform.io/hashicorp/external" {
|
||||
version = "2.0.0"
|
||||
hashes = [
|
||||
"h1:6S7hqjmUnoAZ5D/0F1VlJZKSJsUIBh7Ro0tLjGpKO0g=",
|
||||
"h1:Q5xqryWI3tCY8yr+fugq7dz4Qz+8g4GaW9ZS8dc6Ob8=",
|
||||
"zh:07949780dd6a1d43e7b46950f6e6976581d9724102cb5388d3411a1b6f476bde",
|
||||
"zh:0a4f4636ff93f0644affa8474465dd8c9252946437ad025b28fc9f6603534a24",
|
||||
"zh:0dd7e05a974c649950d1a21d7015d3753324ae52ebdd1744b144bc409ca4b3e8",
|
||||
|
||||
Reference in New Issue
Block a user