From 83b6036e0925cfdecdd67e426b1ea5211a5e01f0 Mon Sep 17 00:00:00 2001
From: Pawel Wieczorek
Date: Mon, 18 Dec 2017 19:14:35 +0100
Subject: [PATCH] DEMO: play & scenarios
Change-Id: I2d9adea644b7152863e0d3e696e199728ed14f56
---
Makefile | 17 ++++++++++-------
demo/demo.sh | 31 +++++++++++++++++++++++++++++++
demo/dtl/echo_foo.sh | 2 ++
demo/mini.yml | 11 ++---------
demo/nonex-artifact.yml | 16 ++++++++++++++++
demo/nonex-device.yml | 15 +++++++++++++++
demo/parallel.yml | 15 +++++++++++++++
demo/parts.yml | 22 ++++++++++++++++++++++
demo/pull.yml | 16 ++++++++++++++++
demo/push.yml | 17 +++++++++++++++++
demo/script.yml | 21 +++++++++++++++++++++
demo/wrong-param.yml | 15 +++++++++++++++
12 files changed, 182 insertions(+), 16 deletions(-)
create mode 100644 demo/demo.sh
create mode 100644 demo/dtl/echo_foo.sh
create mode 100644 demo/nonex-artifact.yml
create mode 100644 demo/nonex-device.yml
create mode 100644 demo/parallel.yml
create mode 100644 demo/parts.yml
create mode 100644 demo/pull.yml
create mode 100644 demo/push.yml
create mode 100644 demo/script.yml
create mode 100644 demo/wrong-param.yml
diff --git a/Makefile b/Makefile
index 24c1e4f..db93c0c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,20 +1,23 @@
BORUTA=localhost:8080
WELES=localhost:5010
+WELES_DB=/tmp/weles
+DATA_SRV=demo/dtl
+DATA_SRV_PORT=9090
-.PHONY: build run watch minitest clean
+.PHONY: build run watch serve clean
build:
- mkdir -p /tmp/weles/
+ mkdir -p ${WELES_DB}
go build cmd/main.go
run:
./main -borutaAddress http://${BORUTA}
-watch:
- watch -n1 "tree /tmp/weles"
+serve:
+ cd ${DATA_SRV} && python -m SimpleHTTPServer ${DATA_SRV_PORT}
-minitest:
- curl -L ${WELES}/api/v1/jobs/ -F "uploadfile=@demo/mini.yml;type=application/octet-stream" -vvv
+watch:
+ watch -n1 "tree -r ${WELES_DB}"
clean:
- rm -r /tmp/weles
+ rm -r ${WELES_DB}
diff --git a/demo/demo.sh b/demo/demo.sh
new file mode 100644
index 0000000..533041e
--- /dev/null
+++ b/demo/demo.sh
@@ -0,0 +1,31 @@
+#doitlive speed: 2
+#doitlive commentecho: true
+
+export TYPE='type=application/octet-stream'
+cd demo
+
+#minimal job definition
+cat mini.yml
+curl -sL localhost:5010/api/v1/jobs/ -F "uploadfile=@demo/mini.yml;$TYPE"
+
+#pull file from target
+cat pull.yml
+curl -sL localhost:5010/api/v1/jobs/ -F "uploadfile=@demo/pull.yml;$TYPE"
+
+#push file to target
+cat push.yml
+curl -sL localhost:5010/api/v1/jobs/ -F "uploadfile=@demo/push.yml;$TYPE"
+
+#run pushed script on the target
+colordiff push.yml script.yml
+curl -sL localhost:5010/api/v1/jobs/ -F "uploadfile=@demo/script.yml;$TYPE"
+
+#run jobs in parallel
+for JOB in `seq 1 3`; do curl -sL localhost:5010/api/v1/jobs/ -F "uploadfile=@demo/parallel.yml;$TYPE" | jq '.jobid' | tee -a jobids; done
+
+#cancel no longer necessary jobs
+while read JOBID; do curl -sL -X POST "localhost:5010/api/v1/jobs/${JOBID}/cancel"; done < jobids
+
+#flash only necessary partitions
+colordiff mini.yml parts.yml
+curl -sL localhost:5010/api/v1/jobs/ -F "uploadfile=@demo/parts.yml;$TYPE"
diff --git a/demo/dtl/echo_foo.sh b/demo/dtl/echo_foo.sh
new file mode 100644
index 0000000..32b5fd0
--- /dev/null
+++ b/demo/dtl/echo_foo.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo 'foo'
diff --git a/demo/mini.yml b/demo/mini.yml
index 83c5816..34f5dae 100644
--- a/demo/mini.yml
+++ b/demo/mini.yml
@@ -3,20 +3,13 @@ job_name: rpi3-mini
priority: medium
actions:
- - deploy:
- images:
- - uri: http:///tizen-unified_iot-boot-arm64-rpi3.tar.gz
- compression: gz
- partition_layout:
- - id: 1
- image_name: boot.img
- boot:
login: root
password: tizen
- test:
- name: rpi3-basic
+ name: check-kernel
test_cases:
- - case_name: check-kernel
+ - case_name: uname
test_actions:
- run:
name: uname -a
diff --git a/demo/nonex-artifact.yml b/demo/nonex-artifact.yml
new file mode 100644
index 0000000..57e2f28
--- /dev/null
+++ b/demo/nonex-artifact.yml
@@ -0,0 +1,16 @@
+device_type: odroid_u3
+job_name: odroid-push-nonex
+priority: medium
+
+actions:
+ - boot:
+ login: root
+ password: tizen
+ - test:
+ name: push-bar
+ test_cases:
+ - case_name: put-echo_bar.sh
+ test_actions:
+ - push:
+ uri: http://localhost:9090/echo_bar.sh
+ dest: /tmp
diff --git a/demo/nonex-device.yml b/demo/nonex-device.yml
new file mode 100644
index 0000000..99cf24c
--- /dev/null
+++ b/demo/nonex-device.yml
@@ -0,0 +1,15 @@
+device_type: note8
+job_name: note8-mini
+priority: medium
+
+actions:
+ - boot:
+ login: root
+ password: toor
+ - test:
+ name: check-kernel
+ test_cases:
+ - case_name: uname
+ test_actions:
+ - run:
+ name: uname -a
diff --git a/demo/parallel.yml b/demo/parallel.yml
new file mode 100644
index 0000000..7aa22d3
--- /dev/null
+++ b/demo/parallel.yml
@@ -0,0 +1,15 @@
+device_type: rpi3
+job_name: rpi3-parallel
+priority: low
+
+actions:
+ - boot:
+ login: root
+ password: tizen
+ - test:
+ name: run-sleep
+ test_cases:
+ - case_name: sleep5
+ test_actions:
+ - run:
+ name: sleep $((5 * 60))
diff --git a/demo/parts.yml b/demo/parts.yml
new file mode 100644
index 0000000..076e223
--- /dev/null
+++ b/demo/parts.yml
@@ -0,0 +1,22 @@
+device_type: rpi3
+job_name: rpi3-selected-parts
+priority: medium
+
+actions:
+ - deploy:
+ images:
+ - uri: http://localhost:9090/tizen-unified_20171218.2_iot-boot-arm64-rpi3.tar.gz
+ compression: gz
+ partition_layout:
+ - id: 1
+ image_name: boot.img
+ - boot:
+ login: root
+ password: tizen
+ - test:
+ name: check-kernel
+ test_cases:
+ - case_name: uname
+ test_actions:
+ - run:
+ name: uname -a
diff --git a/demo/pull.yml b/demo/pull.yml
new file mode 100644
index 0000000..3d43094
--- /dev/null
+++ b/demo/pull.yml
@@ -0,0 +1,16 @@
+device_type: odroid_u3
+job_name: odroid-pull
+priority: medium
+
+actions:
+ - boot:
+ login: root
+ password: tizen
+ - test:
+ name: pull-info
+ test_cases:
+ - case_name: get-info.ini
+ test_actions:
+ - pull:
+ src: /etc/info.ini
+ alias: info.ini
diff --git a/demo/push.yml b/demo/push.yml
new file mode 100644
index 0000000..b5ef071
--- /dev/null
+++ b/demo/push.yml
@@ -0,0 +1,17 @@
+device_type: odroid_u3
+job_name: odroid-push
+priority: medium
+
+actions:
+ - boot:
+ login: root
+ password: tizen
+ - test:
+ name: push-foo
+ test_cases:
+ - case_name: put-echo_foo.sh
+ test_actions:
+ - push:
+ uri: http://localhost:9090/echo_foo.sh
+ dest: /tmp
+ alias: echo_foo.sh
diff --git a/demo/script.yml b/demo/script.yml
new file mode 100644
index 0000000..61aede8
--- /dev/null
+++ b/demo/script.yml
@@ -0,0 +1,21 @@
+device_type: odroid_u3
+job_name: odroid-script
+priority: medium
+
+actions:
+ - boot:
+ login: root
+ password: tizen
+ - test:
+ name: run-foo
+ test_cases:
+ - case_name: exec-echo_foo.sh
+ test_actions:
+ - push:
+ uri: http://localhost:9090/echo_foo.sh
+ dest: /tmp
+ alias: echo_foo.sh
+ - run:
+ name: mv /tmp/echo_foo.sh\* /tmp/echo_foo.sh
+ - run:
+ name: sh /tmp/echo_foo.sh
diff --git a/demo/wrong-param.yml b/demo/wrong-param.yml
new file mode 100644
index 0000000..37e81ec
--- /dev/null
+++ b/demo/wrong-param.yml
@@ -0,0 +1,15 @@
+device_type: rpi3
+job_name: rpi3-mini
+priority: highest
+
+actions:
+ - boot:
+ login: root
+ password: tizen
+ - test:
+ name: check-kernel
+ test_cases:
+ - case_name: uname
+ test_actions:
+ - run:
+ name: uname -a
--
2.7.4