Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Test] Task service api test fix review#6830

Merged
popojk merged 5 commits intoflyteorg:v2from
machichima:task-service-api-test-fix-review
Jan 6, 2026
Merged

[Test] Task service api test fix review#6830
popojk merged 5 commits intoflyteorg:v2from
machichima:task-service-api-test-fix-review

Conversation

@machichima
Copy link
Member

@machichima machichima commented Dec 30, 2025

Tracking issue

follow-up: #6823

Why are the changes needed?

Fix remaining reviews in #6823

What changes were proposed in this pull request?

  • Fast fail is api test server failed to start
  • Improve clean-up logic
  • Remove redundant code

How was this patch tested?

  • API test
❯ make api-test
Makefile:58: warning: overriding commands for target `test'
../go.Makefile:96: warning: ignoring old commands for target `test'
Makefile:122: warning: overriding commands for target `clean'
../go.Makefile:132: warning: ignoring old commands for target `clean'
Running API integration tests...
# github.com/flyteorg/flyte/v2/runs/test/api.test
ld: warning: '/private/var/folders/27/52rf9wx95tvfqzcw0t_x7qqc0000gn/T/go-link-2876845023/000023.o' has malformed LC_DYSYMTAB, expected 98 undefined symbols to start at index 1626, found 95 undefined symbols starting at index 1626
time="2025-12-30T16:41:17+08:00" level=info msg="Set connection pool values to [{MaxOpenConnections:0 OpenConnections:0 InUse:0 Idle:0 WaitCount:0 WaitDuration:0s MaxIdleClosed:1 MaxIdleTimeClosed:0 MaxLifetimeClosed:0}]"
2025/12/30 16:41:17 Database initialized
time="2025-12-30T16:41:17+08:00" level=info msg="Database migrations completed successfully (recreated actions table)"
2025/12/30 16:41:17 Database migrations completed
2025/12/30 16:41:17 Test server starting on http://localhost:8091
2025/12/30 16:41:17 Test server is ready
=== RUN   TestDeployTask
time="2025-12-30T16:41:17+08:00" level=info msg="Created/Updated task: test-org/test-project/test-domain/test-task version 1767084077691962000"
    task_service_test.go:59: Task deployed successfully: org:"test-org" project:"test-project" domain:"test-domain" name:"test-task" version:"1767084077691962000"
    task_service_test.go:74: Task details retrieved successfully: task_id:{org:"test-org" project:"test-project" domain:"test-domain" name:"test-task" version:"1767084077691962000"} metadata:{short_name:"test-task" deployed_at:{seconds:-62135596800}} spec:{task_template:{type:"container" container:{image:"alpine:latest" args:"echo" args:"hello"}}}
    task_service_test.go:24: Test database cleaned up
--- PASS: TestDeployTask (0.01s)
PASS
2025/12/30 16:41:17 Test server stopped
ok      github.com/flyteorg/flyte/v2/runs/test/api      1.050s

Labels

Please add one or more of the following labels to categorize your PR:

  • added: For new features.
  • changed: For changes in existing functionality.
  • deprecated: For soon-to-be-removed features.
  • removed: For features being removed.
  • fixed: For any bug fixed.
  • security: In case of vulnerabilities

This is important to improve the readability of release notes.

Setup process

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

@machichima
Copy link
Member Author

@yuhuan130 PTAL

@machichima
Copy link
Member Author

Also cc @popojk

Copy link
Contributor

@popojk popojk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@machichima Looks great thanks, left few comments

cc @yuhuan130

if err != nil {
log.Fatalf("Failed to initialize database: %v", err)
log.Printf("Failed to initialize database: %v", err)
exitCode = 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm wrong. I think log.Fatalf already returned exitCode 1? Golang doc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! This is why we use Printf here. While Fatalf will also call os.Exit(1), it will not get into the defer block for clean-up

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, thank you

if err := migrations.RunMigrations(testDB); err != nil {
log.Fatalf("Failed to run migrations: %v", err)
log.Printf("Failed to run migrations: %v", err)
exitCode = 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment on lines +126 to +127
exitCode = 1
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
exitCode = 1
return
os.Exit(1)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same reason as above. If we use os.Exit(1) here, the defer block will not be called

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gocha, thanks!

Comment on lines +131 to +132
exitCode = 1
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@popojk popojk merged commit ae10f2b into flyteorg:v2 Jan 6, 2026
4 checks passed
EngHabu pushed a commit that referenced this pull request Feb 26, 2026
* refactor: remove unused function

Signed-off-by: machichima <[email protected]>

* feat: fail directly if test server failed to start

Signed-off-by: machichima <[email protected]>

* refactor: fix typo

Signed-off-by: machichima <[email protected]>

* test: loop through model slice for cleanup

Signed-off-by: machichima <[email protected]>

* test: clean up to defer block

Signed-off-by: machichima <[email protected]>

---------

Signed-off-by: machichima <[email protected]>
Signed-off-by: Haytham Abuelfutuh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants