Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions test/integration/api/allocation/allocation_smoke_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package allocation

import (
"testing"

"github.com/opencost/opencost-integration-tests/pkg/api"
"github.com/opencost/opencost-integration-tests/pkg/env"
)

func TestAllocationSmoke(t *testing.T) {

apiClient := api.NewAPI()

// logging incase we can trace potential env issues with go test -v
Comment thread
Manas23601 marked this conversation as resolved.
t.Logf("Smoke target (OPENCOST_URL or default): %s", env.GetDefaultURL())

testCases := []struct {
name string
window string
}{
{
name: "SimpleValidQuery_1d",
window: "1d",
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {

response, err := apiClient.GetAllocation(api.AllocationRequest{
Window: tc.window,
})

if err != nil {
t.Fatalf("Error while calling Allocation API %v", err)
}

if response.Code != 200 {
t.Errorf("/allocation returned non-200 code: %d", response.Code)
}

itemCount := 0
for _, step := range response.Data {
itemCount += len(step)
}
t.Logf("/allocation OK: code=%d, steps=%d, allocation items=%d",
response.Code, len(response.Data), itemCount)
})
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package allocation

import (
"testing"

"github.com/opencost/opencost-integration-tests/pkg/api"
"github.com/opencost/opencost-integration-tests/pkg/env"
)

func TestAllocationSummarySmoke(t *testing.T) {

apiClient := api.NewAPI()

// logging incase we can trace potential env issues with go test -v
t.Logf("Smoke target (OPENCOST_URL or default): %s", env.GetDefaultURL())

testCases := []struct {
name string
window string
}{
{
name: "SimpleValidQuery_1d",
window: "1d",
},
}

for _, tc := range testCases {

t.Run(tc.name, func(t *testing.T) {

ar := api.AllocationRequest{
Window: tc.window,
}
response, err := apiClient.GetAllocationSummary(ar)
if err != nil {
t.Fatalf("/allocation/summary window=%s request failed: %v", ar.Window, err)
}

if response.Code != 200 {
t.Errorf("/allocation/summary window=%s returned non-200 code: %d", ar.Window, response.Code)
}

t.Logf("/allocation/summary: code=%d, allocation sets returned: %d",
response.Code, len(response.Data.Sets))
})
}
}
12 changes: 11 additions & 1 deletion test/integration/api/allocation/test.bats
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
setup() {
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
cd $DIR
cd "$DIR"
}

teardown() {
: # nothing to tear down
}

@test "allocation: smoke test allocation" {
#60sec cap bc SDK http.Get has no timeout, avoids go test's default 10 min
go test -timeout 60s allocation_smoke_test.go
}

@test "allocation: smoke test allocation summary" {
go test -timeout 60s allocation_summary_smoke_test.go
}

@test "allocation: controller kind consistency" {
go test allocation_controller_consistency_test.go
}
Expand Down
50 changes: 50 additions & 0 deletions test/integration/api/asset/assets_smoke_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package assets

import (
"testing"

"github.com/opencost/opencost-integration-tests/pkg/api"
"github.com/opencost/opencost-integration-tests/pkg/env"
)

func TestAssetsSmoke(t *testing.T) {

apiClient := api.NewAPI()

// logging incase we can trace potential env issues with go test -v
t.Logf("Assets Smoke target (OPENCOST_URL or default): %s", env.GetDefaultURL())

testCases := []struct {
name string
window string
}{
{
name: "ValidQueryTest",
window: "1d",
},
}

for _, tc := range testCases {

t.Run(tc.name, func(t *testing.T) {

ar := api.AssetsRequest{
Window: tc.window,
}
response, err := apiClient.GetAssets(ar)
if err != nil {
t.Fatalf("/assets?window=%s request failed: %v", ar.Window, err)
}

if response.Code != 200 {
t.Errorf("/assets?window=%s returned non-200 code: %d", ar.Window, response.Code)
}

if len(response.Data) == 0 {
t.Logf("warning: /assets returned 200 but zero assets")
}

t.Logf("/assets: code=%d, assets returned: %d", response.Code, len(response.Data))
})
}
}
7 changes: 6 additions & 1 deletion test/integration/api/asset/test.bats
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
setup() {
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
cd $DIR
cd "$DIR"
}

teardown() {
: # nothing to tear down
}

@test "asset: Smoke Test" {
#60sec cap bc SDK http.Get has no timeout, avoids go test's default 10 min
go test -timeout 60s assets_smoke_test.go
Comment thread
peatey marked this conversation as resolved.
Comment on lines +11 to +12
}

@test "asset: Node Labels" {
go test node_labels_test.go
}
Expand Down
Loading