Merged in feature/parallellogqueries (pull request #132)
Testing Tweaks * parallel * slowestquery * split * cleanup * health * dynamiccores * go * profile * timeout * commitmychanges * taskfile * sqlcheckstart * client * cost * ctxtimeout
This commit is contained in:
@@ -4,11 +4,14 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
queryapi "queryorchestration/pkg/queryAPI"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/oapi-codegen/runtime/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -38,7 +41,7 @@ func WaitForClientStatus(t testing.TB, ctx context.Context, service queryapi.Cli
|
||||
t.Helper()
|
||||
|
||||
timeout := time.After(60 * time.Second)
|
||||
ticker := time.NewTicker(500 * time.Millisecond)
|
||||
ticker := time.NewTicker(100 * time.Millisecond)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
@@ -54,6 +57,7 @@ func WaitForClientStatus(t testing.TB, ctx context.Context, service queryapi.Cli
|
||||
|
||||
if jRes.JSON200.Status == status {
|
||||
assert.Equal(t, status, jRes.JSON200.Status)
|
||||
slog.Info("returned client status", "status", jRes.JSON200.Status)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -61,3 +65,33 @@ func WaitForClientStatus(t testing.TB, ctx context.Context, service queryapi.Cli
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func CreateDependentQueries(t testing.TB, client *queryapi.ClientWithResponses, clientId string) (uuid.UUID, uuid.UUID) {
|
||||
contextQueryRes, err := client.CreateQueryWithResponse(t.Context(), queryapi.QueryCreate{
|
||||
Type: queryapi.CONTEXTFULL,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusCreated, contextQueryRes.StatusCode())
|
||||
jcfg := `{"path":"keyone"}`
|
||||
jsonQueryRes, err := client.CreateQueryWithResponse(t.Context(), queryapi.QueryCreate{
|
||||
Type: queryapi.JSONEXTRACTOR,
|
||||
Config: &jcfg,
|
||||
RequiredQueries: &[]types.UUID{contextQueryRes.JSON201.Id},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusCreated, jsonQueryRes.StatusCode())
|
||||
newActiveVersion := int32(1)
|
||||
collRes, err := client.SetCollectorByClientIdWithResponse(t.Context(), clientId, queryapi.CollectorSet{
|
||||
ActiveVersion: &newActiveVersion,
|
||||
Fields: &[]queryapi.CollectorField{
|
||||
{
|
||||
Name: "JSON_QUERY",
|
||||
QueryId: jsonQueryRes.JSON201.Id,
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, collRes.StatusCode())
|
||||
|
||||
return contextQueryRes.JSON201.Id, jsonQueryRes.JSON201.Id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user