Initial support for generating Thermos data objects.

This commit is contained in:
Renan DelValle 2018-12-28 11:46:11 -08:00
parent 51597ecb32
commit afcdaa84b8
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
2 changed files with 115 additions and 0 deletions

66
thermos_test.go Normal file
View file

@ -0,0 +1,66 @@
package realis_test
import (
"encoding/json"
"testing"
"github.com/paypal/gorealis/v2"
"github.com/stretchr/testify/assert"
)
func TestThermosTask(t *testing.T) {
// Test that we can successfully deserialize a minimum subset of an Aurora generated thermos payload
thermosJSON := []byte(
`{
"task": {
"processes": [
{
"daemon": false,
"name": "hello",
"ephemeral": false,
"max_failures": 1,
"min_duration": 5,
"cmdline": "\n while true; do\n echo hello world from gorealis\n sleep 10\n done\n ",
"final": false
}
],
"resources": {
"gpu": 0,
"disk": 134217728,
"ram": 134217728,
"cpu": 1.1
},
"constraints": [
{
"order": [
"hello"
]
}
]
}
}`)
thermos := realis.ThermosExecutor{}
err := json.Unmarshal(thermosJSON, &thermos)
assert.NoError(t, err)
thermosExpected := realis.ThermosExecutor{
Task: realis.ThermosTask{
Processes: []realis.ThermosProcess{
{
Daemon: false,
Name: "hello",
Ephemeral: false,
MaxFailures: 1,
MinDuration: 5,
Cmdline: "\n while true; do\n echo hello world from gorealis\n sleep 10\n done\n ",
Final: false,
},
},
Constraints: []realis.ThermosConstraint{{Order: []string{"hello"}}},
Resources: realis.ThermosResources{CPU: 1.1, Disk: 134217728, RAM: 134217728, GPU: 0}}}
assert.ObjectsAreEqual(thermosExpected, thermos)
}