Skip to content

Commit f38abca

Browse files
authored
add corrupt and loss chaos actions (#1784)
* add corrupt and loss chaos actions, update to testcontainers-go v0.36.0 * changeset * re-trigger * retract tag, merge
1 parent 6c5389a commit f38abca

File tree

7 files changed

+170
-51
lines changed

7 files changed

+170
-51
lines changed

framework/examples/myproject/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
1515
github.com/ethereum/go-ethereum v1.15.0
1616
github.com/go-resty/resty/v2 v2.16.3
17-
github.com/smartcontractkit/chainlink-testing-framework/framework v0.7.3
17+
github.com/smartcontractkit/chainlink-testing-framework/framework v0.7.4
1818
github.com/smartcontractkit/chainlink-testing-framework/havoc v1.50.2
1919
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.10
2020
github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.2

havoc/.changeset/v1.50.6.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Added and verified with Kind two new havoc actions - corrupt and loss for NetworkChaos

havoc/.changeset/v1.50.7.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Added and verified with Kind two new havoc actions - corrupt and loss for NetworkChaos

havoc/go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,5 @@ require (
7878
)
7979

8080
retract [v1.999.0-test-release, v1.999.999-test-release]
81+
82+
retract v1.50.6

havoc/template.go

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,125 @@ func (cr *NamespaceScopedChaosRunner) RunPodStressCPU(ctx context.Context, cfg N
308308
experiment.Create(ctx)
309309
return experiment, nil
310310
}
311+
312+
type PodCorruptCfg struct {
313+
Namespace string
314+
Description string
315+
Corrupt string
316+
Correlation string
317+
LabelKey string
318+
LabelValues []string
319+
InjectionDuration time.Duration
320+
ExperimentCreateDelay time.Duration
321+
}
322+
323+
// RunPodCorrupt initiates packet corruption for some pod in some namespace
324+
func (cr *NamespaceScopedChaosRunner) RunPodCorrupt(ctx context.Context, cfg PodCorruptCfg) (*Chaos, error) {
325+
experiment, err := NewChaos(ChaosOpts{
326+
Object: &v1alpha1.NetworkChaos{
327+
TypeMeta: metav1.TypeMeta{
328+
Kind: string(v1alpha1.TypeNetworkChaos),
329+
APIVersion: "chaos-mesh.org/v1alpha1",
330+
},
331+
ObjectMeta: metav1.ObjectMeta{
332+
Name: fmt.Sprintf("corrupt-%s", uuid.NewString()[0:5]),
333+
Namespace: cfg.Namespace,
334+
},
335+
Spec: v1alpha1.NetworkChaosSpec{
336+
Action: v1alpha1.CorruptAction,
337+
Duration: ptr.To[string]((cfg.InjectionDuration).String()),
338+
TcParameter: v1alpha1.TcParameter{
339+
Corrupt: &v1alpha1.CorruptSpec{
340+
Corrupt: cfg.Corrupt,
341+
Correlation: cfg.Correlation,
342+
},
343+
},
344+
PodSelector: v1alpha1.PodSelector{
345+
Mode: v1alpha1.AllMode,
346+
Selector: v1alpha1.PodSelectorSpec{
347+
GenericSelectorSpec: v1alpha1.GenericSelectorSpec{
348+
Namespaces: []string{cfg.Namespace},
349+
ExpressionSelectors: v1alpha1.LabelSelectorRequirements{
350+
{
351+
Operator: "In",
352+
Key: cfg.LabelKey,
353+
Values: cfg.LabelValues,
354+
},
355+
},
356+
},
357+
},
358+
},
359+
},
360+
},
361+
Listeners: defaultListeners(cr.l),
362+
Logger: &cr.l,
363+
Client: cr.c,
364+
Remove: cr.remove,
365+
})
366+
if err != nil {
367+
return nil, err
368+
}
369+
experiment.Create(ctx)
370+
return experiment, nil
371+
}
372+
373+
type PodLossCfg struct {
374+
Namespace string
375+
Description string
376+
Loss string
377+
Correlation string
378+
LabelKey string
379+
LabelValues []string
380+
InjectionDuration time.Duration
381+
ExperimentCreateDelay time.Duration
382+
}
383+
384+
// RunPodLoss initiates packet loss for some pod in some namespace
385+
func (cr *NamespaceScopedChaosRunner) RunPodLoss(ctx context.Context, cfg PodLossCfg) (*Chaos, error) {
386+
experiment, err := NewChaos(ChaosOpts{
387+
Object: &v1alpha1.NetworkChaos{
388+
TypeMeta: metav1.TypeMeta{
389+
Kind: string(v1alpha1.TypeNetworkChaos),
390+
APIVersion: "chaos-mesh.org/v1alpha1",
391+
},
392+
ObjectMeta: metav1.ObjectMeta{
393+
Name: fmt.Sprintf("loss-%s", uuid.NewString()[0:5]),
394+
Namespace: cfg.Namespace,
395+
},
396+
Spec: v1alpha1.NetworkChaosSpec{
397+
Action: v1alpha1.CorruptAction,
398+
Duration: ptr.To[string]((cfg.InjectionDuration).String()),
399+
TcParameter: v1alpha1.TcParameter{
400+
Loss: &v1alpha1.LossSpec{
401+
Loss: cfg.Loss,
402+
Correlation: cfg.Correlation,
403+
},
404+
},
405+
PodSelector: v1alpha1.PodSelector{
406+
Mode: v1alpha1.AllMode,
407+
Selector: v1alpha1.PodSelectorSpec{
408+
GenericSelectorSpec: v1alpha1.GenericSelectorSpec{
409+
Namespaces: []string{cfg.Namespace},
410+
ExpressionSelectors: v1alpha1.LabelSelectorRequirements{
411+
{
412+
Operator: "In",
413+
Key: cfg.LabelKey,
414+
Values: cfg.LabelValues,
415+
},
416+
},
417+
},
418+
},
419+
},
420+
},
421+
},
422+
Listeners: defaultListeners(cr.l),
423+
Logger: &cr.l,
424+
Client: cr.c,
425+
Remove: cr.remove,
426+
})
427+
if err != nil {
428+
return nil, err
429+
}
430+
experiment.Create(ctx)
431+
return experiment, nil
432+
}

sentinel/go.mod

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/ethereum/go-ethereum v1.14.11
77
github.com/rs/zerolog v1.33.0
88
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.20-0.20250106135623-15722ca32b64
9-
github.com/stretchr/testify v1.9.0
9+
github.com/stretchr/testify v1.10.0
1010
)
1111

1212
require (
@@ -27,9 +27,10 @@ require (
2727
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
2828
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
2929
github.com/distribution/reference v0.6.0 // indirect
30-
github.com/docker/docker v27.3.1+incompatible // indirect
30+
github.com/docker/docker v28.0.1+incompatible // indirect
3131
github.com/docker/go-connections v0.5.0 // indirect
3232
github.com/docker/go-units v0.5.0 // indirect
33+
github.com/ebitengine/purego v0.8.2 // indirect
3334
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
3435
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect
3536
github.com/felixge/httpsnoop v1.0.4 // indirect
@@ -42,7 +43,7 @@ require (
4243
github.com/holiman/uint256 v1.3.1 // indirect
4344
github.com/klauspost/compress v1.17.9 // indirect
4445
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
45-
github.com/magiconair/properties v1.8.7 // indirect
46+
github.com/magiconair/properties v1.8.9 // indirect
4647
github.com/mattn/go-colorable v0.1.13 // indirect
4748
github.com/mattn/go-isatty v0.0.20 // indirect
4849
github.com/mmcloughlin/addchain v0.4.0 // indirect
@@ -54,32 +55,31 @@ require (
5455
github.com/moby/term v0.5.0 // indirect
5556
github.com/morikuni/aec v1.0.0 // indirect
5657
github.com/opencontainers/go-digest v1.0.0 // indirect
57-
github.com/opencontainers/image-spec v1.1.0 // indirect
58+
github.com/opencontainers/image-spec v1.1.1 // indirect
5859
github.com/pkg/errors v0.9.1 // indirect
5960
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
6061
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
6162
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
62-
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
63-
github.com/shoenig/go-m1cpu v0.1.6 // indirect
63+
github.com/shirou/gopsutil/v4 v4.25.1 // indirect
6464
github.com/sirupsen/logrus v1.9.3 // indirect
6565
github.com/stretchr/objx v0.5.2 // indirect
6666
github.com/supranational/blst v0.3.13 // indirect
67-
github.com/testcontainers/testcontainers-go v0.34.0 // indirect
67+
github.com/testcontainers/testcontainers-go v0.36.0 // indirect
6868
github.com/tklauser/go-sysconf v0.3.12 // indirect
6969
github.com/tklauser/numcpus v0.6.1 // indirect
7070
github.com/urfave/cli/v2 v2.27.5 // indirect
71-
github.com/yusufpapurcu/wmi v1.2.3 // indirect
71+
github.com/yusufpapurcu/wmi v1.2.4 // indirect
72+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
7273
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
73-
go.opentelemetry.io/otel v1.28.0 // indirect
74+
go.opentelemetry.io/otel v1.35.0 // indirect
7475
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect
75-
go.opentelemetry.io/otel/metric v1.28.0 // indirect
76-
go.opentelemetry.io/otel/sdk v1.19.0 // indirect
77-
go.opentelemetry.io/otel/trace v1.28.0 // indirect
76+
go.opentelemetry.io/otel/metric v1.35.0 // indirect
77+
go.opentelemetry.io/otel/trace v1.35.0 // indirect
7878
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
7979
golang.org/x/crypto v0.32.0 // indirect
8080
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
8181
golang.org/x/sync v0.8.0 // indirect
82-
golang.org/x/sys v0.29.0 // indirect
82+
golang.org/x/sys v0.31.0 // indirect
8383
gopkg.in/yaml.v3 v3.0.1 // indirect
8484
rsc.io/tmplfunc v0.0.3 // indirect
8585
)

0 commit comments

Comments
 (0)