Skip to content

Commit

Permalink
use ubuntu:jammy, use var/consts where applicable, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Azoam committed Nov 15, 2022
1 parent 2441e91 commit f6654de
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 79 deletions.
6 changes: 3 additions & 3 deletions dogfood/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Installing protoc
# Installing protoc

Run `brew install protobuf` or `make install-protobuf`

Expand Down Expand Up @@ -107,8 +107,8 @@ For gRPC disruption, you can follow these [detailed steps](../docs/grpc_disrupti
### Sending Metrics to Datadog
For the purposes of testing disruptions/workflows, you should make sure that the datadog agent is properly installed
on the cluster that the client and server are running on. 3 of the major disruptive resources properly send metrics
to Datadog (CPU, Network, Disk). The client contains computation related to these disruptions and can be tested using
on the cluster that the client and server are running on. The Datadog Agent should be posting metrics related to CPU,
Network, and Disk which are all necessary to test the related disruptions. The client contains computation related to these disruptions and can be tested using
the disruptions mentioned.
### Clean up
Expand Down
2 changes: 1 addition & 1 deletion dogfood/client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:focal as client
FROM ubuntu:jammy as client

COPY built_go_client /usr/local/bin/dogfood_client

Expand Down
2 changes: 1 addition & 1 deletion dogfood/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:focal as client
FROM ubuntu:jammy as client

COPY built_go_server /usr/local/bin/dogfood_server

Expand Down
2 changes: 1 addition & 1 deletion dogfood/tester/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:focal as client
FROM ubuntu:jammy as client

COPY built_go_client /usr/local/bin/dogfood_tester

Expand Down
132 changes: 59 additions & 73 deletions dogfood/tester/disruptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package main

import (
"fmt"
"github.com/DataDog/chaos-controller/api/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
Expand All @@ -14,30 +15,39 @@ import (
// Globals

var SELECTOR = []string{"app", "chaos-dogfood-client"}
var CONTAINER = "client-deploy"

const CONTAINER = "client-deploy"
const NAMESPACE = "chaos-engineering"
const NAME_PREFIX = "e2etest-"
const DURATION v1beta1.DisruptionDuration = "3m"
const DISK_PRESSURE_PATH = "/mnt/data"

var COUNT = &intstr.IntOrString{Type: intstr.Int, IntVal: 1}
var UNSAFEMODE = &v1beta1.UnsafemodeSpec{
DisableAll: true,
}
var NETWORK_HOST_SPEC = []v1beta1.NetworkDisruptionHostSpec{
{
Host: fmt.Sprintf("chaos-dogfood-server.%s.svc.cluster.local", NAMESPACE),
Port: 50051,
Protocol: "tcp",
},
}

// Network Disruptions
var network1 = v1beta1.Disruption{
ObjectMeta: metav1.ObjectMeta{
Name: "e2etest-network1",
Namespace: "chaos-engineering",
Name: fmt.Sprint(NAME_PREFIX, "network-drop30"),
Namespace: NAMESPACE,
},
Spec: v1beta1.DisruptionSpec{
Count: &intstr.IntOrString{Type: intstr.Int, IntVal: 1},
Unsafemode: &v1beta1.UnsafemodeSpec{
DisableAll: true,
},
Count: COUNT,
Unsafemode: UNSAFEMODE,
Selector: map[string]string{SELECTOR[0]: SELECTOR[1]},
Containers: []string{CONTAINER},
Duration: "3m",
Duration: DURATION,
Network: &v1beta1.NetworkDisruptionSpec{
Hosts: []v1beta1.NetworkDisruptionHostSpec{
{
Host: "chaos-dogfood-server.chaos-demo.svc.cluster.local",
Port: 50051,
Protocol: "tcp",
},
},
Hosts: NETWORK_HOST_SPEC,
Drop: 30,
Corrupt: 0,
Delay: 0,
Expand All @@ -48,25 +58,17 @@ var network1 = v1beta1.Disruption{

var network2 = v1beta1.Disruption{
ObjectMeta: metav1.ObjectMeta{
Name: "e2etest-network2",
Namespace: "chaos-engineering",
Name: fmt.Sprint(NAME_PREFIX, "network-drop70"),
Namespace: NAMESPACE,
},
Spec: v1beta1.DisruptionSpec{
Count: &intstr.IntOrString{Type: intstr.Int, IntVal: 1},
Unsafemode: &v1beta1.UnsafemodeSpec{
DisableAll: true,
},
Count: COUNT,
Unsafemode: UNSAFEMODE,
Selector: map[string]string{SELECTOR[0]: SELECTOR[1]},
Containers: []string{CONTAINER},
Duration: "3m",
Duration: DURATION,
Network: &v1beta1.NetworkDisruptionSpec{
Hosts: []v1beta1.NetworkDisruptionHostSpec{
{
Host: "chaos-dogfood-server.chaos-demo.svc.cluster.local",
Port: 50051,
Protocol: "tcp",
},
},
Hosts: NETWORK_HOST_SPEC,
Drop: 70,
Corrupt: 0,
Delay: 0,
Expand All @@ -77,25 +79,17 @@ var network2 = v1beta1.Disruption{

var network3 = v1beta1.Disruption{
ObjectMeta: metav1.ObjectMeta{
Name: "e2etest-network3",
Namespace: "chaos-engineering",
Name: fmt.Sprint(NAME_PREFIX, "network-delay1000"),
Namespace: NAMESPACE,
},
Spec: v1beta1.DisruptionSpec{
Count: &intstr.IntOrString{Type: intstr.Int, IntVal: 1},
Unsafemode: &v1beta1.UnsafemodeSpec{
DisableAll: true,
},
Count: COUNT,
Unsafemode: UNSAFEMODE,
Selector: map[string]string{SELECTOR[0]: SELECTOR[1]},
Containers: []string{CONTAINER},
Duration: "3m",
Duration: DURATION,
Network: &v1beta1.NetworkDisruptionSpec{
Hosts: []v1beta1.NetworkDisruptionHostSpec{
{
Host: "chaos-dogfood-server.chaos-demo.svc.cluster.local",
Port: 50051,
Protocol: "tcp",
},
},
Hosts: NETWORK_HOST_SPEC,
Drop: 0,
Corrupt: 0,
Delay: 1000,
Expand All @@ -111,19 +105,17 @@ var diskReadsThresholds = []int{1024, 2048, 4098}

var disk1 = v1beta1.Disruption{
ObjectMeta: metav1.ObjectMeta{
Name: "e2etest-disk1",
Namespace: "chaos-engineering",
Name: fmt.Sprint(NAME_PREFIX, "disk-read1024"),
Namespace: NAMESPACE,
},
Spec: v1beta1.DisruptionSpec{
Count: &intstr.IntOrString{Type: intstr.Int, IntVal: 1},
Unsafemode: &v1beta1.UnsafemodeSpec{
DisableAll: true,
},
Count: COUNT,
Unsafemode: UNSAFEMODE,
Selector: map[string]string{SELECTOR[0]: SELECTOR[1]},
Containers: []string{CONTAINER},
Duration: "3m",
Duration: DURATION,
DiskPressure: &v1beta1.DiskPressureSpec{
Path: "/mnt/data",
Path: DISK_PRESSURE_PATH,
Throttling: v1beta1.DiskPressureThrottlingSpec{
ReadBytesPerSec: &diskReadsThresholds[0],
},
Expand All @@ -133,19 +125,17 @@ var disk1 = v1beta1.Disruption{

var disk2 = v1beta1.Disruption{
ObjectMeta: metav1.ObjectMeta{
Name: "e2etest-disk2",
Namespace: "chaos-engineering",
Name: fmt.Sprint(NAME_PREFIX, "disk-write2048"),
Namespace: NAMESPACE,
},
Spec: v1beta1.DisruptionSpec{
Count: &intstr.IntOrString{Type: intstr.Int, IntVal: 1},
Unsafemode: &v1beta1.UnsafemodeSpec{
DisableAll: true,
},
Count: COUNT,
Unsafemode: UNSAFEMODE,
Selector: map[string]string{SELECTOR[0]: SELECTOR[1]},
Containers: []string{CONTAINER},
Duration: "3m",
Duration: DURATION,
DiskPressure: &v1beta1.DiskPressureSpec{
Path: "/mnt/data",
Path: DISK_PRESSURE_PATH,
Throttling: v1beta1.DiskPressureThrottlingSpec{
WriteBytesPerSec: &diskReadsThresholds[1],
},
Expand All @@ -155,17 +145,15 @@ var disk2 = v1beta1.Disruption{

var disk3 = v1beta1.Disruption{
ObjectMeta: metav1.ObjectMeta{
Name: "e2etest-disk3",
Namespace: "chaos-engineering",
Name: fmt.Sprint(NAME_PREFIX, "disk-write4098"),
Namespace: NAMESPACE,
},
Spec: v1beta1.DisruptionSpec{
Count: &intstr.IntOrString{Type: intstr.Int, IntVal: 1},
Unsafemode: &v1beta1.UnsafemodeSpec{
DisableAll: true,
},
Count: COUNT,
Unsafemode: UNSAFEMODE,
Selector: map[string]string{SELECTOR[0]: SELECTOR[1]},
Containers: []string{CONTAINER},
Duration: "3m",
Duration: DURATION,
DiskPressure: &v1beta1.DiskPressureSpec{
Path: "/mnt/data",
Throttling: v1beta1.DiskPressureThrottlingSpec{
Expand All @@ -181,17 +169,15 @@ var DISK_DISRUPTIONS = []v1beta1.Disruption{disk1, disk2, disk3}

var cpu1 = v1beta1.Disruption{
ObjectMeta: metav1.ObjectMeta{
Name: "e2etest-cpu1",
Namespace: "chaos-engineering",
Name: fmt.Sprint(NAME_PREFIX, "cpu-cores4"),
Namespace: NAMESPACE,
},
Spec: v1beta1.DisruptionSpec{
Count: &intstr.IntOrString{Type: intstr.Int, IntVal: 1},
Unsafemode: &v1beta1.UnsafemodeSpec{
DisableAll: true,
},
Count: COUNT,
Unsafemode: UNSAFEMODE,
Selector: map[string]string{SELECTOR[0]: SELECTOR[1]},
Containers: []string{CONTAINER},
Duration: "3m",
Duration: DURATION,
CPUPressure: &v1beta1.CPUPressureSpec{
Count: &intstr.IntOrString{IntVal: 4},
},
Expand Down

0 comments on commit f6654de

Please sign in to comment.