Repository: etcd-io/etcd (language: go)

Issue:
Replace tenv linter with usetesting
### What would you like to be added?

After the `golagci-lint` bump to 1.64.5, we started getting the following warning:

```
The linter 'tenv' is deprecated (since v1.64.0) due to: Duplicate feature another linter. Replaced by usetesting
```

We should replace the linter with `usetesting` to avoid future failures.

Refer to any recent `pull-etcd-verify` job, i.e., https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/etcd-io_etcd/19484/pull-etcd-verify/1894477775524335616#1:build-log.txt%3A114-119

### Why is this needed?

To keep our linters up to date.


Discussion / hints:

Fix patch:
diff --git a/tools/.golangci.yaml b/tools/.golangci.yaml
index 60925e0a467..f8d602cc08f 100644
--- a/tools/.golangci.yaml
+++ b/tools/.golangci.yaml
@@ -30,12 +30,12 @@ linters:
     - revive
     - staticcheck
     - stylecheck
-    - tenv
     - testifylint
     - unconvert # Remove unnecessary type conversions
     - unparam
     - unused
     - usestdlibvars
+    - usetesting
     - whitespace
 linters-settings: # please keep this alphabetized
   goimports:
@@ -120,3 +120,5 @@ linters-settings: # please keep this alphabetized
       # to always require f-functions for stretchr/testify, but not for golang standard lib.
       # Also refer to https://github.com/etcd-io/etcd/pull/18741#issuecomment-2422395914
       require-f-funcs: true
+  usetesting:
+    os-mkdir-temp: false


Test patch:
diff --git a/client/pkg/fileutil/lock_test.go b/client/pkg/fileutil/lock_test.go
index 0c5da9855ad..ea449e1cff3 100644
--- a/client/pkg/fileutil/lock_test.go
+++ b/client/pkg/fileutil/lock_test.go
@@ -23,7 +23,7 @@ import (
 )
 
 func TestLockAndUnlock(t *testing.T) {
-	f, err := os.CreateTemp("", "lock")
+	f, err := os.CreateTemp(t.TempDir(), "lock")
 	require.NoError(t, err)
 	f.Close()
 	defer func() {
diff --git a/client/v3/yaml/config_test.go b/client/v3/yaml/config_test.go
index 4d23f27494e..f4c68c999df 100644
--- a/client/v3/yaml/config_test.go
+++ b/client/v3/yaml/config_test.go
@@ -73,7 +73,7 @@ func TestConfigFromFile(t *testing.T) {
 	}
 
 	for i, tt := range tests {
-		tmpfile, err := os.CreateTemp("", "clientcfg")
+		tmpfile, err := os.CreateTemp(t.TempDir(), "clientcfg")
 		if err != nil {
 			log.Fatal(err)
 		}
diff --git a/server/embed/config_test.go b/server/embed/config_test.go
index 54247382f05..d52a0a2c6a1 100644
--- a/server/embed/config_test.go
+++ b/server/embed/config_test.go
@@ -615,7 +615,7 @@ func compareSlices(slice1, slice2 []string) bool {
 }
 
 func mustCreateCfgFile(t *testing.T, b []byte) *os.File {
-	tmpfile, err := os.CreateTemp("", "servercfg")
+	tmpfile, err := os.CreateTemp(t.TempDir(), "servercfg")
 	if err != nil {
 		t.Fatal(err)
 	}
diff --git a/server/etcdmain/config_test.go b/server/etcdmain/config_test.go
index 56ff9766aa2..514f93ca04d 100644
--- a/server/etcdmain/config_test.go
+++ b/server/etcdmain/config_test.go
@@ -1244,7 +1244,7 @@ func generateCfgsFromFileAndCmdLine(t *testing.T, yc any, cmdLineArgs []string)
 }
 
 func mustCreateCfgFile(t *testing.T, b []byte) *os.File {
-	tmpfile, err := os.CreateTemp("", "servercfg")
+	tmpfile, err := os.CreateTemp(t.TempDir(), "servercfg")
 	if err != nil {
 		t.Fatal(err)
 	}
diff --git a/tests/e2e/ctl_v3_snapshot_test.go b/tests/e2e/ctl_v3_snapshot_test.go
index c9dc03235d1..d66249a5441 100644
--- a/tests/e2e/ctl_v3_snapshot_test.go
+++ b/tests/e2e/ctl_v3_snapshot_test.go
@@ -163,13 +163,9 @@ func TestIssue6361(t *testing.T) { testIssue6361(t) }
 // TestIssue6361 ensures new member that starts with snapshot correctly
 // syncs up with other members and serve correct data.
 func testIssue6361(t *testing.T) {
-	{
-		// This tests is pretty flaky on semaphoreci as of 2021-01-10.
-		// TODO: Remove when the flakiness source is identified.
-		oldenv := os.Getenv("EXPECT_DEBUG")
-		defer os.Setenv("EXPECT_DEBUG", oldenv)
-		os.Setenv("EXPECT_DEBUG", "1")
-	}
+	// This tests is pretty flaky on semaphoreci as of 2021-01-10.
+	// TODO: Remove when the flakiness source is identified.
+	t.Setenv("EXPECT_DEBUG", "1")
 
 	e2e.BeforeTest(t)