From 7fe9eb9fe08f6f257fbf80394fc26c62202598b5 Mon Sep 17 00:00:00 2001 From: lwolczynski <54366429+lwolczynski@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:42:41 -0600 Subject: [PATCH] IWF-232: Add disabling sticky cache option (#473) --- .../ci-cadence-integ-test-disable-sticky.yml | 26 ++++++++++++++++ .../ci-temporal-integ-test-disable-sticky.yml | 31 +++++++++++++++++++ Makefile | 8 ++++- integ/flag.go | 2 ++ integ/util.go | 12 +++++-- service/interpreter/cadence/worker.go | 15 +++++++++ service/interpreter/temporal/worker.go | 15 +++++++++ 7 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci-cadence-integ-test-disable-sticky.yml create mode 100644 .github/workflows/ci-temporal-integ-test-disable-sticky.yml diff --git a/.github/workflows/ci-cadence-integ-test-disable-sticky.yml b/.github/workflows/ci-cadence-integ-test-disable-sticky.yml new file mode 100644 index 00000000..753f91c8 --- /dev/null +++ b/.github/workflows/ci-cadence-integ-test-disable-sticky.yml @@ -0,0 +1,26 @@ +name: Cadence Integration Test +on: + pull_request: + push: + branches: + - 'main' + +jobs: + tests: + name: "Integration testing with sticky cache disabled" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + test-subset: + - "a-m" + - "n-z" + steps: + - uses: actions/checkout@v3 + - name: "Set up cadence environment" + run: docker compose -f docker-compose/ci-cadence-dependencies.yml up -d + - name: "Test against cadence" + run: make ci-cadence-integ-test-disable-sticky startsWith=${{ matrix['test-subset'] }} + - name: Dump docker logs + if: always() + uses: jwalton/gh-docker-logs@v2 diff --git a/.github/workflows/ci-temporal-integ-test-disable-sticky.yml b/.github/workflows/ci-temporal-integ-test-disable-sticky.yml new file mode 100644 index 00000000..ebe5bb32 --- /dev/null +++ b/.github/workflows/ci-temporal-integ-test-disable-sticky.yml @@ -0,0 +1,31 @@ +name: Temporal Integration Test +on: + pull_request: + push: + branches: + - 'main' + +jobs: + tests: + name: "Integration testing with sticky cache disabled" + runs-on: ubuntu-latest + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the + # added or changed files to the repository. + contents: write + strategy: + fail-fast: false + matrix: + test-subset: + - "a-m" + - "n-z" + + steps: + - uses: actions/checkout@v3 + - name: "Set up temporal environment" + run: docker compose -f docker-compose/ci-temporal-dependencies.yml up -d + - name: "Test against temporal" + run: make ci-temporal-integ-test-disable-sticky startsWith=${{ matrix['test-subset'] }} + - name: Dump docker logs + if: always() + uses: jwalton/gh-docker-logs@v2 \ No newline at end of file diff --git a/Makefile b/Makefile index b1ff37c5..cd385a2f 100644 --- a/Makefile +++ b/Makefile @@ -179,8 +179,14 @@ cadenceIntegTests: ci-cadence-integ-test: $Q go test -v ./integ -search=false -temporal=false -dependencyWaitSeconds=180 +ci-cadence-integ-test-disable-sticky: + $Q go test -v ./integ -run "(?i)^Test[${startsWith}]" -search=false -temporal=false -dependencyWaitSeconds=180 -disableStickyCache + ci-temporal-integ-test: - $Q go test -v ./integ -cover -coverprofile coverage.out -coverpkg ./service/... -search=false -cadence=false -dependencyWaitSeconds=60 + $Q go test -v ./integ -cover -coverprofile coverage.out -coverpkg ./service/... -search=false -cadence=false -dependencyWaitSeconds=60 + +ci-temporal-integ-test-disable-sticky: + $Q go test -v ./integ -run "(?i)^Test[${startsWith}]" -cover -coverprofile coverage.out -coverpkg ./service/... -search=false -cadence=false -dependencyWaitSeconds=60 -disableStickyCache ci-all-tests: # Fails CI when used with -coverprofile flag due to tests that panic; see https://go.dev/doc/build-cover#panicprof diff --git a/integ/flag.go b/integ/flag.go index 12079390..4e4dab88 100644 --- a/integ/flag.go +++ b/integ/flag.go @@ -19,3 +19,5 @@ var searchWaitTimeIntegTest = flag.Int("searchWaitMs", 2000, "the amount of time var temporalHostPort = flag.String("temporalHostPort", "", "temporal host port") var dependencyWaitSeconds = flag.Int("dependencyWaitSeconds", 60, "the number of seconds waiting for dependencies to be up(Cadence/Temporal)") + +var disableStickyCache = flag.Bool("disableStickyCache", false, "disable Temporal/Cadence sticky execution") diff --git a/integ/util.go b/integ/util.go index ba1238b4..e90d87ca 100644 --- a/integ/util.go +++ b/integ/util.go @@ -124,7 +124,11 @@ func doStartIwfServiceWithClient(config IwfServiceTestConfig) (uclient uclient.U // start iwf interpreter worker interpreter := temporal.NewInterpreterWorker(createTestConfig(config), temporalClient, service.TaskQueue, config.MemoEncryption, dataConverter, uclient) - interpreter.Start() + if *disableStickyCache { + interpreter.StartWithStickyCacheDisabledForTest() + } else { + interpreter.Start() + } return uclient, func() { iwfServer.Close() interpreter.Close() @@ -155,7 +159,11 @@ func doStartIwfServiceWithClient(config IwfServiceTestConfig) (uclient uclient.U // start iwf interpreter worker interpreter := cadence.NewInterpreterWorker(createTestConfig(config), serviceClient, iwf.DefaultCadenceDomain, service.TaskQueue, closeFunc, uclient) - interpreter.Start() + if *disableStickyCache { + interpreter.StartWithStickyCacheDisabledForTest() + } else { + interpreter.Start() + } return uclient, func() { iwfServer.Close() interpreter.Close() diff --git a/service/interpreter/cadence/worker.go b/service/interpreter/cadence/worker.go index dc22ad73..fcf4884f 100644 --- a/service/interpreter/cadence/worker.go +++ b/service/interpreter/cadence/worker.go @@ -1,6 +1,7 @@ package cadence import ( + "fmt" "github.com/indeedeng/iwf/config" "log" @@ -37,7 +38,15 @@ func (iw *InterpreterWorker) Close() { iw.worker.Stop() } +func (iw *InterpreterWorker) StartWithStickyCacheDisabledForTest() { + iw.start(true) +} + func (iw *InterpreterWorker) Start() { + iw.start(false) +} + +func (iw *InterpreterWorker) start(disableStickyCache bool) { config := env.GetSharedConfig() var options worker.Options @@ -55,6 +64,12 @@ func (iw *InterpreterWorker) Start() { options.MaxConcurrentDecisionTaskPollers = 10 } + // When DisableStickyCache is true it can harm performance; should not be used in production environment + if disableStickyCache { + options.DisableStickyExecution = true + fmt.Println("Cadence worker: Sticky cache disabled") + } + iw.worker = worker.New(iw.service, iw.domain, iw.tasklist, options) worker.EnableVerboseLogging(config.Interpreter.VerboseDebug) diff --git a/service/interpreter/temporal/worker.go b/service/interpreter/temporal/worker.go index 17bf0e62..ab2c78aa 100644 --- a/service/interpreter/temporal/worker.go +++ b/service/interpreter/temporal/worker.go @@ -1,6 +1,7 @@ package temporal import ( + "fmt" "github.com/indeedeng/iwf/config" "log" @@ -35,7 +36,15 @@ func (iw *InterpreterWorker) Close() { iw.worker.Stop() } +func (iw *InterpreterWorker) StartWithStickyCacheDisabledForTest() { + iw.start(true) +} + func (iw *InterpreterWorker) Start() { + iw.start(false) +} + +func (iw *InterpreterWorker) start(disableStickyCache bool) { config := env.GetSharedConfig() var options worker.Options @@ -55,6 +64,12 @@ func (iw *InterpreterWorker) Start() { options.MaxConcurrentWorkflowTaskPollers = 10 } + // When DisableStickyCache is true it can harm performance; should not be used in production environment + if disableStickyCache { + worker.SetStickyWorkflowCacheSize(0) + fmt.Println("Temporal worker: Sticky cache disabled") + } + iw.worker = worker.New(iw.temporalClient, iw.taskQueue, options) worker.EnableVerboseLogging(config.Interpreter.VerboseDebug)