<#6833 Add test for TaskService.ListVersions and t...
# flyte-github
a
#6833 Add test for TaskService.ListVersions and test script Pull request opened by kevinliao852 ## Tracking issue Closes #6822 ## Why are the changes needed? • Integration Test • Added an integration test in
test/api/task_service_test.go
that deploys a task and verifies the versions returned by the
ListVersions
API. • This ensures the API correctly reports all available task versions after deployment. • The test cleans up relevant database state before execution to avoid interference from previous incomplete or failed API tests. • Test Script • Added
test/scripts/list_versions.sh
to allow for manual testing of the
ListVersions
API endpoint using
buf curl
. ## What changes were proposed in this pull request? This PR adds coverage for the
TaskService.ListVersions
API by introducing an integration test and a lightweight test script for manual verification. ## How was this patch tested? test-api
Copy code
➜  runs git:(list-version-tests) make api-test         
Makefile:58: warning: overriding recipe for target 'test'
../go.Makefile:96: warning: ignoring old recipe for target 'test'
Makefile:122: warning: overriding recipe for target 'clean'
../go.Makefile:132: warning: ignoring old recipe for target 'clean'
Running API integration tests...
time="2025-12-31T12:09:30+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/31 12:09:30 Database initialized
time="2025-12-31T12:09:30+08:00" level=info msg="Database migrations completed successfully (recreated actions table)"
2025/12/31 12:09:30 Database migrations completed
2025/12/31 12:09:30 Test server starting on <http://localhost:8091>
2025/12/31 12:09:30 Test server is ready
=== RUN   TestDeployTask
    task_service_test.go:24: Test database cleaned up
time="2025-12-31T12:09:30+08:00" level=info msg="Created/Updated task: test-org/test-project/test-domain/test-task version 1767154170814391212"
    task_service_test.go:63: Task deployed successfully: org:"test-org" project:"test-project" domain:"test-domain" name:"test-task" version:"1767154170814391212"
    task_service_test.go:78: Task details retrieved successfully: task_id:{org:"test-org" project:"test-project" domain:"test-domain" name:"test-task" version:"1767154170814391212"} metadata:{short_name:"test-task" deployed_at:{seconds:1767154170 nanos:822678811}} spec:{task_template:{type:"container" container:{image:"alpine:latest" args:"echo" args:"hello"}}}
    task_service_test.go:95: Task versions retrieved successfully: [version:"1767154170814391212" deployed_at:{seconds:1767154170 nanos:822678811}]
    task_service_test.go:28: Test database cleaned up
--- PASS: TestDeployTask (0.04s)
PASS
2025/12/31 12:09:30 Test server stopped
ok      <http://github.com/flyteorg/flyte/v2/runs/test/api|github.com/flyteorg/flyte/v2/runs/test/api>      1.138s
test script
Copy code
➜  flyte git:(list-version-tests) ✗ ./runs/test/scripts/list_versions.sh
{
  "versions": [
    {
      "version": "1",
      "deployedAt": "2025-12-31T03:07:41.315159253Z"
    }
  ]
}
### 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 flyteorg/flyte