From 78a0980850c72b44731369728f41cae9bbcc7081 Mon Sep 17 00:00:00 2001 From: "agent-platform-auto-pr[bot]" <153269286+agent-platform-auto-pr[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 13:27:36 +0000 Subject: [PATCH] [CWS] fix CWS feature e2e test (#24322) (#24336) Co-authored-by: paulcacheux --- test/new-e2e/tests/cws/api/ddsql.go | 25 ++++++++++++++++++++----- test/new-e2e/tests/cws/ec2_test.go | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/test/new-e2e/tests/cws/api/ddsql.go b/test/new-e2e/tests/cws/api/ddsql.go index 2aecb383a8e0d..2332841367ab2 100644 --- a/test/new-e2e/tests/cws/api/ddsql.go +++ b/test/new-e2e/tests/cws/api/ddsql.go @@ -13,13 +13,23 @@ import ( "time" ) +// JSONAPIPayload is a struct that represents the body of a JSON API request +type JSONAPIPayload[Attr any] struct { + Data JSONAPIPayloadData[Attr] `json:"data"` +} + +// JSONAPIPayloadData is a struct that represents the data field of a JSON API request +type JSONAPIPayloadData[Attr any] struct { + Type string `json:"type"` + Attribute Attr `json:"attributes"` +} + // DDSQLTableQueryParams is a struct that represents a DDSQL table query type DDSQLTableQueryParams struct { DefaultStart int `json:"default_start"` DefaultEnd int `json:"default_end"` DefaultInterval int `json:"default_interval"` Query string `json:"query"` - Source string `json:"source"` } // DDSQLTableResponse is a struct that represents a DDSQL table response @@ -65,14 +75,19 @@ func NewDDSQLClient(apiKey, appKey string) *DDSQLClient { func (c *DDSQLClient) Do(query string) (*DDSQLTableResponse, error) { now := time.Now() params := DDSQLTableQueryParams{ - DefaultStart: int(now.Add(-10 * time.Minute).Unix()), - DefaultEnd: int(now.Unix()), + DefaultStart: int(now.Add(-1 * time.Hour).UnixMilli()), + DefaultEnd: int(now.UnixMilli()), DefaultInterval: 20000, Query: query, - Source: "inventories", + } + payload := JSONAPIPayload[DDSQLTableQueryParams]{ + Data: JSONAPIPayloadData[DDSQLTableQueryParams]{ + Type: "ddsql_table_request", + Attribute: params, + }, } - reqData, err := json.Marshal(params) + reqData, err := json.Marshal(payload) if err != nil { return nil, err } diff --git a/test/new-e2e/tests/cws/ec2_test.go b/test/new-e2e/tests/cws/ec2_test.go index 5351ef79a36f4..c9351721d84ca 100644 --- a/test/new-e2e/tests/cws/ec2_test.go +++ b/test/new-e2e/tests/cws/ec2_test.go @@ -213,7 +213,7 @@ func (a *agentSuite) Test01FeatureCWSEnabled() { return } } - }, 16*time.Minute, 2*time.Minute, "cws activation test timed out for host %s", a.Env().Agent.Client.Hostname()) + }, 20*time.Minute, 30*time.Second, "cws activation test timed out for host %s", a.Env().Agent.Client.Hostname()) } func (a *agentSuite) waitAgentLogs(agentName string, pattern string) error {