Skip to content

Commit

Permalink
Add support for coverage of RUST and GO binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
fnikol committed Dec 6, 2021
1 parent a387f49 commit 9bb919c
Show file tree
Hide file tree
Showing 11 changed files with 518 additions and 8 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
$(KUSTOMIZE) build config/default | kubectl delete -f -



release: ## Release a new version of Frisbee.
if [[ -z "${VERSION}" ]]; then echo "VERSION is not set"; exit 1; fi
echo "${VERSION}" > VERSION
Expand Down
153 changes: 153 additions & 0 deletions charts/tikv/examples/plan.baseline.coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: coverage-ingress
spec:
rules:
- host: master.platform.science-hangar.eu
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: master
port:
number: 80

- host: worker0.platform.science-hangar.eu
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: workers-0
port:
number: 80

- host: worker1.platform.science-hangar.eu
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: worker1
port:
number: 80

---
apiVersion: frisbee.io/v1alpha1
kind: Workflow
metadata:
name: tikv-baseline
spec:
withTelemetry:
importMonitors: [ "platform.telemetry.container", "ycsb.telemetry.client", "tikv.telemetry.pd", "tikv.telemetry.worker" ]

actions:
# Step 0: bootstrap.
# For TiKV, we must first create a placementDriver and then add the workers.
- action: Service
name: master
service:
fromTemplate:
templateRef: tikv.cluster.coverage.placement-driver
#inputs:
# - { cpu: "4", memory: "8Gi" }

- action: Cluster
depends: { running: [ master ] }
name: workers
cluster:
templateRef: tikv.cluster.coverage.worker
instances: 1
inputs:
- { placementDriver: .service.master.any }

# Step 1: Load a new dataset, using the parameters of workload A.
# We use no throttling to maximize this step and complete it soon.
- action: Service
depends: { running: [ workers ] , after: 30h}
name: loader
service:
fromTemplate:
templateRef: ycsb.tikv.loader
inputs:
- { server: .service.master.any, workload: workloada, recordcount: "10000000" }

# Step 2: Run workload A
- action: Service
depends: { success: [ loader ] }
name: workload-a
service:
fromTemplate:
templateRef: ycsb.tikv.runner
inputs:
- { server: .service.master.any, workload: workloada, operationcount: "1000000", }

# Step 3: Run workload B
- action: Service
depends: { success: [ workload-a ] }
name: workload-b
service:
fromTemplate:
templateRef: ycsb.tikv.runner
inputs:
- { server: .service.master.any, workload: workloadb, operationcount: "1000000",}

# Step 4: Run workload C
- action: Service
depends: { success: [ workload-b ] }
name: workload-c
service:
fromTemplate:
templateRef: ycsb.tikv.runner
inputs:
- { server: .service.master.any, workload: workloadc, operationcount: "1000000",}


# Step 5: Run workload F
- action: Service
depends: { success: [ workload-c ] }
name: workload-f
service:
fromTemplate:
templateRef: ycsb.tikv.runner
inputs:
- { server: .service.master.any, workload: workloadf, operationcount: "1000000",}


# Step 6: Run workload D.
- action: Service
depends: { success: [ workload-f ] }
name: workload-d
service:
fromTemplate:
templateRef: ycsb.tikv.runner
inputs:
- { server: .service.master.any, workload: workloadd, operationcount: "1000000",}


# Step 7,8: Reload the data with parameters of workload E.
# We use the dropdata field to remove all data before test.
- action: Service
depends: { success: [ workload-d ] }
name: reloader
service:
fromTemplate:
templateRef: ycsb.tikv.loader
inputs:
- { server: .service.master.any, workload: workloade, dropdata: "true", recordcount: "1000000",}

# Step 9:Run workload E
- action: Service
depends: { success: [ reloader ] }
name: workload-e
service:
fromTemplate:
templateRef: ycsb.tikv.runner
inputs:
- { server: .service.master.any, workload: workloade, operationcount: "1000000",}
161 changes: 161 additions & 0 deletions charts/tikv/templates/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
---
# In some situations such as in the Docker or NAT network environment, if the other nodes (peers) cannot access
# the PD node through the default peer URLs listened to by this PD node, you must manually set the advertise peer URLs.
apiVersion: frisbee.io/v1alpha1
kind: Template
metadata:
name: tikv.cluster.coverage.placement-driver
labels:
app.kubernetes.io/managed-by: {{.Release.Service | quote}}
spec:
inputs:
parameters:
cpu: ""
memory: ""
service:
requirements: # Requirements
frisbee.io/pvc: datastore # Will create a PVC and mount the volume
pvc.frisbee.io/spec: |
storageClassName: ssd-storage
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 15Gi
volumes: # Manual volumes
- name: in-memory
emptyDir:
medium: Memory
agents: # Agents
telemetry: [ platform.telemetry.container, tikv.telemetry.pd ]
resources: # Resources
cpu: {{"{{.Inputs.Parameters.cpu}}" | quote}}
memory: {{"{{.Inputs.Parameters.memory}}" | quote}}
container: # Container
name: app
image: icsforth/tikv-pd-coverage
volumeMounts:
- name: datastore
mountPath: /store
ports:
- name: to-clients
containerPort: 2379
- name: to-cluster
containerPort: 2380
- name: coverage
containerPort: 80
command:
- /bin/sh # Run shell
- -c # Read from string
- | # Multi-line str
set -eum
trap "touch /dev/shm/stop" EXIT
echo "Starting goc server"
/goc server &>/dev/null &
echo "Starting lcov webserver at :80 Path:/var/www/localhost/htdocs/"
lighttpd -f /etc/lighttpd/lighttpd.conf
echo "Starting the instrumented binary"
rm -rf /store/$${HOSTNAME}
mkdir -p /store/$${HOSTNAME}/pd
/instr_bin \
--client-urls=http://0.0.0.0:2379 \
--advertise-client-urls=http://$${HOSTNAME}:2379 \
--peer-urls=http://0.0.0.0:2380 \
--advertise-peer-urls=http://$${HOSTNAME}:2380 \
--data-dir=/store/$${HOSTNAME}/pd &
sleep 10
echo "Periodically update the coverage report"
while true
do
echo "Update coverage"
# Get the report in the go cover format
/goc profile | \
# Convert it to lcov format
/gcov2lcov > /tmp/profile.out | \
# Generate http.
genhtml -o /var/www/localhost/htdocs/ /tmp/profile.out &> /dev/null
sleep 30
done
---
apiVersion: frisbee.io/v1alpha1
kind: Template
metadata:
name: tikv.cluster.coverage.worker
labels:
app.kubernetes.io/managed-by: {{.Release.Service | quote}}
spec:
inputs:
parameters:
placementDriver: "localhost"
cpu: ""
memory: ""
service:
requirements: # Requirements
frisbee.io/pvc: datastore # Will create a PVC and mount the volume
pvc.frisbee.io/spec: |
storageClassName: ssd-storage
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 15Gi
volumes: # Manual volumes
- name: in-memory
emptyDir:
medium: Memory
agents: # Agents
telemetry: [ platform.telemetry.container, tikv.telemetry.worker ]
resources: # Resources
cpu: {{"{{.Inputs.Parameters.cpu}}" | quote}}
memory: {{"{{.Inputs.Parameters.memory}}" |quote}}
container: # Container
name: app
image: localhost:32000/tikv-datanode-coverage2
volumeMounts:
- name: in-memory
mountPath: /store
ports:
- name: clusterbus
containerPort: 20160
command:
- /bin/sh # Run shell
- -c # Read from string
- | # Multi-line str
set -eum
trap "touch /dev/shm/stop" EXIT
# increase the maximum number of open file descriptors
ulimit -n 82920
rm -rf /store/$${HOSTNAME}
mkdir -p /store/$${HOSTNAME}/data
# see https://github.com/tikv/tikv/blob/master/etc/config-template.toml
cat > config.toml <<EOF
log-file = "/var/log/tikv-server.log"
[server]
addr="0.0.0.0:20160"
advertise-addr="$${HOSTNAME}:20160"
# used by the prometheus agent
status-addr = "127.0.0.1:20180"
[pd]
endpoints = ["{{"{{.Inputs.Parameters.placementDriver}}"}}:2379"]
[storage]
reserve-space = "0"
data-dir = "/store/$${HOSTNAME}/data"
EOF
echo "Start profiler"
mkdir -p /source/coverage
kcov --exclude-pattern=/usr /var/www/html/ ./target/debug/tikv-server --config=config.toml
4 changes: 0 additions & 4 deletions charts/tikv/templates/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ spec:
--advertise-peer-urls=http://$${HOSTNAME}:2380 \
--data-dir=/store/$${HOSTNAME}/pd
echo "SKATA"
---
apiVersion: frisbee.io/v1alpha1
Expand Down Expand Up @@ -138,5 +136,3 @@ spec:
EOF
/tikv-server --config=config.toml
echo "SKATA"
4 changes: 2 additions & 2 deletions charts/tikv/templates/telemetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
specificTo: pd
agent:
container:
name: tikv-pd
name: telegraf
image: telegraf:1.20.3
ports:
- name: mon-pd
Expand Down Expand Up @@ -70,7 +70,7 @@ spec:

agent:
container:
name: tikv-worker
name: telegraf
image: telegraf:1.20.3
ports:
- name: mon-tikv
Expand Down
3 changes: 2 additions & 1 deletion controllers/cluster/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ func calculateLifecycle(cluster *v1alpha1.Cluster, gs lifecycle.Classifier) v1al
current: %v
total: %d,
activeJobs: %s,
runningJobs: %s,
successfulJobs: %s,
failedJobs: %s
`, status, expectedJobs, gs.ActiveList(), gs.SuccessfulList(), gs.FailedList()))
`, status, expectedJobs, gs.ActiveList(), gs.RunningList(), gs.SuccessfulList(), gs.FailedList()))
}
1 change: 1 addition & 0 deletions tools/coverage/gcov2lcov
Submodule gcov2lcov added at f7e321
Loading

0 comments on commit 9bb919c

Please sign in to comment.