Skip to content

Commit

Permalink
[CWS] fix CWS feature e2e test (#24322) (#24336)
Browse files Browse the repository at this point in the history
Co-authored-by: paulcacheux <[email protected]>
  • Loading branch information
1 parent d6e7dfa commit 78a0980
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
25 changes: 20 additions & 5 deletions test/new-e2e/tests/cws/api/ddsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion test/new-e2e/tests/cws/ec2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 78a0980

Please sign in to comment.