Browse Source

Merge pull request #4488 from gyuho/page_cache

etcd-agent: cleans page cache when cleaning up
Gyu-Ho Lee 10 years ago
parent
commit
4b9bf0d673
1 changed files with 12 additions and 1 deletions
  1. 12 1
      tools/functional-tester/etcd-agent/agent.go

+ 12 - 1
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