Skip to content

Commit

Permalink
feat: transaction run crud and execution (#1465)
Browse files Browse the repository at this point in the history
* add transaction run to openapi spec

* implement transaction runs in db

* generate frontend types

* add controller implementation

* implement transaction runner

* fix frontend code errors

* fix runner and add get endpoints for transaction runs

* add delete endpoint and fix error handling in db layer

* refactor time.sleep and make transaction check period configurable

* don't export transaction runner

* refactor patchEnvironment function

* refactor condition for patching environment

* add env to be overriden in env merge test

* use run instead of runs in api definition

* improve memory usage

* use channel to notify end of test run

* export transaction step

* Revert "generate frontend types"

This reverts commit 784b0c7.

* Revert "fix frontend code errors"

This reverts commit adbe84b.

* test consuming channel

* fix run result channel

* disable cleanup for debugging

* remove hack

* fix channel

* Revert "disable cleanup for debugging"

This reverts commit 3beeff2.
  • Loading branch information
mathnogueira committed Nov 14, 2022
1 parent 467a0be commit aaad0b7
Show file tree
Hide file tree
Showing 47 changed files with 5,270 additions and 804 deletions.
2 changes: 1 addition & 1 deletion api/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ components:
type: object
properties:
runInformation:
$ref: "./tests.yaml#/components/schemas/TestRunInformation"
$ref: "./tests.yaml#/components/schemas/RunInformation"
content:
type: string
101 changes: 100 additions & 1 deletion api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,105 @@ paths:
responses:
"204":
description: OK

/transactions/{transactionId}/run:
post:
tags:
- api
parameters:
- in: path
name: transactionId
schema:
type: string
required: true
summary: "run transaction"
description: "run a particular transaction"
operationId: runTransaction
requestBody:
content:
application/json:
schema:
$ref: "./tests.yaml#/components/schemas/RunInformation"
responses:
200:
description: successful operation
content:
application/json:
schema:
$ref: "./transactions.yaml#/components/schemas/TransactionRun"
get:
tags:
- api
parameters:
- in: path
name: transactionId
schema:
type: string
required: true
summary: "Get all runs from a particular transaction"
description: "Get all runs from a particular transaction"
operationId: getTransactionRuns
responses:
200:
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "./transactions.yaml#/components/schemas/TransactionRun"

/transactions/{transactionId}/run/{runId}:
get:
tags:
- api
parameters:
- in: path
name: transactionId
schema:
type: string
required: true
- in: path
name: runId
schema:
type: integer
required: true
summary: "Get a specific run from a particular transaction"
description: "Get a specific run from a particular transaction"
operationId: getTransactionRun
responses:
200:
description: OK
content:
application/json:
schema:
$ref: "./transactions.yaml#/components/schemas/TransactionRun"
404:
description: transaction run not found

delete:
tags:
- api
parameters:
- in: path
name: transactionId
schema:
type: string
required: true
- in: path
name: runId
schema:
type: integer
required: true
summary: "Delete a specific run from a particular transaction"
description: "Delete a specific run from a particular transaction"
operationId: deleteTransactionRun
responses:
204:
description: OK
404:
description: transaction run not found

/tests:
get:
tags:
Expand Down Expand Up @@ -317,7 +416,7 @@ paths:
content:
application/json:
schema:
$ref: "./tests.yaml#/components/schemas/TestRunInformation"
$ref: "./tests.yaml#/components/schemas/RunInformation"
responses:
200:
description: successful operation
Expand Down
2 changes: 1 addition & 1 deletion api/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ components:
additionalProperties:
type: string

TestRunInformation:
RunInformation:
type: object
properties:
metadata:
Expand Down
36 changes: 36 additions & 0 deletions api/transactions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,39 @@ components:
createdAt:
type: string
format: date-time

TransactionRun:
type: object
properties:
id:
type: string
readOnly: true
createdAt:
type: string
format: date-time
completedAt:
type: string
format: date-time
state:
type: string
enum:
[
CREATED,
EXECUTING,
FINISHED,
FAILED,
]
steps:
type: array
items:
$ref: "./tests.yaml#/components/schemas/Test"
stepRuns:
type: array
items:
$ref: "./tests.yaml#/components/schemas/TestRun"
environment:
$ref: "./environments.yaml#/components/schemas/Environment"
metadata:
type: object
additionalProperties:
type: string
2 changes: 1 addition & 1 deletion cli/actions/run_test_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (a runTestAction) runDefinitionFile(ctx context.Context, f file.File, param
ExecuteDefinition(ctx).
TextDefinition(openapi.TextDefinition{
Content: openapi.PtrString(resolvedFile.Contents()),
RunInformation: &openapi.TestRunInformation{
RunInformation: &openapi.RunInformation{
Metadata: params.Metadata,
},
}).
Expand Down

0 comments on commit aaad0b7

Please sign in to comment.