funktionio / funktion

a CLI tool for working with funktion
https://funktion.fabric8.io/
Apache License 2.0
297 stars 25 forks source link

provide a Test command to test a step #29

Open jstrachan opened 7 years ago

jstrachan commented 7 years ago

it would be nice to be able to choose a sample input message and to test out a single step in an existing flow. Eventually we could package this up as a REST API we can use from consoles but starting with a CLI would be great.

e.g. something like:

$ funktion test-step myflow 3 -f sampleMessage.json -oyaml
testing myflow step setHeader:foo=bar
output:
  foo: 1234

Under the covers we'd need to create a new temporary flow for something like:

funktion create flow mytmp http://localhost setHeader:foo=bar

i.e. pull out the step to be tested and add a http endpoint in front. Then the funktion test-step would wait for a pod to start, when its up, POST the sampleMessage.json to the pod's HTTP port and output/save the results (then removing the flow). We could use a temporary namespace for these 'tests' to avoid it confusing end users too?

jstrachan commented 7 years ago

over time we maybe wanna get more clever, having pools of 'Test flows' pods around that we update on the fly rather than spin up from scratch - as Java + camel can take a while to startup ;)

So we maybe want a way to have single message mode flows that we update the flow, wait for the response, then the pod stays around until we decide to explicitly kill it (to scale down the pool) or replace the flow with a new step to test.

e.g. if you set the singleMessageMode: true on a flow it will only process 1 message then stop. So we can then just find a pod thats finished; update its flow.yml, fire in a new message and wait for the result.

Another option is to put the sample message into some canonical place (a message store - such as the content-repository HTTP server we use for hosting build maven websites) - then the flow consumes from that URL and posts the results to some place and just poll for the result from the CLI - then we don't need to worry about watching the pod is ready to know if its ready for POSTing to?

It may be simplest to POST to a HTTP endpoint inside the 'test pods', the sample message and the flow and for the HTTP response to come back with the result message? Then we just need a special HTTP connector in the test pods we can use?