Skip to content

Add smoke tests for allocation, allocation summary, and assets endpoints#97

Open
e-300 wants to merge 3 commits into
opencost:mainfrom
e-300:add-smoke-tests
Open

Add smoke tests for allocation, allocation summary, and assets endpoints#97
e-300 wants to merge 3 commits into
opencost:mainfrom
e-300:add-smoke-tests

Conversation

@e-300

@e-300 e-300 commented Jun 11, 2026

Copy link
Copy Markdown
Member

Description

Adds smoke tests for the /allocation, /allocation/summary, and /assets endpoints.
Each test issues a request with window=1d and verifies the endpoint responds with a 200 status code, providing a fast first-line check that the API is alive before the deeper integration tests run.

Cloud cost endpoint smoke coverage was intentionally left out of this PR: implementing it would require adding a cloud cost client to pkg/api first, I've left it for a follow up PR to keep this one focused, but happy to include it here if reviewers prefer.

Changes

  • Added allocation_smoke_test.go and allocation_summary_smoke_test.go under test/integration/api/allocation/
  • Added assets_smoke_test.go under test/integration/api/asset/
  • Updated test/integration/api/allocation/test.bats and test/integration/api/asset/test.bats to register the new smoke tests, with a -timeout 60s cap on each go test invocation (the SDK's HTTP client has no timeout, so this prevents a hung endpoint from stalling until go test's 10-minute default)

Related Issues

#74

Testing

Ran the new smoke tests against a local k3d cluster running OpenCost and the demo cluster; all pass via both go test -run Smoke ./... and the bats suite.

@e-300
e-300 requested a review from a team as a code owner June 11, 2026 19:23
Copilot AI review requested due to automatic review settings June 11, 2026 19:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adds smoke tests for the allocation and asset API endpoints, along with a minor shell quoting fix in the bats setup functions.

Changes:

  • Added smoke tests for /allocation, /allocation/summary, and /assets endpoints that verify HTTP 200 responses with a 60-second timeout.
  • Quoted $DIR in the cd command within the bats setup() functions to handle paths with spaces.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/integration/api/asset/test.bats Added smoke test entry and quoted $DIR in setup
test/integration/api/asset/assets_smoke_test.go New Go test verifying /assets?window=1d returns 200
test/integration/api/allocation/test.bats Added smoke test entries and quoted $DIR in setup
test/integration/api/allocation/allocation_smoke_test.go New Go test verifying /allocation returns 200
test/integration/api/allocation/allocation_summary_smoke_test.go New Go test verifying /allocation/summary returns 200

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

)

func TestAllocationSmoke(t *testing.T) {
apiObj := api.NewAPI()

apiClient := api.NewAPI()

// logging incase we can trace potential env issues with go test -v
func TestAllocationSmoke(t *testing.T) {
apiObj := api.NewAPI()

// logging incase we can trace potential env issues with go test -v
Comment thread test/integration/api/allocation/allocation_summary_smoke_test.go
Comment thread test/integration/api/asset/test.bats
Signed-off-by: Ebad Shahid <ebad@ebad.dev>
window string
}{
{
name: "ValidQueryTest",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit - make naming consistent with alloc test

Copilot AI review requested due to automatic review settings June 12, 2026 17:58
@e-300
e-300 force-pushed the add-smoke-tests branch from 0e76ee8 to ef45083 Compare June 12, 2026 17:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

)

func TestAllocationSmoke(t *testing.T) {
apiObj := api.NewAPI()
func TestAllocationSmoke(t *testing.T) {
apiObj := api.NewAPI()

// logging incase we can trace potential env issues with go test -v

apiClient := api.NewAPI()

// logging incase we can trace potential env issues with go test -v

apiClient := api.NewAPI()

// logging incase we can trace potential env issues with go test -v
This reverts commit 8946b9e.

Signed-off-by: Ebad Shahid <ebad@ebad.dev>
Copilot AI review requested due to automatic review settings June 15, 2026 16:48
@e-300
e-300 force-pushed the add-smoke-tests branch from 2681cea to 7d7efa8 Compare June 15, 2026 16:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.


apiClient := api.NewAPI()

// logging incase we can trace potential env issues with go test -v

apiClient := api.NewAPI()

// logging incase we can trace potential env issues with go test -v

apiClient := api.NewAPI()

// logging incase we can trace potential env issues with go test -v
Comment on lines +11 to +12
#60sec cap bc SDK http.Get has no timeout, avoids go test's default 10 min
go test -timeout 60s assets_smoke_test.go
}

@test "allocation: smoke test allocation" {
#60sec cap bc SDK http.Get has no timeout, avoids go test's default 10 min
@e-300 e-300 closed this Jun 15, 2026
@e-300 e-300 reopened this Jun 15, 2026
@e-300 e-300 closed this Jun 17, 2026
@e-300 e-300 reopened this Jun 17, 2026
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.

4 participants