17
17
package node
18
18
19
19
import (
20
+ "fmt"
20
21
"github.com/chaosblade-io/chaosblade-exec-os/exec"
21
22
"github.com/chaosblade-io/chaosblade-spec-go/spec"
23
+ "strings"
22
24
23
25
"github.com/chaosblade-io/chaosblade-operator/channel"
24
26
"github.com/chaosblade-io/chaosblade-operator/exec/model"
@@ -80,7 +82,7 @@ blade create k8s node-network delay --time 5000 --interface eth0 --exclude-port
80
82
case * exec.DropActionSpec :
81
83
action .SetExample (
82
84
`# Experimental scenario of network shielding
83
- blade create k8s node-network drop --channel ssh --ssh-host 192.168.1.100 --ssh-user root` )
85
+ blade create k8s node-network drop --source-port 80 --network-traffic in -- channel ssh --ssh-host 192.168.1.100 --ssh-user root` )
84
86
case * exec.DnsActionSpec :
85
87
action .SetExample (
86
88
`# The domain name www.baidu.com is not accessible
@@ -156,7 +158,7 @@ blade create k8s node-disk burn --write --path /home --channel ssh --ssh-host 19
156
158
157
159
# Read and write IO load scenarios are performed at the same time. Path is not specified. The default is
158
160
blade create k8s node-disk burn --read --write --channel ssh --ssh-host 192.168.1.100 --ssh-user root` )
159
- case exec.MemCommandModelSpec :
161
+ case * exec.MemLoadActionCommand :
160
162
action .SetLongDesc ("The memory fill experiment scenario in container" )
161
163
action .SetExample (
162
164
`# The execution memory footprint is 50%
@@ -173,6 +175,25 @@ blade create k8s node-mem load --mode ram --mem-percent 50 --timeout 200 --chann
173
175
174
176
# 200M memory is reserved
175
177
blade create k8s node-mem load --mode ram --reserve 200 --rate 100 --channel ssh --ssh-host 192.168.1.100 --ssh-user root` )
178
+ case * exec.ScriptDelayActionCommand :
179
+ action .SetExample (`
180
+ # Add commands to the script "start0() { sleep 10.000000 ...}"
181
+ blade create k8s node-script delay --time 10000 --file test.sh --function-name start0 --channel ssh --ssh-host 192.168.1.100 --ssh-user root` )
182
+ case * exec.ScriptExitActionCommand :
183
+ action .SetExample (`
184
+ # Add commands to the script "start0() { echo this-is-error-message; exit 1; ... }"
185
+ blade create k8s node-script exit --exit-code 1 --exit-message this-is-error-message --file test.sh --function-name start0 --channel ssh --ssh-host 192.168.1.100 --ssh-user root` )
186
+ default :
187
+ action .SetExample (strings .Replace (action .Example (),
188
+ fmt .Sprintf ("blade create %s %s" , expModelSpec .Name (), action .Name ()),
189
+ fmt .Sprintf ("blade create k8s node-%s %s --names nginx-app --channel ssh --ssh-host 192.168.1.100 --ssh-user root" , expModelSpec .Name (), action .Name ()),
190
+ - 1 ,
191
+ ))
192
+ action .SetExample (strings .Replace (action .Example (),
193
+ fmt .Sprintf ("blade c %s %s" , expModelSpec .Name (), action .Name ()),
194
+ fmt .Sprintf ("blade c k8s node-%s %s --names nginx-app --channel ssh --ssh-host 192.168.1.100 --ssh-user root" , expModelSpec .Name (), action .Name ()),
195
+ - 1 ,
196
+ ))
176
197
}
177
198
}
178
199
}
0 commit comments