Merge pull request #9809 from hashicorp/f-use-jobspec2-in-e2eutil

e2e: use jobspec2 Parse for parsing jobfile in e2e utils
This commit is contained in:
Seth Hoenig 2021-01-13 14:14:34 -06:00 committed by GitHub
commit f1084b0a84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package e2eutil
import (
"fmt"
"os"
"strings"
"testing"
"time"
@ -9,7 +10,7 @@ import (
consulapi "github.com/hashicorp/consul/api"
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/jobspec"
"github.com/hashicorp/nomad/jobspec2"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/testutil"
"github.com/kr/pretty"
@ -63,10 +64,16 @@ func stringToPtrOrNil(s string) *string {
return helper.StringToPtr(s)
}
func Parse2(t *testing.T, jobFile string) (*api.Job, error) {
f, err := os.Open(jobFile)
require.NoError(t, err)
return jobspec2.Parse(jobFile, f)
}
func RegisterAllocs(t *testing.T, nomadClient *api.Client, jobFile, jobID, cToken string) []*api.AllocationListStub {
// Parse job
job, err := jobspec.ParseFile(jobFile)
job, err := Parse2(t, jobFile)
require.NoError(t, err)
// Set custom job ID (distinguish among tests)