Skip to content

Commit

Permalink
feat(cws): Sync cws test from main
Browse files Browse the repository at this point in the history
  • Loading branch information
chouetz committed Nov 20, 2024
1 parent 121cc60 commit c3442f5
Show file tree
Hide file tree
Showing 14 changed files with 829 additions and 391 deletions.
6 changes: 5 additions & 1 deletion test/new-e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/DataDog/datadog-agent/pkg/version v0.53.0
github.com/DataDog/datadog-agent/test/fakeintake v0.53.0
github.com/DataDog/datadog-api-client-go v1.16.0
github.com/DataDog/datadog-api-client-go/v2 v2.19.0
github.com/DataDog/datadog-api-client-go/v2 v2.27.0
// Are you bumping github.com/DataDog/test-infra-definitions ?
// You should bump `TEST_INFRA_DEFINITIONS_BUILDIMAGES` in `.gitlab-ci.yml`
// `TEST_INFRA_DEFINITIONS_BUILDIMAGES` matches the commit sha in the module version
Expand Down Expand Up @@ -242,9 +242,11 @@ require (
require (
github.com/DataDog/datadog-agent/pkg/util/optional v0.55.2
github.com/DataDog/datadog-agent/pkg/util/scrubber v0.58.2
github.com/mitchellh/mapstructure v1.5.0
github.com/pulumi/pulumi-aws/sdk/v6 v6.56.1
github.com/pulumi/pulumi-awsx/sdk/v2 v2.16.1
github.com/pulumi/pulumi-kubernetes/sdk/v4 v4.17.1
github.com/xeipuuv/gojsonschema v1.2.0
)

require (
Expand All @@ -260,4 +262,6 @@ require (
github.com/pulumi/pulumi-eks/sdk/v2 v2.7.8 // indirect
github.com/pulumi/pulumi-gcp/sdk/v6 v6.67.1 // indirect
github.com/pulumi/pulumi-gcp/sdk/v7 v7.38.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
)
12 changes: 10 additions & 2 deletions test/new-e2e/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

209 changes: 0 additions & 209 deletions test/new-e2e/tests/cws/api/api.go

This file was deleted.

54 changes: 54 additions & 0 deletions test/new-e2e/tests/cws/api/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

// Package api provides test helpers to interact with the Datadog API
package api

import (
"context"
"net/http"

"github.com/DataDog/datadog-api-client-go/v2/api/datadog"

"github.com/DataDog/datadog-agent/test/new-e2e/pkg/runner"
"github.com/DataDog/datadog-agent/test/new-e2e/pkg/runner/parameters"
)

// Client represents the datadog API context
type Client struct {
api *datadog.APIClient
ctx context.Context
http http.Client
apiKey string
appKey string
}

// NewClient initialise a client with the API and APP keys
func NewClient() *Client {
apiKey, _ := runner.GetProfile().SecretStore().Get(parameters.APIKey)
appKey, _ := runner.GetProfile().SecretStore().Get(parameters.APPKey)
ctx := context.WithValue(
context.Background(),
datadog.ContextAPIKeys,
map[string]datadog.APIKey{
"apiKeyAuth": {
Key: apiKey,
},
"appKeyAuth": {
Key: appKey,
},
},
)

cfg := datadog.NewConfiguration()

return &Client{
api: datadog.NewAPIClient(cfg),
ctx: ctx,
http: http.Client{},
apiKey: apiKey,
appKey: appKey,
}
}
20 changes: 2 additions & 18 deletions test/new-e2e/tests/cws/api/ddsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,8 @@ type Column struct {
Values []interface{} `json:"values"`
}

// DDSQLClient is a struct that represents a DDSQL client
type DDSQLClient struct {
http http.Client
apiKey string
appKey string
}

// NewDDSQLClient returns a new DDSQL client
func NewDDSQLClient(apiKey, appKey string) *DDSQLClient {
return &DDSQLClient{
http: http.Client{},
apiKey: apiKey,
appKey: appKey,
}
}

// Do executes a DDSQL query, returning a DDSQL table response
func (c *DDSQLClient) Do(query string) (*DDSQLTableResponse, error) {
// TableQuery executes a DDSQL query, returning a DDSQL table response
func (c *Client) TableQuery(query string) (*DDSQLTableResponse, error) {
now := time.Now()
params := DDSQLTableQueryParams{
DefaultStart: int(now.Add(-1 * time.Hour).UnixMilli()),
Expand Down
Loading

0 comments on commit c3442f5

Please sign in to comment.