From 78df258ea8914eb8098839b8cebc147a08fc393e Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Thu, 11 Feb 2016 13:38:13 -0800 Subject: [PATCH] etcd-agent: cleans page cache when cleaning up Reference: - https://www.kernel.org/doc/Documentation/sysctl/vm.txt - https://github.com/torvalds/linux/blob/master/fs/drop_caches.c --- tools/functional-tester/etcd-agent/agent.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/functional-tester/etcd-agent/agent.go b/tools/functional-tester/etcd-agent/agent.go index 4c8f3fe42..40935096c 100644 --- a/tools/functional-tester/etcd-agent/agent.go +++ b/tools/functional-tester/etcd-agent/agent.go @@ -16,6 +16,7 @@ package main import ( "fmt" + "log" "net" "os" "os/exec" @@ -119,7 +120,17 @@ func (a *Agent) cleanup() error { } f, err := os.Create(a.etcdLogPath) a.logfile = f - return err + if err != nil { + return err + } + + // https://www.kernel.org/doc/Documentation/sysctl/vm.txt + // https://github.com/torvalds/linux/blob/master/fs/drop_caches.c + cmd := exec.Command("/bin/sh", "-c", `echo "echo 1 > /proc/sys/vm/drop_caches" | sudo sh`) + if err := cmd.Run(); err != nil { + log.Printf("error when cleaning page cache (%v)", err) + } + return nil } // terminate stops the exiting etcd process the agent started