diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 9d355d28..4bedbb4f 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -48,6 +48,6 @@ jobs: - name: Get dependencies run: go mod download - name: Run end-to-end tests - run: go test -v -cover -coverpkg=./... -parallel 4 ./test/e2e/... -timeout 1000s + run: go test -v -cover -coverpkg=./... -parallel 4 ./test/e2e/... -timeout 180m env: METAL_AUTH_TOKEN: ${{ secrets.METAL_AUTH_TOKEN }} diff --git a/internal/vrf/updateroute.go b/internal/vrf/updateroute.go index 3aa79486..d508bd53 100644 --- a/internal/vrf/updateroute.go +++ b/internal/vrf/updateroute.go @@ -29,10 +29,16 @@ func (c *Client) UpdateRoute() *cobra.Command { inc := []string{} exc := []string{} - vrfRouteUpdateInput := metalv1.VrfRouteUpdateInput{ - Prefix: &prefix, - NextHop: &nextHop, - Tags: tags, + vrfRouteUpdateInput := metalv1.VrfRouteUpdateInput{} + + if prefix != "" { + vrfRouteUpdateInput.Prefix = &prefix + } + if nextHop != "" { + vrfRouteUpdateInput.NextHop = &nextHop + } + if cmd.Flag("tags").Changed { + vrfRouteUpdateInput.Tags = tags } vrfRoute, _, err := c.Service.UpdateVrfRouteById(context.Background(), vrfID).VrfRouteUpdateInput(vrfRouteUpdateInput).Include(c.Servicer.Includes(inc)).Exclude(c.Servicer.Excludes(exc)).Execute() diff --git a/test/e2e/vrfstest/vrf_route_test.go b/test/e2e/vrfstest/vrf_route_test.go index 76d18bcc..9b58e704 100644 --- a/test/e2e/vrfstest/vrf_route_test.go +++ b/test/e2e/vrfstest/vrf_route_test.go @@ -4,6 +4,7 @@ import ( "regexp" "strings" "testing" + "time" root "github.com/equinix/metal-cli/internal/cli" outputPkg "github.com/equinix/metal-cli/internal/outputs" @@ -113,10 +114,6 @@ func TestCli_Vrf_Route(t *testing.T) { }, want: &cobra.Command{}, cmdFunc: func(t *testing.T, c *cobra.Command) { - // Actually user have to wait for 5 min to updae the VRF-routes. This test case is skipped intentionally - if true { - t.Skip("Skipping this test because someCondition is true") - } root := c.Root() projName := "metal-cli-" + randName + "-vrf-list-test" @@ -128,19 +125,22 @@ func TestCli_Vrf_Route(t *testing.T) { ipReservation := helper.CreateTestVrfIpRequest(t, projectId.GetId(), vrf.GetId()) _ = helper.CreateTestVrfGateway(t, projectId.GetId(), ipReservation.VrfIpReservation.GetId(), vlan.GetId()) - _ = helper.CreateTestVrfRoute(t, vrf.GetId()) + route := helper.CreateTestVrfRoute(t, vrf.GetId()) - if vlan.GetId() != "" && vrf.GetId() != "" { - root.SetArgs([]string{subCommand, "update-route", "-i", vrf.GetId(), "-t", "foobar"}) + // We literally need to sleep for 5 minutes; the API will reject any + // VRF route update request that comes in less than 5 minutes after + // the VRF route was last updated + time.Sleep(300 * time.Second) - out := helper.ExecuteAndCaptureOutput(t, root) + root.SetArgs([]string{subCommand, "update-route", "-i", route.GetId(), "-t", "foobar"}) - if !strings.Contains(string(out[:]), "TYPE") && - !strings.Contains(string(out[:]), "static") && - !strings.Contains(string(out[:]), "PREFIX") && - !strings.Contains(string(out[:]), "0.0.0.0/0") { - t.Error("expected output should include TYPE static PREFIX and 0.0.0.0/0, in the out string ") - } + out := helper.ExecuteAndCaptureOutput(t, root) + + if !strings.Contains(string(out[:]), "TYPE") && + !strings.Contains(string(out[:]), "static") && + !strings.Contains(string(out[:]), "PREFIX") && + !strings.Contains(string(out[:]), "0.0.0.0/0") { + t.Error("expected output should include TYPE static PREFIX and 0.0.0.0/0, in the out string ") } } },