Skip to content

Commit 21cbd87

Browse files
committed
feature: improvement use case
Signed-off-by: tiny.x <[email protected]>
1 parent 53f1d72 commit 21cbd87

File tree

6 files changed

+182
-94
lines changed

6 files changed

+182
-94
lines changed

exec/container/container.go

Lines changed: 76 additions & 50 deletions
Large diffs are not rendered by default.

exec/node/node.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
package node
1818

1919
import (
20+
"fmt"
2021
"github.com/chaosblade-io/chaosblade-exec-os/exec"
2122
"github.com/chaosblade-io/chaosblade-spec-go/spec"
23+
"strings"
2224

2325
"github.com/chaosblade-io/chaosblade-operator/channel"
2426
"github.com/chaosblade-io/chaosblade-operator/exec/model"
@@ -80,7 +82,7 @@ blade create k8s node-network delay --time 5000 --interface eth0 --exclude-port
8082
case *exec.DropActionSpec:
8183
action.SetExample(
8284
`# 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`)
8486
case *exec.DnsActionSpec:
8587
action.SetExample(
8688
`# 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
156158
157159
# Read and write IO load scenarios are performed at the same time. Path is not specified. The default is
158160
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:
160162
action.SetLongDesc("The memory fill experiment scenario in container")
161163
action.SetExample(
162164
`# The execution memory footprint is 50%
@@ -173,6 +175,25 @@ blade create k8s node-mem load --mode ram --mem-percent 50 --timeout 200 --chann
173175
174176
# 200M memory is reserved
175177
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+
))
176197
}
177198
}
178199
}

exec/pod/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func NewDeletePodActionSpec(client *channel.Client) spec.ExpActionCommandSpec {
4949
ActionExecutor: &DeletePodActionExecutor{client: client},
5050
ActionExample:
5151
`# Deletes the POD under the specified default namespace that is app=guestbook
52-
blade create k8s pod-pod delete --labels app=guestbook --namespace default --evict-count 2 --kubeconfig config`,
52+
blade create k8s pod-pod delete --labels app=guestbook --namespace default --evict-count 2 --kubeconfig ~/.kube/config`,
5353
},
5454
}
5555
}

0 commit comments

Comments
 (0)