From aa3150ffee4c922c385f56035a2a2d9b51b2e8e4 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Thu, 19 Oct 2023 11:43:22 -0400 Subject: [PATCH] Fix manual start test --- tests/accept_manual_start_test.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/accept_manual_start_test.go b/tests/accept_manual_start_test.go index 1b2dab72f..ef88ce57f 100644 --- a/tests/accept_manual_start_test.go +++ b/tests/accept_manual_start_test.go @@ -20,9 +20,10 @@ package tests import ( "github.com/michaelquigley/pfxlog" - "github.com/openziti/ziti/controller/xt" "github.com/openziti/sdk-golang/ziti" "github.com/openziti/sdk-golang/ziti/edge" + "github.com/openziti/ziti/controller/change" + "github.com/openziti/ziti/controller/xt" "github.com/pkg/errors" "sync/atomic" "testing" @@ -34,7 +35,9 @@ func Test_ManualStart(t *testing.T) { defer ctx.Teardown() ctx.StartServer() - xt.GlobalRegistry().RegisterFactory(&testFailoverStrategyFactory{}) + xt.GlobalRegistry().RegisterFactory(&testFailoverStrategyFactory{ + ctx: ctx, + }) t.Run("creating service and edge router", func(t *testing.T) { ctx.testContextChanged(t) ctx.RequireAdminManagementApiLogin() @@ -165,25 +168,35 @@ func Test_ManualStart(t *testing.T) { }) } -type testFailoverStrategyFactory struct{} +type testFailoverStrategyFactory struct { + ctx *TestContext +} func (self *testFailoverStrategyFactory) GetStrategyName() string { return "test-failover" } func (self *testFailoverStrategyFactory) NewStrategy() xt.Strategy { - return &testFailoverStrategy{} + return &testFailoverStrategy{ + ctx: self.ctx, + } } type testFailoverStrategy struct { xt.DefaultEventVisitor failCount int32 + ctx *TestContext } func (self *testFailoverStrategy) VisitDialFailed(event xt.TerminatorEvent) { failCount := atomic.AddInt32(&self.failCount, 1) if failCount >= 3 { - xt.GlobalCosts().SetPrecedence(event.GetTerminator().GetId(), xt.Precedences.Failed) + mgr := self.ctx.EdgeController.AppEnv.Managers.Terminator + t, err := mgr.Read(event.GetTerminator().GetId()) + self.ctx.Req.NoError(err) + t.Precedence = xt.Precedences.Failed + err = mgr.Update(t, nil, change.New()) + self.ctx.Req.NoError(err) } }