Skip to content

Commit

Permalink
switch to chaosd clock attack
Browse files Browse the repository at this point in the history
  • Loading branch information
ecordell committed Mar 17, 2022
1 parent c74e2e3 commit 4eb10f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,7 @@ jobs:
working-directory: "e2e/newenemy"
run: |
curl https://binaries.cockroachdb.com/cockroach-v21.2.7.linux-amd64.tgz | tar -xz && mv cockroach-v21.2.7.linux-amd64/cockroach ./cockroach
curl -fsSL https://mirrors.chaos-mesh.org/chaosd-v1.0.2-linux-amd64.tar.gz | tar -xz && mv chaosd-v1.0.2-linux-amd64/chaosd ./chaosd
# chaosd doesn't yet include time modification, install it separately
git clone https://github.com/chaos-mesh/chaos-mesh/
pushd chaos-mesh
git reset --hard 72d2bc17febc7f2a4a10c97417f11c5eb1d86a13
CGO_ENABLED=1 go build ./cmd/watchmaker/
popd
mv ./chaos-mesh/watchmaker ./watchmaker
curl -fsSL https://mirrors.chaos-mesh.org/chaosd-v1.1.1-linux-amd64.tar.gz | tar -xz && mv chaosd-v1.1.1-linux-amd64/chaosd ./chaosd
- uses: "actions/cache@v2"
with:
path: |
Expand Down
16 changes: 5 additions & 11 deletions e2e/cockroach/cockroach.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,19 +180,13 @@ func (cs Cluster) NetworkDelay(ctx context.Context, out io.Writer, node int, dur

// TimeDelay adds a skew to the clock of the given node
func (cs Cluster) TimeDelay(ctx context.Context, out io.Writer, node int, duration time.Duration) error {
sec, nsec := secAndNSecFromDuration(duration)
return e2e.Run(ctx, out, out,
"sudo",
"./watchmaker",
"./chaosd",
"attack",
"clock",
fmt.Sprintf("--pid=%d", cs[node].pid),
fmt.Sprintf("--sec_delta=%d", sec),
fmt.Sprintf("--nsec_delta=%d", nsec),
"--clk_ids=CLOCK_REALTIME,CLOCK_MONOTONIC",
fmt.Sprintf("--time-offset=%s", duration),
"--clock-ids-slice=CLOCK_REALTIME,CLOCK_MONOTONIC",
)
}

func secAndNSecFromDuration(duration time.Duration) (sec int64, nsec int64) {
sec = duration.Nanoseconds() / 1e9
nsec = duration.Nanoseconds() - (sec * 1e9)
return
}

0 comments on commit 4eb10f5

Please sign in to comment.