Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions executors/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/ovh/venom/executors/readfile"
"github.com/ovh/venom/executors/redis"
"github.com/ovh/venom/executors/smtp"
"github.com/ovh/venom/executors/spanner"
"github.com/ovh/venom/executors/sql"
"github.com/ovh/venom/executors/ssh"
"github.com/ovh/venom/executors/web"
Expand Down Expand Up @@ -44,4 +45,5 @@ var Registry map[string]Constructor = map[string]Constructor{
mongo.Name: mongo.New,
web.Name: web.New,
couchbase.Name: couchbase.New,
spanner.Name: spanner.New,
}
71 changes: 71 additions & 0 deletions executors/spanner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Venom - Executor Spanner

Step to execute SQL statements on Google Cloud Spanner.

Supports:
* Query statements (for example `SELECT`, `WITH`)
* DML statements (for example `INSERT`, `UPDATE`, `DELETE`)

## Input

In your yaml file, declare your step like this:

```yaml
- project mandatory
- instance mandatory
- database mandatory
- credentials_file optional
- commands optional
- file optional
```

- `commands` is a list of SQL statements.
- `file` is used as fallback if `commands` is empty.
- `credentials_file` is optional. If not set, the executor uses Application Default Credentials (ADC).

## Output

Each statement result is returned in `result.queries`:

- Query statement:
- `statement_type: query`
- `rows: []`
- DML statement:
- `statement_type: dml`
- `row_count: <number>`

## Example usage

```yaml
name: Spanner sample
testcases:
- name: Query and DML
steps:
- type: spanner
project: my-project
instance: my-instance
database: my-database
commands:
- "SELECT SingerId, FirstName FROM Singers LIMIT 1"
- "UPDATE Singers SET FirstName = 'Alice' WHERE SingerId = 1"
assertions:
- result.queries.__Len__ ShouldEqual 2
- result.queries.queries0.statement_type ShouldEqual query
- result.queries.queries1.statement_type ShouldEqual dml
```

Example using a credentials file:

```yaml
name: Spanner with SA key
testcases:
- name: Query with credential file
steps:
- type: spanner
project: my-project
instance: my-instance
database: my-database
credentials_file: /path/to/service-account.json
commands:
- "SELECT 1"
```
Loading