Skip to content

Instantly share code, notes, and snippets.

@rtyler
Last active October 29, 2020 18:48
Show Gist options
  • Save rtyler/4c999e9c953070f4ad4188ff6df4bbe0 to your computer and use it in GitHub Desktop.
Save rtyler/4c999e9c953070f4ad4188ff6df4bbe0 to your computer and use it in GitHub Desktop.
Simple Otto step library testing

Prerequisites

  • Have a rust compiler set up

  • make steps will package all the steps up for you

  • mkdir tmp && for f in *.tar.gz; do tar -zxvf $f -C tmp; done will prepare the tmp/ directory with those step libraries extracted

Then you should be able ro invoke the test-pipeline.yml with the following command:

RUST_LOG=debug STEPS_DIR=$PWD/tmp ./target/release/otto-agent ./test-pipeline.yml
INFO ottoagent::control > Starting the agent control server
INFO tide::listener::unix_listener > Server listening on http+unix:///home/tyler/source/git/otto/agent.sock
WARN ottoagent > unknown/manifest.yml does not exist, step cannot execute
StepStart { symbol: "sh", uuid: 5599cffb-f23a-4e0f-a0b9-f74654641b2b }
StepOutput { symbol: "sh", uuid: 5599cffb-f23a-4e0f-a0b9-f74654641b2b, buffer: "-rw-r--r-- 1 tyler users 1.1K Feb 20 2020 system.dot", stream: Stdout }
StepOutput { symbol: "sh", uuid: 5599cffb-f23a-4e0f-a0b9-f74654641b2b, buffer: "-rw-r--r-- 1 tyler users 43K Feb 20 2020 system.png", stream: Stdout }
StepOutput { symbol: "sh", uuid: 5599cffb-f23a-4e0f-a0b9-f74654641b2b, buffer: "drwxr-xr-x 7 tyler users 4.0K Oct 17 15:25 target", stream: Stdout }
StepOutput { symbol: "sh", uuid: 5599cffb-f23a-4e0f-a0b9-f74654641b2b, buffer: "-rw-r--r-- 1 tyler users 2.2K Oct 28 10:57 test-pipeline.yml", stream: Stdout }
StepOutput { symbol: "sh", uuid: 5599cffb-f23a-4e0f-a0b9-f74654641b2b, buffer: "drwxr-xr-x 9 tyler users 4.0K Oct 28 15:33 tmp", stream: Stdout }
StepOutput { symbol: "sh", uuid: 5599cffb-f23a-4e0f-a0b9-f74654641b2b, buffer: "+ ls -lah", stream: Stdout }
StepOutput { symbol: "sh", uuid: 5599cffb-f23a-4e0f-a0b9-f74654641b2b, buffer: "+ tail -n 5", stream: Stdout }
StepEnd { symbol: "sh", uuid: 5599cffb-f23a-4e0f-a0b9-f74654641b2b }
StepStart { symbol: "sh", uuid: 2265b5d0-1f70-46de-bf50-f1050e9fac9a }
StepOutput { symbol: "sh", uuid: 2265b5d0-1f70-46de-bf50-f1050e9fac9a, buffer: "Hello world from a script", stream: Stdout }
StepOutput { symbol: "sh", uuid: 2265b5d0-1f70-46de-bf50-f1050e9fac9a, buffer: "+ echo \'Hello world from a script\'", stream: Stdout }
StepEnd { symbol: "sh", uuid: 2265b5d0-1f70-46de-bf50-f1050e9fac9a }
StepStart { symbol: "dir", uuid: 022c09ef-15f2-456a-a93a-92e584c1a1f4 }
StepStart { symbol: "sh", uuid: 81e8309e-e615-49d4-946c-22527ebce8e1 }
StepOutput { symbol: "sh", uuid: 81e8309e-e615-49d4-946c-22527ebce8e1, buffer: "/home/tyler/source/git/otto/stdlib", stream: Stdout }
StepOutput { symbol: "sh", uuid: 81e8309e-e615-49d4-946c-22527ebce8e1, buffer: "total 28K", stream: Stdout }
StepOutput { symbol: "sh", uuid: 81e8309e-e615-49d4-946c-22527ebce8e1, buffer: "drwxr-xr-x 7 tyler users 4.0K Oct 28 11:04 .", stream: Stdout }
StepOutput { symbol: "sh", uuid: 81e8309e-e615-49d4-946c-22527ebce8e1, buffer: "drwxr-xr-x 22 tyler users 4.0K Oct 29 08:25 ..", stream: Stdout }
StepOutput { symbol: "sh", uuid: 81e8309e-e615-49d4-946c-22527ebce8e1, buffer: "drwxr-xr-x 4 tyler users 4.0K Oct 28 15:33 archive", stream: Stdout }
StepOutput { symbol: "sh", uuid: 81e8309e-e615-49d4-946c-22527ebce8e1, buffer: "drwxr-xr-x 4 tyler users 4.0K Oct 22 20:19 dir", stream: Stdout }
StepOutput { symbol: "sh", uuid: 81e8309e-e615-49d4-946c-22527ebce8e1, buffer: "drwxr-xr-x 2 tyler users 4.0K Oct 22 20:28 echo", stream: Stdout }
StepOutput { symbol: "sh", uuid: 81e8309e-e615-49d4-946c-22527ebce8e1, buffer: "drwxr-xr-x 3 tyler users 4.0K Oct 28 10:25 error", stream: Stdout }
StepOutput { symbol: "sh", uuid: 81e8309e-e615-49d4-946c-22527ebce8e1, buffer: "drwxr-xr-x 4 tyler users 4.0K Oct 28 11:11 sh", stream: Stdout }
StepOutput { symbol: "sh", uuid: 81e8309e-e615-49d4-946c-22527ebce8e1, buffer: "+ pwd", stream: Stdout }
StepOutput { symbol: "sh", uuid: 81e8309e-e615-49d4-946c-22527ebce8e1, buffer: "+ ls -lah", stream: Stdout }
StepEnd { symbol: "sh", uuid: 81e8309e-e615-49d4-946c-22527ebce8e1 }
StepStart { symbol: "echo", uuid: 7f7ec29b-ad62-4fba-9c5f-db7a49a2d658 }
StepOutput { symbol: "echo", uuid: 7f7ec29b-ad62-4fba-9c5f-db7a49a2d658, buffer: "Hello from a block-scoped step!", stream: Stdout }
StepEnd { symbol: "echo", uuid: 7f7ec29b-ad62-4fba-9c5f-db7a49a2d658 }
StepEnd { symbol: "dir", uuid: 022c09ef-15f2-456a-a93a-92e584c1a1f4 }
StepStart { symbol: "sh", uuid: 2265b5d0-1f70-46de-bf50-f1050e9fac9a }
StepOutput { symbol: "sh", uuid: 2265b5d0-1f70-46de-bf50-f1050e9fac9a, buffer: "Hello world from a script", stream: Stdout }
StepOutput { symbol: "sh", uuid: 2265b5d0-1f70-46de-bf50-f1050e9fac9a, buffer: "+ echo \'Hello world from a script\'", stream: Stdout }
StepEnd { symbol: "sh", uuid: 2265b5d0-1f70-46de-bf50-f1050e9fac9a }
---
uuid: '2265b5d0-1f70-46de-bf50-f1050e9fac9a'
contexts:
- name: 'Prep'
uuid: '3ce1f6fb-79ca-4564-a47e-98265f53ef7f'
environment:
CLOUD: 'yes'
- name: 'Build'
uuid: '5e9d4943-33e5-4945-8a97-a11421cb4b11'
steps:
- symbol: sh
uuid: '5599cffb-f23a-4e0f-a0b9-f74654641b2b'
context: '3ce1f6fb-79ca-4564-a47e-98265f53ef7f'
parameters:
script: 'ls -lah | tail -n 5'
# - symbol: error
# uuid: '3652dfe3-a07c-4bd7-b8e5-303100a3873c'
# context: '3ce1f6fb-79ca-4564-a47e-98265f53ef7f'
# parameters:
# message: 'Failing out early'
- symbol: sh
uuid: '2265b5d0-1f70-46de-bf50-f1050e9fac9a'
context: '5e9d4943-33e5-4945-8a97-a11421cb4b11'
parameters:
script: 'echo "Hello world from a script"'
- symbol: dir
uuid: '022c09ef-15f2-456a-a93a-92e584c1a1f4'
context: 'a4cdad98-caf0-4705-ae1f-7986f8a1adf3'
parameters:
directory: 'stdlib'
block:
- symbol: sh
uuid: '81e8309e-e615-49d4-946c-22527ebce8e1'
context: 'a4cdad98-caf0-4705-ae1f-7986f8a1adf3'
parameters:
script: 'pwd && ls -lah'
- symbol: echo
uuid: '7f7ec29b-ad62-4fba-9c5f-db7a49a2d658'
context: 'a4cdad98-caf0-4705-ae1f-7986f8a1adf3'
parameters:
message: 'Hello from a block-scoped step!'
- symbol: sh
uuid: '2265b5d0-1f70-46de-bf50-f1050e9fac9a'
context: '5e9d4943-33e5-4945-8a97-a11421cb4b11'
parameters:
script: 'echo "Hello world from a script"'
- symbol: unknown
context: '5e9d4943-33e5-4945-8a97-a11421cb4b11'
uuid: 'd479e450-9ada-4127-84ca-e0576d0c0c98'
parameters:
message: 'this should fail'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment