Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): refactor runner channels into abstract queues #2971

Merged
merged 45 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5e12879
replace pg driver
schoren Jul 18, 2023
e435f93
fix test
schoren Jul 18, 2023
74cc661
--wip-- [skip ci]
schoren Jul 18, 2023
63b152f
WIP: add pipeline structure
mathnogueira Jul 19, 2023
98ec189
update assertion runner
schoren Jul 19, 2023
cca4bdf
implement linter runner
schoren Jul 19, 2023
ed4d1cb
WIP: convert other workers
mathnogueira Jul 19, 2023
d571b57
wip
mathnogueira Jul 19, 2023
86440e8
implement runner
schoren Jul 20, 2023
d4baa2a
fix rerun
schoren Jul 20, 2023
5893a9e
cleanup
schoren Jul 21, 2023
a88c4b2
fix test
schoren Jul 21, 2023
e3cea98
fix config test
schoren Jul 21, 2023
0b5fa81
clenaup test
schoren Jul 24, 2023
2d80e77
--wip-- [skip ci]
schoren Jul 24, 2023
c012f93
fix transactions
schoren Jul 24, 2023
b55841d
fix poller test
schoren Jul 24, 2023
10ec3ab
fixes
schoren Jul 24, 2023
ab31f99
fix queries
schoren Jul 24, 2023
e52736f
setup context propagation
schoren Jul 24, 2023
b0b17fc
fix tests
schoren Jul 25, 2023
93bfd02
fix: fixes header propagation
mathnogueira Jul 25, 2023
8cbbf64
fix
schoren Jul 25, 2023
782e0f2
--wip-- [skip ci]
schoren Jul 26, 2023
25d62c7
--wip-- [skip ci]
schoren Jul 26, 2023
945b5f9
remove race condiion
schoren Jul 26, 2023
6d93f17
fix: weird polling bug
mathnogueira Jul 26, 2023
15d7823
--wip-- [skip ci]
schoren Jul 26, 2023
63050c6
fix test
schoren Jul 26, 2023
211deba
update test
schoren Jul 26, 2023
ceda8eb
implement stop
schoren Jul 26, 2023
f8cc155
remove debug logs
schoren Jul 26, 2023
c9caa5b
remove debug logs
schoren Jul 26, 2023
84430ea
rollback change
schoren Jul 27, 2023
0dd4ecd
revert change
schoren Jul 27, 2023
a3b7acd
organize code
schoren Jul 27, 2023
5dc4e28
server/openapi
schoren Jul 27, 2023
65ad8f8
fix
schoren Jul 27, 2023
7269452
fix pp
schoren Jul 27, 2023
a81e761
Update server/pkg/id/generator.go
schoren Jul 27, 2023
66add09
name magic constant
schoren Jul 27, 2023
796aeec
handle empty queues
schoren Jul 27, 2023
8a20d1d
name magic constant
schoren Jul 27, 2023
f36fbbf
fix rerun state
schoren Jul 27, 2023
d910771
fix
schoren Jul 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
153 changes: 12 additions & 141 deletions go.work.sum

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions local-config/tracetest.provision.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ spec:
periodic:
timeout: 30s
retryDelay: 1s
selectorMatchRetries: 3
---
type: TestRunner
spec:
Expand Down
4 changes: 4 additions & 0 deletions server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ GO_LDFLAGS := $(shell echo \
-X "'github.com/kubeshop/tracetest/server/analytics.FrontendKey=$(ANALYTICS_FE_KEY)'" \
| sed 's/ / /g')

.PHONY: help
help: Makefile ## show list of commands
@echo "Choose a command run:"
@echo ""
Expand All @@ -18,12 +19,15 @@ init-submodule:
git submodule init
git submodule update

.PHONY: test
test: ## run go tests for this application
go test -timeout 150s -coverprofile=coverage.out ./...

.PHONY: vet
vet: ## run vet tool to analyze the code for suspicious, abnormal, or useless code
go vet -structtag=false ./...

.PHONY: run
run: ## run server locally
go run -ldflags="$(GO_LDFLAGS)" main.go serve

Expand Down
102 changes: 56 additions & 46 deletions server/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,44 +208,33 @@ func (app *App) Start(opts ...appOption) error {
eventEmitter := executor.NewEventEmitter(testDB, subscriptionManager)
registerOtlpServer(app, runRepo, eventEmitter, dataStoreRepo)

rf := newRunnerFacades(
testPipeline := buildTestPipeline(
pollingProfileRepo,
dataStoreRepo,
linterRepo,
testRunnerRepo,
testDB,
testRepo,
runRepo,
transactionRunRepository,
applicationTracer,
tracer,
subscriptionManager,
triggerRegistry,
)

// worker count. should be configurable
rf.tracePoller.Start(5)
rf.runner.Start(5)
rf.runner.Start(5)
rf.transactionRunner.Start(5)
rf.assertionRunner.Start(5)
rf.linterRunner.Start(5)

app.registerStopFn(func() {
fmt.Println("stopping tracePoller")
rf.tracePoller.Stop()
})
app.registerStopFn(func() {
fmt.Println("stopping runner")
rf.runner.Stop()
})
testPipeline.Start()
app.registerStopFn(func() {
fmt.Println("stopping transactionRunner")
rf.transactionRunner.Stop()
testPipeline.Stop()
})

transactionPipeline := buildTransactionPipeline(
transactionsRepository,
transactionRunRepository,
testPipeline,
subscriptionManager,
)

transactionPipeline.Start()
app.registerStopFn(func() {
fmt.Println("stopping assertionRunner")
rf.assertionRunner.Stop()
transactionPipeline.Stop()
})

err = analytics.SendEvent("Server Started", "beacon", "", nil)
Expand All @@ -256,14 +245,17 @@ func (app *App) Start(opts ...appOption) error {
provisioner := provisioning.New()

router, mappers := controller(app.cfg,
tracer,

testPipeline,
transactionPipeline,

testDB,
transactionsRepository,
transactionRunRepository,
testRepo,
runRepo,
tracer,
environmentRepo,
rf,
)
registerWSHandler(router, mappers, subscriptionManager)

Expand Down Expand Up @@ -314,7 +306,7 @@ func (app *App) Start(opts ...appOption) error {
var (
matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)")
matchAllCap = regexp.MustCompile("([a-z0-9])([A-Z])")
matchResourceName = regexp.MustCompile("(\\w)(\\.)(\\w)")
matchResourceName = regexp.MustCompile(`(\w)(\.)(\w)`)
)

func toWords(str string) string {
Expand Down Expand Up @@ -506,27 +498,36 @@ func registerWSHandler(router *mux.Router, mappers mappings.Mappings, subscripti

func controller(
cfg httpServerConfig,
testDB model.Repository,
transactionRepository *transaction.Repository,
transactionRunRepository *transaction.RunRepository,
testRepository test.Repository,
runRepository test.RunRepository,

tracer trace.Tracer,

testRunner *executor.TestPipeline,
transactionRunner *executor.TransactionPipeline,

testRunEvents model.TestRunEventRepository,
transactionRepo *transaction.Repository,
transactionRunRepo *transaction.RunRepository,
testRepo test.Repository,
testRunRepo test.RunRepository,
environmentRepo *environment.Repository,
rf *runnerFacade,
) (*mux.Router, mappings.Mappings) {
mappers := mappings.New(tracesConversionConfig(), comparator.DefaultRegistry())

router := openapi.NewRouter(httpRouter(
cfg,
testDB,
transactionRepository,
transactionRunRepository,
testRepository,
runRepository,

tracer,

testRunner,
transactionRunner,

testRunEvents,
transactionRepo,
transactionRunRepo,
testRepo,
testRunRepo,
environmentRepo,
rf,

mappers,
))

Expand All @@ -535,27 +536,36 @@ func controller(

func httpRouter(
cfg httpServerConfig,
testDB model.Repository,

tracer trace.Tracer,

testRunner *executor.TestPipeline,
transactionRunner *executor.TransactionPipeline,

testRunEvents model.TestRunEventRepository,
transactionRepo *transaction.Repository,
transactionRunRepo *transaction.RunRepository,
testRepo test.Repository,
testRunRepo test.RunRepository,
tracer trace.Tracer,
environmentRepo *environment.Repository,
rf *runnerFacade,

mappers mappings.Mappings,
) openapi.Router {
controller := httpServer.NewController(
testDB,
tracer,

testRunner,
transactionRunner,

testRunEvents,
transactionRepo,
transactionRunRepo,
testRepo,
testRunRepo,
environmentRepo,

tracedb.Factory(testRunRepo),
rf,
mappers,
environmentRepo,
tracer,
Version,
)
apiApiController := openapi.NewApiApiController(controller)
Expand Down
140 changes: 0 additions & 140 deletions server/app/facade.go

This file was deleted.