Skip to content

Commit

Permalink
tests (#636)
Browse files Browse the repository at this point in the history
CTS: Updates traces v2 tests

What this PR does / why we need it
Fixed a test and added additional marker one.

Reviewed-by: Anton Sidelnikov
  • Loading branch information
artem-lifshits authored Mar 21, 2024
1 parent 98ec17f commit d52d70e
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions acceptance/openstack/cts/v2/traces_test.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
package v2

import (
"strconv"
"testing"
"time"

"github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients"
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/openstack/cts"
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools"
"github.com/opentelekomcloud/gophertelekomcloud/openstack/cts/v2/traces"
th "github.com/opentelekomcloud/gophertelekomcloud/testhelper"
)

func TestTraces(t *testing.T) {
bucketName := cts.CreateOBSBucket(t)
t.Cleanup(func() {
cts.DeleteOBSBucket(t, bucketName)
})

cv2, err := clients.NewCTSV2Client()
th.AssertNoErr(t, err)

list, err := traces.List(cv2, "system", traces.ListTracesOpts{})
th.AssertNoErr(t, err)
now := time.Now().UTC()
toMilliseconds := now.UnixNano() / int64(time.Millisecond)

oneDay := now.Add(-time.Hour * 24 * 1)
fromMilliseconds := oneDay.UnixNano() / int64(time.Millisecond)

listOpts := traces.ListTracesOpts{
To: strconv.FormatInt(toMilliseconds, 10),
From: strconv.FormatInt(fromMilliseconds, 10),
Limit: "20",
}

var listResp traces.ListTracesResponse

for i := 0; i < 2; i++ {
list, err := traces.List(cv2, "system", listOpts)
th.AssertNoErr(t, err)
tools.PrintResource(t, list)

listOpts.Next = list.MetaData.Marker
listResp = *list
}

t.Logf("Number of Tracker Traces: %d", len(list.Traces))
th.AssertEquals(t, true, len(list.Traces) > 0)
tools.PrintResource(t, list)
t.Logf("Number of Tracker Traces in latest API call : %d", len(listResp.Traces))
th.AssertEquals(t, true, len(listResp.Traces) > 0)
}

0 comments on commit d52d70e

Please sign in to comment.