Skip to content

Commit

Permalink
WIP checkin. Modify components to handle flattened object list.
Browse files Browse the repository at this point in the history
  • Loading branch information
justinkambic committed May 15, 2018
1 parent 055fd8c commit 257a905
Show file tree
Hide file tree
Showing 9 changed files with 401 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export class IfVertex extends Vertex {
return this.outgoingEdges.find(e => e.when === true);
}

// get allTrueVertices() {
// const outgoingIds = this.outgoingEdges.filter(e => e.when === true).map(e => e.to.id);
// return this.outgoingVertices.filter(v => outgoingIds.some(id => id === v.id));
// }

get falseEdge() {
return this.outgoingEdges.find(e => e.when === false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,356 @@ describe('Pipeline class', () => {
});
});

// output {
// stdout { }
// if [foo] in [foobar] {
// elasticsearch {
// id => "testElasticsearch"
// password => changeme
// user => elastic
// }
// }
// if [foo] in [foobar] and [foo] in [foobar2] {
// stdout { }
// if [foo2] in [foobar] {
// if [foo3] in [foobar] {
// if [foo4] in [foobar] {
// stdout { }
// }
// else {
// stdout { }
// }
// }
// else {
// stdout { }
// }
// }
// else {
// stdout { }
// }
// }
// else {
// file {
// path => "/Users/jk/git/justinkambic/logstash-data/tmp2"
// gzip => true
// }
// }
// stdout { }
// }

describe('Big test', () => {
beforeEach(() => {
graph = new Graph();
graph.update({
edges: [
{
id: "1519e0960d295b9de71e5885ca749d950cecb644112a2204b14ac39e408c6a1f",
when: true,
type: "boolean",
to: "testElasticsearch",
from: "9afa5b6a10e437211f92a276649bf5e085662684efdf08e6e85f9aa64ed35611"
},
{
id: "c7bb239c7f7432b290ae7d5695993a77adf1ac38d81d264d7db8dad81bf2b967",
when: true,
type: "boolean",
to: "f46184583487f1c19c158468f5c7c530a6a6d78e9fc3c544ec68979defadcc2e",
from: "8c07e7d5f41f51402b4d8806e78bbe417226ab698f1107f33a1e4b3733e170ac"
},
{//
id: "adc8d5a2c791bf3f7f19885b7f47fc1b4e9158ae38783566612410676a95f45f",
when: true,
type: "boolean",
to: "e74136fab69c02fddce137c921183ef90ea4d059af45072406a62566a3999dfa",
from: "8c07e7d5f41f51402b4d8806e78bbe417226ab698f1107f33a1e4b3733e170ac"
},
{//
id: "7176b02619dad090da4914a9e20a342b53f5826d7d68f2675d81ead4111d425d",
when: false,
type: "boolean",
to: "b42c580b154d8f2667f3dbbfc6596c395f356f477602fdcac54e2c5c7c7e82f0",
from: "8c07e7d5f41f51402b4d8806e78bbe417226ab698f1107f33a1e4b3733e170ac"
},
{
id: "29fe123e774b2b9bcc14d05480228674aad8401605ebfd4c98d47b858e55d044",
when: true,
type: "boolean",
to: "c99f15438d618162e1535bb5e7cddb38781e1fc35bac21707638e80428eea031",
from: "567af720ff70c8d57c45fbed037b9713222d46d0d75d9d657610eb92803dd53f"
},
{//
id: "93b2b6bb17f73237057aff4c97d75c0207e475898486395838533ed2713fdaf1",
when: true,
type: "boolean",
to: "000b81326e4a370c03b8e812a3da9919cc9cb92cee9ec94b124c2528bd6d3642",
from: "e74136fab69c02fddce137c921183ef90ea4d059af45072406a62566a3999dfa"
},
{//
id: "a31f86e9baa00afff575e52d3c9e25cd897e912f3fa2efb086f8165398047d37",
when: false,
type: "boolean",
to: "073e7304b236abb12880d08eb84919199647e59cf64c4dda3896db440dfb3170",
from: "e74136fab69c02fddce137c921183ef90ea4d059af45072406a62566a3999dfa"
},
{//
id: "144ee5c922faae3f32979a9c7320f63b6e580557254c396461806c88bb30d148",
when: true,
type: "boolean",
to: "567af720ff70c8d57c45fbed037b9713222d46d0d75d9d657610eb92803dd53f",
from: "000b81326e4a370c03b8e812a3da9919cc9cb92cee9ec94b124c2528bd6d3642"
},
{//
id: "e8c14e04a4a12afebb44929305863e55a45d2a7ad246e49dec8d71884f7cc9ab",
when: false,
type: "boolean",
to: "9fd02fd6ed7ed27f1e96767f9041b0aa1b5a83e352551cfcd793cbfc662f2af0",
from: "000b81326e4a370c03b8e812a3da9919cc9cb92cee9ec94b124c2528bd6d3642"
},
{//
id: "906985acef938b973da9bc30e284e418bd4723a1efcecedcb16eb060f5fd0ef4",
when: false,
type: "boolean",
to: "50522abe405d4028e6791f4c3ba9e3472f50890992c12071d2902be3d75f50a8",
from: "567af720ff70c8d57c45fbed037b9713222d46d0d75d9d657610eb92803dd53f"
},
],
vertices: [
{
plugin_type: "output",
type: "plugin",
config_name: "stdout",
id: "1637f9a5b2c1cc9610bb6a5e2ccc957e6118f2e32d2da5b9ad2c8eccac59cc88",
meta: {
source: {
line: 115,
protocol: "str",
id: "pipeline",
column: 3
}
},
explicit_id: false,
stats: null
},
{
explicit_id: false,
id: "9afa5b6a10e437211f92a276649bf5e085662684efdf08e6e85f9aa64ed35611",
meta: {
source: {
line: 116,
protocol: "str",
id: "pipeline",
column: 6
}
},
type: "if",
condition: "[foo] in [foobar]",
stats: null
},
{
plugin_type: "output",
type: "plugin",
config_name: "elasticsearch",
id: "testElasticsearch",
meta: {
source: {
line: 117,
protocol: "str",
id: "pipeline",
column: 5
}
},
explicit_id: true,
stats: null
},
{
explicit_id: false,
id: "8c07e7d5f41f51402b4d8806e78bbe417226ab698f1107f33a1e4b3733e170ac",
meta: {
source: {
line: 123,
protocol: "str",
id: "pipeline",
column: 6
}
},
type: "if",
condition: "[foo] in [foobar] and [foo] in [foobar2]",
stats: null
},
{
plugin_type: "output",
type: "plugin",
config_name: "stdout",
id: "f46184583487f1c19c158468f5c7c530a6a6d78e9fc3c544ec68979defadcc2e",
meta: {
source: {
line: 124,
protocol: "str",
id: "pipeline",
column: 5
}
},
explicit_id: false,
stats: null
},
{
explicit_id: false,
id: "e74136fab69c02fddce137c921183ef90ea4d059af45072406a62566a3999dfa",
meta: {
source: {
line: 125,
protocol: "str",
id: "pipeline",
column: 8
}
},
type: "if",
condition: "[foo2] in [foobar]",
stats: null
},
{
explicit_id: false,
id: "000b81326e4a370c03b8e812a3da9919cc9cb92cee9ec94b124c2528bd6d3642",
meta: {
source: {
line: 126,
protocol: "str",
id: "pipeline",
column: 10
}
},
type: "if",
condition: "[foo3] in [foobar]",
stats: null
},
{
explicit_id: false,
id: "567af720ff70c8d57c45fbed037b9713222d46d0d75d9d657610eb92803dd53f",
meta: {
source: {
line: 127,
protocol: "str",
id: "pipeline",
column: 12
}
},
type: "if",
condition: "[foo4] in [foobar]",
stats: null
},
{
plugin_type: "output",
type: "plugin",
config_name: "stdout",
id: "c99f15438d618162e1535bb5e7cddb38781e1fc35bac21707638e80428eea031",
meta: {
source: {
line: 128,
protocol: "str",
id: "pipeline",
column: 11
}
},
explicit_id: false,
stats: null
},
{
plugin_type: "output",
type: "plugin",
config_name: "stdout",
id: "50522abe405d4028e6791f4c3ba9e3472f50890992c12071d2902be3d75f50a8",
meta: {
source: {
line: 131,
protocol: "str",
id: "pipeline",
column: 11
}
},
explicit_id: false,
stats: null
},
{
plugin_type: "output",
type: "plugin",
config_name: "stdout",
id: "9fd02fd6ed7ed27f1e96767f9041b0aa1b5a83e352551cfcd793cbfc662f2af0",
meta: {
source: {
line: 135,
protocol: "str",
id: "pipeline",
column: 9
}
},
explicit_id: false,
stats: null
},
{
plugin_type: "output",
type: "plugin",
config_name: "stdout",
id: "073e7304b236abb12880d08eb84919199647e59cf64c4dda3896db440dfb3170",
meta: {
source: {
line: 139,
protocol: "str",
id: "pipeline",
column: 7
}
},
explicit_id: false,
stats: null
},
{
plugin_type: "output",
type: "plugin",
config_name: "file",
id: "b42c580b154d8f2667f3dbbfc6596c395f356f477602fdcac54e2c5c7c7e82f0",
meta: {
source: {
line: 143,
protocol: "str",
id: "pipeline",
column: 5
}
},
explicit_id: false,
stats: null
},
{
plugin_type: "output",
type: "plugin",
config_name: "stdout",
id: "b959611c55dffa3deb3fb8e8343a5e73b40693b3a491ab1a26ebe483346bb4fc",
meta: {
source: {
line: 148,
protocol: "str",
id: "pipeline",
column: 3
}
},
explicit_id: false,
stats: null
}
]
});
});

it('should fail', () => {
const pipeline = Pipeline.fromPipelineGraph(graph);

//console.log(pipeline.outputStatements);
expect(pipeline.outputStatements.length).to.be(4);
expect(pipeline.outputStatements[1].trueStatements.length).to.be(1);
expect(pipeline.outputStatements[2].trueStatements.length).to.be(2);
//expect(pipeline.outputStatements[1].elseStatements.length).to.be(0);

//expect(1).to.be(2);
});
});

describe('Pipeline with nested ifs', () => {
beforeEach(() => {
graph = new Graph();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,24 @@ function getQueue(pipelineGraph) {
}

function getOutputStatements(pipelineGraph) {
return pipelineGraph.getVertices()
.filter(v => (v.pipelineStage === 'output') && !v.incomingVertices.some(p => p.pipelineStage === 'output'))
const vertices = pipelineGraph.getVertices()
.filter(v => (v.pipelineStage === 'output') && !v.incomingVertices.some(p => p.pipelineStage === 'output'));
const ret = vertices
.map(v => makeStatement(v, 'output'));

// console.log(pipelineGraph.getVertices());
// console.log(vertices);
// console.log(ret[2]);
// console.log(Object.keys(ret[2]));
// console.log(ret[2].allTrueVertices);

// const allTrue = vertices[2].allTrueVertices;
// console.log(allTrue);
// console.log(allTrue[0]);

//console.log(vertices[2].allTrueVertices);

return ret;
}

export class Pipeline {
Expand Down

0 comments on commit 257a905

Please sign in to comment.