From 005765c1e9099f63589f280854be21929cddc135 Mon Sep 17 00:00:00 2001 From: Ian Fitzpatrick Date: Wed, 22 Jun 2016 12:37:19 -0700 Subject: [PATCH 1/3] Graph receipt message type and message_id --- schema/yaml/graph.yml | 123 ++++++++-------------------------- schema/yaml/shared.yml | 3 + test/schema/test_graph.coffee | 108 +++++++++-------------------- 3 files changed, 63 insertions(+), 171 deletions(-) diff --git a/schema/yaml/graph.yml b/schema/yaml/graph.yml index b249ad2..322464d 100644 --- a/schema/yaml/graph.yml +++ b/schema/yaml/graph.yml @@ -10,100 +10,33 @@ output: description: 'Graph error' $ref: '/shared/message' - addnode: - id: 'output/addnode' - description: 'Add node to a graph.' - $ref: '../input/addnode' - - removenode: - id: 'output/removenode' - description: 'Remove a node from a graph.' - $ref: '../input/removenode' - - renamenode: - id: 'output/renamenode' - description: 'Change the ID of a node in the graph' - $ref: '../input/renamenode' - - changenode: - id: 'output/changenode' - description: 'Change the metadata associated to a node in the graph' - $ref: '../input/changenode' - - addedge: - id: 'output/addedge' - description: 'Add an edge to the graph' - $ref: '../input/addedge' - - removeedge: - id: 'output/removeedge' - description: 'Remove an edge from the graph' - $ref: '../input/removeedge' - - changeedge: - id: 'output/changeedge' - description: 'Change an edge''s metadata' - $ref: '../input/changeedge' - - addinitial: - id: 'output/addinitial' - description: 'Add an IIP to the graph' - $ref: '../input/addinitial' - - removeinitial: - id: 'output/removeinitial' - description: 'Remove an IIP from the graph' - $ref: '../input/removeinitial' - - addinport: - id: 'output/addinport' - description: 'Add an exported inport to the graph.' - $ref: '../input/addinport' - - removeinport: - id: 'output/removeinport' - description: 'Remove an exported port from the graph' - $ref: '../input/removeinport' - - renameinport: - id: 'output/renameinport' - description: 'Rename an exported port in the graph' - $ref: '../input/renameinport' - - addoutport: - id: 'output/addoutport' - description: 'Add an exported outport to the graph.' - $ref: '../input/addoutport' - - removeoutport: - id: 'output/removeoutport' - description: 'Remove an exported port from the graph' - $ref: '../input/removeoutport' - - renameoutport: - id: 'output/renameoutport' - description: 'Rename an exported port in the graph' - $ref: '../input/renameoutport' - - addgroup: - id: 'output/addgroup' - description: 'Add a group to the graph' - $ref: '../input/addgroup' - - removegroup: - id: 'output/removegroup' - description: 'Remove a group from the graph' - $ref: '../input/removegroup' - - renamegroup: - id: 'output/renamegroup' - description: 'Rename a group in the graph.' - $ref: '../input/renamegroup' - - changegroup: - id: 'output/changegroup' - description: 'Change a group''s metadata' - $ref: '../input/changegroup' + receipt: + id: 'output/receipt' + description: >- + Acknowledge that message reached receiver and whether or not receiver + responded successfully. Messages that create or change graphs should + be responded to with receipt messages. + allOf: + - $ref: '/shared/message' + - properties: + protocol: + enum: ['graph'] + command: + enum: ['receipt'] + payload: + required: ['message_id', 'success'] + additionalProperties: false + properties: + message_id: + type: string + description: 'Id of input message' + success: + type: boolean + description: 'Whether or not message was successfully processed' + error: + type: string + description: >- + Error description if original message did not succeed input: error: @@ -118,7 +51,7 @@ input: protocol: enum: ['graph'] command: - enum: ['addnode'] + enum: ['clear'] payload: required: ['id'] additionalProperties: false diff --git a/schema/yaml/shared.yml b/schema/yaml/shared.yml index cc7c192..8e1b44c 100644 --- a/schema/yaml/shared.yml +++ b/schema/yaml/shared.yml @@ -26,6 +26,9 @@ message: payload: type: object description: 'content of message' + id: + type: string + description: 'unique id of message' port: id: 'port' diff --git a/test/schema/test_graph.coffee b/test/schema/test_graph.coffee index 3eda5d3..534ad45 100644 --- a/test/schema/test_graph.coffee +++ b/test/schema/test_graph.coffee @@ -9,16 +9,44 @@ describe 'Test graph protocol schema on event', -> tv4.addSchema '/shared/', sharedSchema tv4.addSchema '/graph/', graphSchema + describe 'receipt', -> + schema = '/graph/output/receipt' + + it 'should have output schema', -> + chai.expect(tv4.getSchema schema).to.exist + + it 'should validate event with required fields', -> + event = + protocol: 'graph' + command: 'receipt' + payload: + message_id: 'message1' + success: true + + chai.expect(tv4.validate event, schema).to.be.true + + describe 'clear', -> + schema = '/graph/input/clear' + + it 'should have input schema', -> + chai.expect(tv4.getSchema schema).to.exist + + it 'should validate event with required fields', -> + event = + protocol: 'graph' + command: 'clear' + payload: + id: 'graph1' + secret: 'abcdefg' + + chai.expect(tv4.validate event, schema).to.be.true + describe 'addnode', -> schema = '/graph/input/addnode' it 'should have input schema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output shema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/addnode').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -70,10 +98,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input schema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output shema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/removenode').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -90,10 +114,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input schema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output shema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/renamenode').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -111,10 +131,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input schema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output shema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/changenode').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -144,10 +160,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input schema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output schema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/addedge').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -182,10 +194,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input schema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output schema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/removeedge').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -207,10 +215,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input schema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output schema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/changeedge').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -234,10 +238,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input schema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output shema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/addinitial').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -271,10 +271,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input shema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output shema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/removeinitial').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -307,10 +303,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input shema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output schema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/addinport').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -342,10 +334,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input shema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output schema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/removeinport').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -374,10 +362,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input shema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output schema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/renameinport').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -395,10 +379,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input shema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output schema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/addoutport').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -430,10 +410,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input shema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output schema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/removeoutport').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -462,10 +438,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input shema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output schema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/renameoutport').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -483,10 +455,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input schema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output shema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/addgroup').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -516,10 +484,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input shema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output schema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/removegroup').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -536,10 +500,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input shema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output schema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/renamegroup').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' @@ -557,10 +517,6 @@ describe 'Test graph protocol schema on event', -> it 'should have input schema', -> chai.expect(tv4.getSchema schema).to.exist - it 'should have output shema', -> - chai.expect(tv4.getSchema(schema).properties).to.eql( - tv4.getSchema('/graph/output/changegroup').properties) - it 'should validate event with required fields', -> event = protocol: 'graph' From 2827126e32c0e2dbba757279b1b7bc50e74373d2 Mon Sep 17 00:00:00 2001 From: Ian Fitzpatrick Date: Wed, 22 Jun 2016 12:39:56 -0700 Subject: [PATCH 2/3] Include output messages for graph protocol in docs now that we are not repeating every message --- Gruntfile.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 9112adc..98377f9 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -149,7 +149,7 @@ module.exports = -> desc = {} protocols = runtime: ['input', 'output'] - graph: ['input'] + graph: ['input', 'output'] component: ['input', 'output'] network: ['input', 'output'] From 6b6289be136c3b5531169134b624c11854b5dd7f Mon Sep 17 00:00:00 2001 From: Ian Fitzpatrick Date: Wed, 22 Jun 2016 17:21:34 -0700 Subject: [PATCH 3/3] Clarify that message ids should uuid4 --- schema/yaml/shared.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/schema/yaml/shared.yml b/schema/yaml/shared.yml index 8e1b44c..0a71129 100644 --- a/schema/yaml/shared.yml +++ b/schema/yaml/shared.yml @@ -28,7 +28,8 @@ message: description: 'content of message' id: type: string - description: 'unique id of message' + description: >- + unique id of message, expected to be a uuid v4 as defined by rfc 4122 port: id: 'port'