From e2a65bee6e8708aa54f180289340ec40ecc165af Mon Sep 17 00:00:00 2001 From: Piotr Tabor Date: Sun, 10 Jan 2021 12:47:23 +0100 Subject: [PATCH] Avoid 'interactive prompt' for root password in etcd tests. Before: ``` {"level":"info","ts":1610273495.3791487,"caller":"agent/handler.go:668","msg":"cleaning up page cache"} {"level":"info","ts":1610273495.3793094,"caller":"agent/handler.go:94","msg":"created etcd log file","path":"/tmp/etcd-functional-2/etcd.log"} {"level":"info","ts":1610273495.379328,"caller":"agent/handler.go:668","msg":"cleaning up page cache"} [sudo] password for ptab: pam_glogin: invalid password Sorry, try again. [sudo] password for ptab: ``` Now the caches are dropped if the current users is in sudoers, bot not in the other cases. To be honest I don't see the purpose for dropping the caches at all in the test. --- tests/functional/agent/handler.go | 1 + tests/functional/agent/utils.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/functional/agent/handler.go b/tests/functional/agent/handler.go index e59c9038b..9a2962604 100644 --- a/tests/functional/agent/handler.go +++ b/tests/functional/agent/handler.go @@ -665,6 +665,7 @@ func (srv *Server) handle_SIGQUIT_ETCD_AND_ARCHIVE_DATA() (*rpcpb.Response, erro } } + // TODO: Verify whether this cleaning of 'cache pages' is needed. srv.lg.Info("cleaning up page cache") if err := cleanPageCache(); err != nil { srv.lg.Warn("failed to clean up page cache", zap.String("error", err.Error())) diff --git a/tests/functional/agent/utils.go b/tests/functional/agent/utils.go index 45ea66333..d77fce60b 100644 --- a/tests/functional/agent/utils.go +++ b/tests/functional/agent/utils.go @@ -103,6 +103,6 @@ func copyFile(src, dst string) error { func cleanPageCache() error { // 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`) + cmd := exec.Command("/bin/sh", "-c", `echo "echo 1 > /proc/sys/vm/drop_caches" | sudo -s -n`) return cmd.Run() }