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.
- Host: GitHub
- URL: https://github.com/globocom/tdi
- Owner: globocom
- License: gpl-3.0
- Created: 2014-04-07T18:44:32.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-04-19T21:07:50.000Z (over 9 years ago)
- Last Synced: 2025-08-13T09:14:37.825Z (12 months ago)
- Language: Ruby
- Homepage:
- Size: 503 KB
- Stars: 12
- Watchers: 20
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
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`

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

* `1` if any `failure`

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

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

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

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