-
Notifications
You must be signed in to change notification settings - Fork 33
Dogfood e2etest; Client/Server Application #617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 12 commits
a1eb1aa
3d6b0ae
fabb299
bb886be
dbe7cb9
d02d1fb
ee9fdc8
c1905cb
4a692d9
230f316
fbe198e
2441e91
f6654de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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` | ||
|
||
|
@@ -104,6 +104,13 @@ x | |
You can `kubectl apply -f examples/<disruption.yaml>` for any `example/` disruption files. | ||
For gRPC disruption, you can follow these [detailed steps](../docs/grpc_disruption/demo_instructions.md). | ||
|
||
### 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I dont understand this sentence There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing, let me know if its still confusing after the next commit |
||
the disruptions mentioned. | ||
|
||
### Clean up | ||
|
||
- Run `make uninstall` to `kubectl delete` both charts as well as remove the namespace. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Unless explicitly stated otherwise all files in this repository are licensed | ||
# under the Apache License Version 2.0. | ||
# This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
# Copyright 2022 Datadog, Inc. | ||
|
||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: dogfood-client-pvc | ||
namespace: chaos-demo | ||
spec: | ||
storageClassName: longhorn | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 3Gi |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,11 @@ package main | |
|
||
import ( | ||
"context" | ||
"errors" | ||
"flag" | ||
"fmt" | ||
"log" | ||
"os" | ||
"strconv" | ||
"time" | ||
|
||
|
@@ -56,7 +58,50 @@ func getCatalogWithTimeout(client pb.ChaosDogfoodClient) ([]*pb.CatalogItem, err | |
return res.Items, nil | ||
} | ||
|
||
// regularly order food for different aniamls | ||
func printAndLog(logLine string) { | ||
fmt.Println(logLine) | ||
|
||
go func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused, why do we want to write all this random data to /mnt/data/logging whenever we're trying to print to console? They dont seem to need to be so coupled. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The point of printAndLog is to give the client Write IO. This is the function that will help us test Disk write disruptions properly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know why we want to have the logging done, but why put it in printAndLog? It seems this could be in gothreads that run separately, I don't see why we kick it off once per print There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this spawned from not knowing what data to write to disk at first. I think you can pull random data from somewhere, but I opted to just use the logs that were already in the code as data to write. |
||
f, err := os.OpenFile("/dev/urandom", os.O_RDONLY|os.O_SYNC, 0644) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
logLineBytes := make([]byte, 500000) | ||
|
||
_, err = f.Read(logLineBytes) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
if err = f.Close(); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
if _, err = os.Stat("/mnt/data/logging"); errors.Is(err, os.ErrNotExist) { | ||
f, err = os.Create("/mnt/data/logging") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} else { | ||
f, err = os.OpenFile("/mnt/data/logging", os.O_WRONLY|os.O_SYNC, 0644) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
_, err = f.Write(logLineBytes) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
if err = f.Close(); err != nil { | ||
log.Fatal(err) | ||
} | ||
}() | ||
} | ||
|
||
// regularly order food for different animals | ||
// note: mouse should return error because food for mice is not in the catalog | ||
func sendsLotsOfRequests(client pb.ChaosDogfoodClient) { | ||
animals := []string{"dog", "cat", "mouse"} | ||
|
@@ -66,24 +111,24 @@ func sendsLotsOfRequests(client pb.ChaosDogfoodClient) { | |
|
||
for { | ||
// visually mark a new loop in logs | ||
fmt.Println("x") | ||
printAndLog("x") | ||
|
||
// grab catalog | ||
items, err := getCatalogWithTimeout(client) | ||
if err != nil { | ||
fmt.Printf("| ERROR getting catalog:%v\n", err.Error()) | ||
printAndLog(fmt.Sprintf("| ERROR getting catalog:%v\n", err.Error())) | ||
} | ||
|
||
fmt.Printf("| catalog: %v items returned %s\n", strconv.Itoa(len(items)), stringifyCatalogItems(items)) | ||
printAndLog(fmt.Sprintf("| catalog: %v items returned %s\n", strconv.Itoa(len(items)), stringifyCatalogItems(items))) | ||
time.Sleep(time.Second) | ||
|
||
// make an order | ||
order, err := orderWithTimeout(client, animals[i]) | ||
if err != nil { | ||
fmt.Printf("| ERROR ordering food: %v\n", err.Error()) | ||
printAndLog(fmt.Sprintf("| ERROR ordering food: %v\n", err.Error())) | ||
} | ||
|
||
fmt.Printf("| ordered: %v\n", order) | ||
printAndLog(fmt.Sprintf("| ordered: %v\n", order)) | ||
time.Sleep(time.Second) | ||
|
||
// iterate | ||
|
@@ -106,9 +151,10 @@ func stringifyCatalogItems(items []*pb.CatalogItem) string { | |
|
||
func main() { | ||
// create and eventually close connection | ||
fmt.Printf("connecting to %v...\n", serverAddr) | ||
printAndLog(fmt.Sprintf("connecting to %v...\n", serverAddr)) | ||
|
||
var opts []grpc.DialOption | ||
|
||
opts = append(opts, grpc.WithInsecure()) | ||
opts = append(opts, grpc.WithBlock()) | ||
|
||
|
@@ -126,5 +172,7 @@ func main() { | |
// generate and use client | ||
client := pb.NewChaosDogfoodClient(conn) | ||
|
||
printAndLog("We successfully generated the client, getting ready to send requests") | ||
|
||
sendsLotsOfRequests(client) | ||
} |
Uh oh!
There was an error while loading. Please reload this page.