From 6177a0db3e62948dfe7e89b101acacb8ff61828c Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Tue, 25 Jul 2023 17:48:45 +0000 Subject: [PATCH] metrics: Add env files for FIO This PR adds the env files for FIO for kata metrics. Signed-off-by: Gabriela Cervantes --- .../metrics/storage/fio-k8s/pkg/env/Makefile | 9 +++++ tests/metrics/storage/fio-k8s/pkg/env/env.go | 39 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 tests/metrics/storage/fio-k8s/pkg/env/Makefile create mode 100644 tests/metrics/storage/fio-k8s/pkg/env/env.go diff --git a/tests/metrics/storage/fio-k8s/pkg/env/Makefile b/tests/metrics/storage/fio-k8s/pkg/env/Makefile new file mode 100644 index 000000000..01e0d9209 --- /dev/null +++ b/tests/metrics/storage/fio-k8s/pkg/env/Makefile @@ -0,0 +1,9 @@ +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# + +gomod: + GO111MODULE=on go mod edit -replace=github.com/kata-containers/tests/metrics/exec=../exec + GO111MODULE=on go mod tidy diff --git a/tests/metrics/storage/fio-k8s/pkg/env/env.go b/tests/metrics/storage/fio-k8s/pkg/env/env.go new file mode 100644 index 000000000..e5deb29e4 --- /dev/null +++ b/tests/metrics/storage/fio-k8s/pkg/env/env.go @@ -0,0 +1,39 @@ +// Copyright (c) 2021 Intel Corporation +// +// SPDX-License-Identifier: Apache-2.0 +// +package env + +import ( + exec "github.com/kata-containers/tests/metrics/exec" +) + +//logger interface for pkg +var log logger +var Debug bool = false + +type logger interface { + Infof(string, ...interface{}) + Debugf(string, ...interface{}) + Errorf(string, ...interface{}) +} + +func SetLogger(l logger) { + log = l +} + +var sysDropCachesPath = "/proc/sys/vm/drop_caches" + +func DropCaches() (err error) { + log.Infof("drop caches") + _, err = exec.ExecCmd("sync", Debug) + if err != nil { + return err + } + + _, err = exec.ExecCmd("echo 3 | sudo tee "+sysDropCachesPath, Debug) + if err != nil { + return err + } + return nil +}