e2e: fix failing tests due to region name change. (#24713)

This commit is contained in:
James Rasell
2024-12-19 15:21:17 +01:00
committed by GitHub
parent 04e930b756
commit 8bb7c1315d
3 changed files with 9 additions and 23 deletions

View File

@@ -40,7 +40,7 @@ func testCNIArgs(t *testing.T) {
job, _ := jobs3.Submit(t, "./input/cni_args.nomad.hcl") job, _ := jobs3.Submit(t, "./input/cni_args.nomad.hcl")
logs := job.Exec("group", "task", []string{"cat", "local/victory"}) logs := job.Exec("group", "task", []string{"cat", "local/victory"})
t.Logf("FancyMessage: %s", logs.Stdout) t.Logf("FancyMessage: %s", logs.Stdout)
// "global" is the Nomad node's region, interpolated in the jobspec, // "default" is the Nomad node's pool, interpolated in the jobspec, passed
// passed through the CNI plugin, and cat-ed by the task. // through the CNI plugin, and cat-ed by the task.
must.Eq(t, "global\n", logs.Stdout) must.Eq(t, "default\n", logs.Stdout)
} }

View File

@@ -8,9 +8,10 @@ job "cni_args" {
cni { cni {
# feature under test # feature under test
args = { args = {
# the message gets placed as a file called "victory" # the message gets placed as a file called "victory" in the task dir
# in the task dir specified here by the cni_args.sh plugin # specified here by the cni_args.sh plugin. Using node pool allows us
FancyMessage = "${node.region}" # to test interpolation as an extra.
FancyMessage = "${node.pool}"
FancyTaskDir = "${NOMAD_ALLOC_DIR}/task/local" FancyTaskDir = "${NOMAD_ALLOC_DIR}/task/local"
} }
} }

View File

@@ -75,7 +75,6 @@ func testRunCLIVarFlags(t *testing.T) {
// check the submission api // check the submission api
sub, _, err := nomad.Jobs().Submission(jobID, 0, &api.QueryOptions{ sub, _, err := nomad.Jobs().Submission(jobID, 0, &api.QueryOptions{
Region: "global",
Namespace: "default", Namespace: "default",
}) })
must.NoError(t, err) must.NoError(t, err)
@@ -101,7 +100,6 @@ func testRunCLIVarFlags(t *testing.T) {
// check the submission api for v1 // check the submission api for v1
sub, _, err = nomad.Jobs().Submission(jobID, 1, &api.QueryOptions{ sub, _, err = nomad.Jobs().Submission(jobID, 1, &api.QueryOptions{
Region: "global",
Namespace: "default", Namespace: "default",
}) })
must.NoError(t, err) must.NoError(t, err)
@@ -112,7 +110,6 @@ func testRunCLIVarFlags(t *testing.T) {
// check the submission api for v0 (make sure we still have it) // check the submission api for v0 (make sure we still have it)
sub, _, err = nomad.Jobs().Submission(jobID, 0, &api.QueryOptions{ sub, _, err = nomad.Jobs().Submission(jobID, 0, &api.QueryOptions{
Region: "global",
Namespace: "default", Namespace: "default",
}) })
must.NoError(t, err) must.NoError(t, err)
@@ -130,7 +127,6 @@ func testRunCLIVarFlags(t *testing.T) {
// check the submission api for v0 after deregister (make sure its gone) // check the submission api for v0 after deregister (make sure its gone)
sub, _, err = nomad.Jobs().Submission(jobID, 0, &api.QueryOptions{ sub, _, err = nomad.Jobs().Submission(jobID, 0, &api.QueryOptions{
Region: "global",
Namespace: "default", Namespace: "default",
}) })
must.ErrorContains(t, err, "job source not found") must.ErrorContains(t, err, "job source not found")
@@ -149,9 +145,7 @@ func testSubmissionACL(t *testing.T) {
namespaceClient := nomad.Namespaces() namespaceClient := nomad.Namespaces()
_, err := namespaceClient.Register(&api.Namespace{ _, err := namespaceClient.Register(&api.Namespace{
Name: myNamespaceName, Name: myNamespaceName,
}, &api.WriteOptions{ }, &api.WriteOptions{})
Region: "global",
})
must.NoError(t, err) must.NoError(t, err)
aclCleanup.Add(myNamespaceName, acl.NamespaceTestResourceType) aclCleanup.Add(myNamespaceName, acl.NamespaceTestResourceType)
@@ -159,9 +153,7 @@ func testSubmissionACL(t *testing.T) {
otherNamespaceName := "submission-other-acl-" + uuid.Short() otherNamespaceName := "submission-other-acl-" + uuid.Short()
_, err = namespaceClient.Register(&api.Namespace{ _, err = namespaceClient.Register(&api.Namespace{
Name: otherNamespaceName, Name: otherNamespaceName,
}, &api.WriteOptions{ }, &api.WriteOptions{})
Region: "global",
})
must.NoError(t, err) must.NoError(t, err)
aclCleanup.Add(otherNamespaceName, acl.NamespaceTestResourceType) aclCleanup.Add(otherNamespaceName, acl.NamespaceTestResourceType)
@@ -192,7 +184,6 @@ func testSubmissionACL(t *testing.T) {
Type: "client", Type: "client",
Policies: []string{myNamespacePolicy.Name}, Policies: []string{myNamespacePolicy.Name},
}, &api.WriteOptions{ }, &api.WriteOptions{
Region: "global",
Namespace: myNamespaceName, Namespace: myNamespaceName,
}) })
must.NoError(t, err) must.NoError(t, err)
@@ -204,7 +195,6 @@ func testSubmissionACL(t *testing.T) {
Type: "client", Type: "client",
Policies: []string{otherNamespacePolicy.Name}, Policies: []string{otherNamespacePolicy.Name},
}, &api.WriteOptions{ }, &api.WriteOptions{
Region: "global",
Namespace: otherNamespaceName, Namespace: otherNamespaceName,
}) })
must.NoError(t, err) must.NoError(t, err)
@@ -232,7 +222,6 @@ func testSubmissionACL(t *testing.T) {
// get submission using my token // get submission using my token
sub, _, err := nomad.Jobs().Submission(jobID, 0, &api.QueryOptions{ sub, _, err := nomad.Jobs().Submission(jobID, 0, &api.QueryOptions{
Region: "global",
Namespace: myNamespaceName, Namespace: myNamespaceName,
AuthToken: myToken.SecretID, AuthToken: myToken.SecretID,
}) })
@@ -244,7 +233,6 @@ func testSubmissionACL(t *testing.T) {
// get submission using other token (fail) // get submission using other token (fail)
sub, _, err = nomad.Jobs().Submission(jobID, 0, &api.QueryOptions{ sub, _, err = nomad.Jobs().Submission(jobID, 0, &api.QueryOptions{
Region: "global",
Namespace: myNamespaceName, Namespace: myNamespaceName,
AuthToken: otherToken.SecretID, AuthToken: otherToken.SecretID,
}) })
@@ -274,7 +262,6 @@ func testMaxSize(t *testing.T) {
// check the submission api making sure it is not there // check the submission api making sure it is not there
nomad := e2eutil.NomadClient(t) nomad := e2eutil.NomadClient(t)
sub, _, err := nomad.Jobs().Submission(jobID, 0, &api.QueryOptions{ sub, _, err := nomad.Jobs().Submission(jobID, 0, &api.QueryOptions{
Region: "global",
Namespace: "default", Namespace: "default",
}) })
must.ErrorContains(t, err, "job source not found") must.ErrorContains(t, err, "job source not found")
@@ -313,7 +300,6 @@ func testReversion(t *testing.T) {
expectY := []string{"0", "1", "2", "1"} expectY := []string{"0", "1", "2", "1"}
for version := 0; version < 4; version++ { for version := 0; version < 4; version++ {
sub, _, err := nomad.Jobs().Submission(jobID, version, &api.QueryOptions{ sub, _, err := nomad.Jobs().Submission(jobID, version, &api.QueryOptions{
Region: "global",
Namespace: "default", Namespace: "default",
}) })
must.NoError(t, err) must.NoError(t, err)
@@ -348,7 +334,6 @@ func testVarFiles(t *testing.T) {
// get submission // get submission
sub, _, err := nomad.Jobs().Submission(jobID, version, &api.QueryOptions{ sub, _, err := nomad.Jobs().Submission(jobID, version, &api.QueryOptions{
Region: "global",
Namespace: "default", Namespace: "default",
}) })
must.NoError(t, err) must.NoError(t, err)