An open API service indexing awesome lists of open source software.

https://github.com/globocom/tdi

Test Driven Infrastructure. Automates validation of deployed servers.
https://github.com/globocom/tdi

Last synced: 11 months ago
JSON representation

Test Driven Infrastructure. Automates validation of deployed servers.

Awesome Lists containing this project

README

          

# TDI

Test Driven Infrastructure acceptance helpers.

Validate your deployed infrastructure and external dependencies.

## Installation

Add this line to your Gemfile:

```bash
gem 'tdi'
```

And then execute:

```bash
$ bundle
```

Or install with:

```bash
$ gem install tdi
```

## Usage

```bash
$ tdi [-h]

Usage:

tdi test_plan_file [options]

Examples:

tdi tdi.json

tdi tdi.json -n
tdi tdi.json --nofail

tdi tdi.json -w
tdi tdi.json --warnfail

tdi tdi.json -p app
tdi tdi.json --plan app
tdi tdi.json --plan app::acl
tdi tdi.json --plan app::acl,app::file

tdi tdi.json -r /tmp/tdi-report.json
tdi tdi.json --reportfile /tmp/tdi-report.json

tdi tdi.json -s
tdi tdi.json --shred

tdi tdi.json -v
tdi tdi.json -vv
tdi tdi.json -vvv

tdi --version

Options:

-n, --nofail No fail mode.
-w, --warnfail Fail if any warning.
-p, --plan Test plan list.
-r, --reportfile Report file to save test plan status.
-s, --shred Wipe out the test plan, leaving no trace behind.
-v, --verbose Verbose mode.
--version Version.
-h, --help Display this help message.
```

## Test plan samples

[Sample TDI JSONs](https://github.com/globocom/tdi/tree/master/doc/json)

### ACL

Test network access/filters for TCP services.

[acl.json](https://github.com/globocom/tdi/tree/master/doc/json/acl.json)

```json
{
"app": {
"desc": "Test role",
"acl": {
"port": 80,

"www.globo.com": {},

"globoesporte.globo.com": {},

"cartolafc.globo.com": {},

"doesnotexist.globo.com": {},

"www.example.com": {
"port": [80, 9999],
"timeout": 3
},

"localhost": {
"port": [22, 31337]
}
}
}
}
```

### FILE

Test files and diretories permissions.

[file.json](https://github.com/globocom/tdi/tree/master/doc/json/file.json)

```json
{
"app": {
"desc": "Test role",
"file": {
"user": "nobody",
"perm": "rw",
"type": "file",
"location": "local",

"/tmp/afile1.txt": {},

"/tmp/afile2.txt": {
"perm": "ro"
},

"/tmp/afile3.txt": {
"user": "root"
},

"/tmp/doesnotexist/afile.txt": {},

"/tmp/doesnotexist": {
"type": "directory"
},

"/tmp": {
"type": "directory"
}
}
}
}
```

### HTTP

Test URLs and match expected responses.

[http.json](https://github.com/globocom/tdi/tree/master/doc/json/http.json)

```json
{
"app": {
"desc": "Test role",
"http": {
"globoesporte.globo.com": {
"match": " {
:desc => 'Test role',
:acl => {'localhost' => {:port => [22, 80]}},
:http => {
'globo.com' => {:code => 301},
'noexist.globo.com' => {:code => 200},
},
}
}

File.open('tdi.json', 'w').write(JSON.pretty_generate(tdi_plan))
```

### Python

```python
import json

tdi_plan = {
'app': {
'desc': 'Test role',
'acl': {'localhost': {'port': [22, 80]}},
'http': {
'globo.com': {'code': 301},
'noexist.globo.com': {'code': 200},
},
}
}

open('tdi.json', 'w').write(json.dumps(tdi_plan, indent=2))
```

### Validating your plan file

Use JSONLint site to validate your JSONs.

http://jsonlint.com/

## Running test plans and their possible `return codes`

Return codes are:

* `0` if all `success`

![success](https://raw.githubusercontent.com/globocom/tdi/master/doc/output/success.png)

* `0` by default even if warning (warning should not generate a validation error)

![warning](https://raw.githubusercontent.com/globocom/tdi/master/doc/output/warning.png)

* `1` if any `failure`

![failure](https://raw.githubusercontent.com/globocom/tdi/master/doc/output/failure.png)

* `2` if any `warning` plus option `-w` or `--warnfail`

![warnfail](https://raw.githubusercontent.com/globocom/tdi/master/doc/output/warnfail.png)

* `3` if both `failure` and `warning` plus option `-w` or `--warnfail`

![both](https://raw.githubusercontent.com/globocom/tdi/master/doc/output/both.png)

* `0` regardless failure or warning if `-n` or `--nofail`

![nofail](https://raw.githubusercontent.com/globocom/tdi/master/doc/output/nofail.png)

## Contributors

[People](https://github.com/globocom/tdi/graphs/contributors)