Skip to content

Commit

Permalink
IWF-232: Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lwolczynski committed Nov 1, 2024
1 parent 7a888d6 commit fe750a4
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 23 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ci-cadence-integ-test-disable-sticky.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Cadence Integration Test
on:
pull_request:
push:
branches:
- 'main'

jobs:
tests:
name: "Integration testing"
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
8 changes: 1 addition & 7 deletions .github/workflows/ci-cadence-integ-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@ jobs:
tests:
name: "Integration testing"
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 startsWith=${{ matrix['test-subset'] }}
run: make ci-cadence-integ-test
- name: Dump docker logs
if: always()
uses: jwalton/gh-docker-logs@v2
31 changes: 31 additions & 0 deletions .github/workflows/ci-temporal-integ-test-disable-sticky.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Temporal Integration Test
on:
pull_request:
push:
branches:
- 'main'

jobs:
tests:
name: "Integration testing"
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
9 changes: 1 addition & 8 deletions .github/workflows/ci-temporal-integ-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,12 @@ jobs:
# 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 startsWith=${{ matrix['test-subset'] }}
run: make ci-temporal-integ-test
- name: Dump docker logs
if: always()
uses: jwalton/gh-docker-logs@v2
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,16 @@ cadenceIntegTests:
$Q go test -v ./integ -temporal=false

ci-cadence-integ-test:
ifeq (${startsWith},)
$Q go test -v ./integ -search=false -temporal=false -dependencyWaitSeconds=180 -disableStickyCache=true
else

ci-cadence-integ-test-disable-sticky:
$Q go test -v ./integ -run "(?i)^Test[${startsWith}]" -search=false -temporal=false -dependencyWaitSeconds=180 -disableStickyCache=true
endif

ci-temporal-integ-test:
ifeq (${startsWith},)
$Q go test -v ./integ -cover -coverprofile coverage.out -coverpkg ./service/... -search=false -cadence=false -dependencyWaitSeconds=60 -disableStickyCache=true
else

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=true
endif

ci-all-tests:
# Fails CI when used with -coverprofile flag due to tests that panic; see https://go.dev/doc/build-cover#panicprof
Expand Down
14 changes: 12 additions & 2 deletions integ/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,13 @@ func doStartIwfServiceWithClient(config IwfServiceTestConfig) (uclient uclient.U

// start iwf interpreter worker
interpreter := temporal.NewInterpreterWorker(createTestConfig(config), temporalClient, service.TaskQueue, config.MemoEncryption, dataConverter, uclient)
interpreter.StartWithOptions(temporal.StartOptions{DisableStickyCache: *disableStickyCache})

if *disableStickyCache {
interpreter.StartWithStickyCacheDisabledForTest()
} else {
interpreter.Start()
}

return uclient, func() {
iwfServer.Close()
interpreter.Close()
Expand Down Expand Up @@ -155,7 +161,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.StartWithOptions(cadence.StartOptions{DisableStickyCache: *disableStickyCache})
if *disableStickyCache {
interpreter.StartWithStickyCacheDisabledForTest()
} else {
interpreter.Start()
}
return uclient, func() {
iwfServer.Close()
interpreter.Close()
Expand Down
13 changes: 13 additions & 0 deletions service/interpreter/cadence/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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

Expand All @@ -55,6 +63,11 @@ 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
}

iw.worker = worker.New(iw.service, iw.domain, iw.tasklist, options)
worker.EnableVerboseLogging(config.Interpreter.VerboseDebug)

Expand Down
13 changes: 13 additions & 0 deletions service/interpreter/temporal/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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

Expand All @@ -55,6 +63,11 @@ 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)
}

iw.worker = worker.New(iw.temporalClient, iw.taskQueue, options)
worker.EnableVerboseLogging(config.Interpreter.VerboseDebug)

Expand Down

0 comments on commit fe750a4

Please sign in to comment.