Skip to content

Commit

Permalink
added region and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ohuu committed Nov 10, 2024
1 parent 1c5ce40 commit d425285
Show file tree
Hide file tree
Showing 24 changed files with 596 additions and 161 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ http = "1.1.0"
itertools = "0.13.0"
mime_guess = { version = "2.0.5" }
num_cpus = "1.16.0"
phf = { version = "0.11", features = ["macros"] }
reqwest = { version = "0.12.7", features = ["json"] }
rust-embed = "8.5.0"
sea-orm = { version = "1.0.0", features = [
Expand Down
68 changes: 68 additions & 0 deletions cardamon.bk.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# CPU
# ########################################
[cpu]
name = "AMD Ryzen 7 PRO 6850U with Radeon Graphics"
curve = [
7.627190097500079,
0.07551567953624883,
20.45110313049153,
-1.5261422759740344,
]

# Processes
# ########################################
[[process]]
name = "rand-api"
up = "./rand-api"
down = "kill {pid}"
redirect.to = "file"
process.type = "baremetal"

[[process]]
name = "rand-api-docker"
up = "docker run -d --name c1 -p 4244:4243 rand-api"
down = "bash -c 'docker stop c1 && docker rm c1'"
redirect.to = "file"
process.type = "docker"
process.containers = ["c1"]

# Scenarios
# ########################################
[[scenario]]
name = "stress"
desc = ""
command = "sh scenario.sh"
iterations = 2
processes = ["rand-api", "rand-api-docker"]

[[scenario]]
name = "stress_metal"
desc = ""
command = "sh scenario.sh"
iterations = 2
processes = ["rand-api"]

[[scenario]]
name = "stress_docker"
desc = ""
command = "sh scenario.sh"
iterations = 2
processes = ["rand-api-docker"]

# Observations
# ########################################
[[observation]]
name = "stress"
scenarios = ["stress"]

[[observation]]
name = "stress_metal"
scenarios = ["stress_metal"]

[[observation]]
name = "stress_docker"
scenarios = ["stress_docker"]

[[observation]]
name = "live_monitor"
processes = ["test_proc1", "test_proc2"]
174 changes: 122 additions & 52 deletions cardamon.toml
Original file line number Diff line number Diff line change
@@ -1,68 +1,138 @@
# CPU
# ########################################
[cpu]
name = "AMD Ryzen 7 PRO 6850U with Radeon Graphics"
curve = [
7.627190097500079,
0.07551567953624883,
20.45110313049153,
-1.5261422759740344,
]
curve = [7.627190097500079,0.07551567953624883,20.45110313049153,-1.5261422759740344]

# Processes
# ########################################
# ---------
# This array of tables describes the components of your application that you
# would like cardamon to measure.
#
# processes contain the following properties:
# name:
# type - string
# desc - must be unique
# required - true
#
# up:
# type - string
# desc - command to execute the processes
# required - true
#
# down:
# type - string
# desc - command to stop the process. In the case of bare-metal processes
# cardamon will pass the PID of the process to this command. You can
# use `{pid}` as a placeholder in the command e.g. `kill {pid}`.
# default: empty string
# required - false
#
# proccess.type:
# type - "baremetal" | "docker"
# desc - the type of process which is being executed
# required - true
#
# process.containers:
# type - string[]
# desc - docker processes may initiate multiple containers from a single
# command, e.g. `docker compose up -d`. This is the list of
# containers started by this process you would like cardamon to
# measure.
# required - true (if `process.type` is "docker")
#
# redirect.to:
# type - "null" | "parent" | "file"
# desc - where to redirect this processes stdout and stderr. "null" ignores
# output, "parent" attaches the processes output to cardamon, "file"
# writes stdout and stderr to a file of the same name as this
# process e.g. db.stdout.
# default: "file"
# required - false
#
# EXAMPLE
# -------
# [[process]]
# name = "db"
# up = "docker compose up -d"
# down = "docker compose down"
# redirect.to = "file"
# process.type = "docker"
# process.containers = ["postgres"]

[[process]]
name = "rand-api"
up = "./rand-api"
name = "test_proc"
up = "bash -c \"while true; do shuf -i 0-1337 -n 1; done\""
down = "kill {pid}"
redirect.to = "file"
process.type = "baremetal"

[[process]]
name = "rand-api-docker"
up = "docker run -d --name c1 -p 4244:4243 rand-api"
down = "bash -c 'docker stop c1 && docker rm c1'"
redirect.to = "file"
process.type = "docker"
process.containers = ["c1"]

# Scenarios
# ########################################
# ---------
# This array of tables describes the scenarios that cardamon can run. They can
# be any kind of executable and are designed to place your application under
# consistent load each time they are run. Examples include bash scripts which
# `curl` a REST endpoint or nodejs scripts using playwright.js to control a
# webpage.
#
# scenarios contain the following properties:
# name:
# type - string
# desc - must be unique
# required - true
#
# desc:
# type - string
# desc - a short description of the scenario to remind you what it does
# required - false
#
# command:
# type - string
# desc - the command to execute this scenario
# required - true
#
# iterations:
# type - integer
# desc - the number of times cardamon should execute this scenario per run.
# It's better to run scenarios multiple times and take an average.
# default - 1
# required - false
#
# processes:
# type - string[]
# desc - a list of the processes which need to be started before executing
# this scenario.
# required - true
#
[[scenario]]
name = "stress"
desc = ""
command = "sh scenario.sh"
name = "sleep"
desc = "Sleeps for 10 seconds, a real scenario would call your app"
command = "sleep 10"
iterations = 2
processes = ["rand-api", "rand-api-docker"]
processes = ["test_proc"]

[[scenario]]
name = "stress_metal"
desc = ""
command = "sh scenario.sh"
iterations = 2
processes = ["rand-api"]

[[scenario]]
name = "stress_docker"
desc = ""
command = "sh scenario.sh"
iterations = 2
processes = ["rand-api-docker"]

# Observations
# ########################################
[[observation]]
name = "stress"
scenarios = ["stress"]

[[observation]]
name = "stress_metal"
scenarios = ["stress_metal"]

[[observation]]
name = "stress_docker"
scenarios = ["stress_docker"]

# ---------------
# This array of tables allows you to group scenarios together to make it
# easier to execute multiple scenarios in a single run.
#
# obserations contain the following properties:
# name:
# type - string
# desc - a unique name
# required - true
#
# observe.scenarios:
# type - string[]
# desc - a list of scenarios to execute whilst observing the processes
# required to run all scenarios
# required - required if observe.processes is not defined
#
# observe.processes:
# type - string[]
# desc - a list of processes to execute and observe. Running an observation
# with this property set runs Cardamon in Live mode.
# required - required if observe.scenarios is not defined.
#
[[observation]]
name = "live_monitor"
processes = ["test_proc1", "test_proc2"]
name = "test_obs"
scenarios = ["sleep"]
8 changes: 4 additions & 4 deletions fixtures/runs.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DELETE FROM run;

INSERT INTO run (id, is_live, cpu_id, start_time, stop_time)
INSERT INTO run (id, is_live, cpu_id, region, start_time, stop_time)
VALUES
(1, false, 1, 1717507590000, 1717507601000),
(2, false, 1, 1717507690000, 1717507699000),
(3, false, 1, 1717507790000, 1717507795000);
(1, false, 1, 'GB', 1717507590000, 1717507601000),
(2, false, 1, 'GB', 1717507690000, 1717507699000),
(3, false, 1, 'GB', 1717507790000, 1717507795000);
Loading

0 comments on commit d425285

Please sign in to comment.