Skip to content

Commit

Permalink
feat: migrate transactions to new resourcemanager architecture (#2551)
Browse files Browse the repository at this point in the history
  • Loading branch information
schoren committed May 23, 2023
1 parent dca002e commit 5654831
Show file tree
Hide file tree
Showing 126 changed files with 4,992 additions and 2,848 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yaml
Expand Up @@ -11,7 +11,7 @@ on:
- cli/**
- examples/**
- server/**
- tracetesting/**
- testing/**
- web/**
- Dockerfile
- k8s/**
Expand Down
84 changes: 60 additions & 24 deletions api/openapi.yaml
Expand Up @@ -61,7 +61,7 @@ paths:
/transactions:
get:
tags:
- api
- resource-api
summary: "Get transactions"
description: "get transactions"
operationId: getTransactions
Expand All @@ -74,43 +74,56 @@ paths:
responses:
200:
description: successful operation
headers:
X-Total-Count:
schema:
type: integer
description: Total records count
content:
application/json:
schema:
type: array
items:
$ref: "./transactions.yaml#/components/schemas/Transaction"
$ref: "./transactions.yaml#/components/schemas/TransactionResourceList"
text/yaml:
schema:
type: object
properties:
count:
type: integer
items:
type: array
items:
$ref: "./transactions.yaml#/components/schemas/TransactionResource"
400:
description: "invalid query for transactions, some data was sent in incorrect format."
500:
description: "problem with getting transactions"
post:
tags:
- api
- resource-api
summary: "Create new transaction"
description: "Create new transaction"
operationId: createTransaction
requestBody:
content:
application/json:
schema:
$ref: "./transactions.yaml#/components/schemas/Transaction"
$ref: "./transactions.yaml#/components/schemas/TransactionResource"
text/yaml:
schema:
$ref: "./transactions.yaml#/components/schemas/TransactionResource"
responses:
200:
201:
description: successful operation
content:
application/json:
schema:
$ref: "./transactions.yaml#/components/schemas/Transaction"
$ref: "./transactions.yaml#/components/schemas/TransactionResource"
text/yaml:
schema:
$ref: "./transactions.yaml#/components/schemas/TransactionResource"
400:
description: "trying to create a transaction with an already existing ID"
500:
description: "problem creating a transaction"
/transactions/{transactionId}:
get:
tags:
- api
- resource-api
parameters:
- $ref: "./parameters.yaml#/components/parameters/transactionId"
summary: "get transaction"
Expand All @@ -122,12 +135,17 @@ paths:
content:
application/json:
schema:
$ref: "./transactions.yaml#/components/schemas/Transaction"
$ref: "./transactions.yaml#/components/schemas/TransactionResource"
text/yaml:
schema:
$ref: "./transactions.yaml#/components/schemas/TransactionResource"
404:
description: "transaction not found"
500:
description: "problem with getting a transaction"
description: "problem getting an transaction"
put:
tags:
- api
- resource-api
parameters:
- $ref: "./parameters.yaml#/components/parameters/transactionId"
summary: "update transaction"
Expand All @@ -137,23 +155,41 @@ paths:
content:
application/json:
schema:
$ref: "./transactions.yaml#/components/schemas/Transaction"
$ref: "./transactions.yaml#/components/schemas/TransactionResource"
text/yaml:
schema:
$ref: "./transactions.yaml#/components/schemas/TransactionResource"
responses:
204:
200:
description: successful operation
content:
application/json:
schema:
$ref: "./transactions.yaml#/components/schemas/TransactionResource"
text/yaml:
schema:
$ref: "./transactions.yaml#/components/schemas/TransactionResource"
400:
description: "invalid transaction, some data was sent in incorrect format."
404:
description: "transaction not found"
500:
description: "problem with updating transaction"
description: "problem updating a transaction"
delete:
tags:
- api
- resource-api
parameters:
- $ref: "./parameters.yaml#/components/parameters/transactionId"
summary: "delete a transaction"
description: "delete a transaction"
operationId: deleteTransaction
responses:
"204":
description: OK
204:
description: successful operation
404:
description: "transaction not found"
500:
description: "problem deleting a transaction"
/transactions/{transactionId}/version/{version}:
get:
tags:
Expand Down Expand Up @@ -786,7 +822,7 @@ paths:
$ref: "./config.yaml#/components/schemas/ConfigurationResource"
500:
description: "problem updating configuration"

/pollingprofiles:
get:
tags:
Expand Down
29 changes: 29 additions & 0 deletions api/transactions.yaml
@@ -1,6 +1,29 @@
openapi: 3.0.0
components:
schemas:

TransactionResourceList:
type: object
properties:
count:
type: integer
items:
type: array
items:
$ref: "#/components/schemas/TransactionResource"

TransactionResource:
type: object
description: "Represents a transaction structured into the Resources format."
properties:
type:
type: string
description: "Represents the type of this resource. It should always be set as 'Transaction'."
enum:
- Transaction
spec:
$ref: "#/components/schemas/Transaction"

Transaction:
type: object
properties:
Expand All @@ -16,6 +39,12 @@ components:
description: version number of the test
steps:
type: array
description: list of steps of the transaction containing just each test id
items:
type: string
fullSteps:
type: array
description: list of steps of the transaction containing the whole test object
items:
$ref: "./tests.yaml#/components/schemas/Test"
createdAt:
Expand Down
15 changes: 6 additions & 9 deletions api/triggers.yaml
Expand Up @@ -7,15 +7,12 @@ components:
triggerType:
type: string
enum: ["http", "grpc", "traceid"]
triggerSettings:
type: object
properties:
http:
$ref: "./http.yaml#/components/schemas/HTTPRequest"
grpc:
$ref: "./grpc.yaml#/components/schemas/GRPCRequest"
traceid:
$ref: "./traceid.yaml#/components/schemas/TRACEIDRequest"
http:
$ref: "./http.yaml#/components/schemas/HTTPRequest"
grpc:
$ref: "./grpc.yaml#/components/schemas/GRPCRequest"
traceid:
$ref: "./traceid.yaml#/components/schemas/TRACEIDRequest"

TriggerResult:
type: object
Expand Down
10 changes: 5 additions & 5 deletions cli/actions/run_test_action.go
Expand Up @@ -23,7 +23,7 @@ import (
"go.uber.org/zap"
)

type RunTestConfig struct {
type RunResourceArgs struct {
DefinitionFile string
EnvID string
WaitForResult bool
Expand All @@ -37,7 +37,7 @@ type runTestAction struct {
environmentActions environmentsActions
}

var _ Action[RunTestConfig] = &runTestAction{}
var _ Action[RunResourceArgs] = &runTestAction{}

type runDefParams struct {
DefinitionFile string
Expand All @@ -52,7 +52,7 @@ func NewRunTestAction(config config.Config, logger *zap.Logger, client *openapi.
return runTestAction{config, logger, client, environmentActions}
}

func (a runTestAction) Run(ctx context.Context, args RunTestConfig) error {
func (a runTestAction) Run(ctx context.Context, args RunResourceArgs) error {
if args.DefinitionFile == "" {
return fmt.Errorf("you must specify a definition file to run a test")
}
Expand Down Expand Up @@ -286,14 +286,14 @@ func (a runTestAction) askForMissingVariables(resp *http.Response) (map[string]s
}

func (a runTestAction) getTransaction(ctx context.Context, id string) (openapi.Transaction, error) {
test, _, err := a.client.ApiApi.
transaction, _, err := a.client.ResourceApiApi.
GetTransaction(ctx, id).
Execute()
if err != nil {
return openapi.Transaction{}, fmt.Errorf("could not execute request: %w", err)
}

return *test, nil
return *transaction.Spec, nil
}

func (a runTestAction) getTest(ctx context.Context, id string) (openapi.Test, error) {
Expand Down

0 comments on commit 5654831

Please sign in to comment.