{
"_comment": "Golden vectors for JSON control messages. Each valid message must parse and re-serialize to an equal JSON value; each invalid one must be refused. See spec/control-messages.md.",
"valid": [
{
"name": "authenticate",
"json": {
"type": "Authenticate",
"data": {
"request_id": "r1",
"protocol_version": 1,
"tenant_id": "acme",
"client_id": "c-1",
"auth_method": "api_key",
"credentials": "k"
}
}
},
{
"name": "flush ack",
"json": {
"type": "FlushAck",
"data": {
"request_id": "r2",
"file_id": 3,
"seq": 17
}
}
},
{
"name": "resync request",
"json": {
"type": "Resync",
"data": {
"request_id": "r3",
"file_id": 3
}
}
},
{
"name": "resync done",
"json": {
"type": "ResyncDone",
"data": {
"request_id": "r3",
"file_id": 3,
"seq": 18,
"size": 4096
}
}
},
{
"name": "error with request id",
"json": {
"type": "Error",
"data": {
"code": "PERMISSION_DENIED",
"message": "no grant",
"request_id": "r4"
}
}
},
{
"name": "error without request id",
"json": {
"type": "Error",
"data": {
"code": "INVALID_REQUEST",
"message": "bad frame"
}
}
},
{
"name": "get service file path",
"json": {
"type": "GetServiceFilePath",
"data": {
"request_id": "r5",
"service_id": "svc-1"
}
}
},
{
"name": "service file path offered",
"json": {
"type": "ServiceFilePath",
"data": {
"request_id": "r5",
"service_id": "svc-1",
"file_id": 3,
"path": "/srv/commy/tenant_acme/svc-1.bin",
"nonce_path": "/srv/commy/tenant_acme/.nonce-9f2c"
}
}
},
{
"name": "service file path not offered",
"json": {
"type": "ServiceFilePath",
"data": {
"request_id": "r5",
"service_id": "svc-1",
"file_id": 3
}
}
},
{
"name": "confirm local",
"json": {
"type": "ConfirmLocal",
"data": {
"request_id": "r6",
"file_id": 3,
"nonce": "c0ffee"
}
}
},
{
"name": "confirm local ack",
"json": {
"type": "ConfirmLocalAck",
"data": {
"request_id": "r6",
"file_id": 3
}
}
},
{
"name": "rotate request resize",
"json": {
"type": "RotateRequest",
"data": {
"request_id": "q1",
"service_id": "svc-1",
"reason": "RESIZE",
"new_size": 1048576
}
}
},
{
"name": "rotate request revocation",
"json": {
"type": "RotateRequest",
"data": {
"request_id": "q2",
"service_id": "svc-1",
"reason": "REVOCATION",
"revoke_client_id": "c-9"
}
}
},
{
"name": "rotation accepted",
"json": {
"type": "RotationAccepted",
"data": {
"request_id": "q1",
"rotation_id": "rot-1"
}
}
},
{
"name": "rotation pending",
"json": {
"type": "RotationPending",
"data": {
"rotation_id": "rot-1",
"service_id": "svc-1",
"file_id": 3,
"deadline_ms": 5000
}
}
},
{
"name": "rotation drained",
"json": {
"type": "RotationDrained",
"data": {
"request_id": "q3",
"rotation_id": "rot-1",
"file_id": 3,
"seq": 42
}
}
},
{
"name": "rotation commit resize",
"json": {
"type": "RotationCommit",
"data": {
"rotation_id": "rot-1",
"service_id": "svc-1",
"reason": "RESIZE",
"old_file_id": 3,
"new_file_id": 4,
"generation": 1,
"size": 1048576
}
}
},
{
"name": "loss straggler",
"json": {
"type": "Loss",
"data": {
"service_id": "svc-1",
"file_id": 3,
"kind": "ROTATION_STRAGGLER"
}
}
},
{
"name": "loss resync overwrote with ranges",
"json": {
"type": "Loss",
"data": {
"service_id": "svc-1",
"file_id": 3,
"kind": "RESYNC_OVERWROTE",
"ranges": [
{
"offset": 4096,
"len": 16
}
]
}
}
},
{
"name": "loss revoked",
"json": {
"type": "Loss",
"data": {
"service_id": "svc-1",
"file_id": 3,
"kind": "REVOKED"
}
}
},
{
"name": "commit without a preceding pending (late joiner) is just a commit",
"json": {
"type": "RotationCommit",
"data": {
"rotation_id": "rot-2",
"service_id": "svc-1",
"reason": "REVOCATION",
"old_file_id": 4,
"new_file_id": 5,
"generation": 2,
"size": 4096
}
}
}
],
"invalid": [
{
"name": "authenticate without protocol_version",
"json": {
"type": "Authenticate",
"data": {
"request_id": "r1",
"tenant_id": "acme",
"client_id": "c-1",
"auth_method": "api_key",
"credentials": "k"
}
}
},
{
"name": "authenticate without request_id",
"json": {
"type": "Authenticate",
"data": {
"protocol_version": 1,
"tenant_id": "acme",
"client_id": "c-1",
"auth_method": "api_key",
"credentials": "k"
}
}
},
{
"name": "flush ack with negative seq",
"json": {
"type": "FlushAck",
"data": {
"request_id": "r2",
"file_id": 3,
"seq": -1
}
}
},
{
"name": "unknown field",
"json": {
"type": "Resync",
"data": {
"request_id": "r3",
"file_id": 3,
"extra": true
}
}
},
{
"name": "unknown message type",
"json": {
"type": "Bogus",
"data": {}
}
},
{
"name": "legacy error spelling",
"json": {
"type": "Error",
"data": {
"code": "Unauthorized",
"message": "x"
}
}
},
{
"name": "confirm local without nonce",
"json": {
"type": "ConfirmLocal",
"data": {
"request_id": "r6",
"file_id": 3
}
}
},
{
"name": "service file path without file_id",
"json": {
"type": "ServiceFilePath",
"data": {
"request_id": "r5",
"service_id": "svc-1"
}
}
},
{
"name": "get service file path without service_id",
"json": {
"type": "GetServiceFilePath",
"data": {
"request_id": "r5"
}
}
},
{
"name": "rotate request with unknown reason",
"json": {
"type": "RotateRequest",
"data": {
"request_id": "q1",
"service_id": "svc-1",
"reason": "resize",
"new_size": 4096
}
}
},
{
"name": "rotation commit without generation",
"json": {
"type": "RotationCommit",
"data": {
"rotation_id": "rot-1",
"service_id": "svc-1",
"reason": "RESIZE",
"old_file_id": 3,
"new_file_id": 4,
"size": 1048576
}
}
},
{
"name": "rotation drained without seq",
"json": {
"type": "RotationDrained",
"data": {
"request_id": "q3",
"rotation_id": "rot-1",
"file_id": 3
}
}
}
],
"inconsistent_rotate_requests": [
{
"name": "resize without new_size",
"json": {
"type": "RotateRequest",
"data": {
"request_id": "q1",
"service_id": "svc-1",
"reason": "RESIZE"
}
}
},
{
"name": "resize with zero new_size",
"json": {
"type": "RotateRequest",
"data": {
"request_id": "q1",
"service_id": "svc-1",
"reason": "RESIZE",
"new_size": 0
}
}
},
{
"name": "resize naming a client",
"json": {
"type": "RotateRequest",
"data": {
"request_id": "q1",
"service_id": "svc-1",
"reason": "RESIZE",
"new_size": 4096,
"revoke_client_id": "c-9"
}
}
},
{
"name": "revocation without client",
"json": {
"type": "RotateRequest",
"data": {
"request_id": "q2",
"service_id": "svc-1",
"reason": "REVOCATION"
}
}
},
{
"name": "revocation with new_size",
"json": {
"type": "RotateRequest",
"data": {
"request_id": "q2",
"service_id": "svc-1",
"reason": "REVOCATION",
"revoke_client_id": "c-9",
"new_size": 4096
}
}
}
],
"tolerated_unknown_loss_kinds": [
{
"name": "loss with a kind from a newer server",
"json": {
"type": "Loss",
"data": {
"service_id": "svc-1",
"file_id": 3,
"kind": "LOST_IN_SPACE"
}
}
}
]
}