ronantakizawa/codereview-bench huggingface dataset:
Repository: etcd-io/etcd
File: etcdctl/ctlv3/command/printer_json.go (Go)

Code before:
// Copyright 2016 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package command

import (
	"encoding/json"
	"fmt"
	"io"
	"os"

	pb "go.etcd.io/etcd/api/v3/etcdserverpb"
	v3 "go.etcd.io/etcd/client/v3"
)

type jsonPrinter struct {
	writer io.Writer
	isHex  bool
	printer
}

type (
	HexResponseHeader pb.ResponseHeader
	HexMember         pb.Member
)

func (h *HexResponseHeader) MarshalJSON() ([]byte, error) {
	type Alias pb.ResponseHeader

	return json.Marshal(&struct {
		ClusterID string `json:"cluster_id"`
		MemberID  string `json:"member_id"`
		Alias
	}{
		ClusterID: fmt.Sprintf("%x", h.ClusterId),
		MemberID:  fmt.Sprintf("%x", h.MemberId),
		Alias:     (Alias)(*h),
	})

Review comment (suggestion):
Personally I think `clientv3` is accurate & better. (Actually we don't need to specify package name here, because it's `clientv3` by default.

https://github.com/etcd-io/etcd/blob/df6b790d7c5bac171bd18f605de352126e01518a/client/v3/compare.go#L15

So I suggest to keep this file unchanged.

Code after:
// Copyright 2016 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package command

import (
	"encoding/json"
	"fmt"
	"io"
	"os"

	pb "go.etcd.io/etcd/api/v3/etcdserverpb"
	clientv3 "go.etcd.io/etcd/client/v3"
)

type jsonPrinter struct {
	writer io.Writer
	isHex  bool
	printer
}

type (
	HexResponseHeader pb.ResponseHeader
	HexMember         pb.Member
)

func (h *HexResponseHeader) MarshalJSON() ([]byte, error) {
	type Alias pb.ResponseHeader

	return json.Marshal(&struct {
		ClusterID string `json:"cluster_id"`
		MemberID  string `json:"member_id"`
		Alias
	}{
		ClusterID: fmt.Sprintf("%x", h.ClusterId),
		MemberID:  fmt.Sprintf("%x", h.MemberId),
		Alias:     (Alias)(*h),
	})
Repository: etcd-io/etcd
File: server/etcdmain/grpc_proxy_logger.go (Go)

Code before:
// Copyright 2016 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package etcdmain

import (
	"context"
	"fmt"
	"path"
	"reflect"
	"slices"
	"time"

	"github.com/golang/protobuf/jsonpb"
	"github.com/golang/protobuf/proto"

Review comment (security):
```suggestion
// Copyright 2025 The etcd Authors
```

Code after:
// Copyright 2025 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package etcdmain

import (
	"context"
	"fmt"
	"path"
	"reflect"
	"slices"
	"time"

	"github.com/golang/protobuf/jsonpb"
	"github.com/golang/protobuf/proto"
Repository: etcd-io/etcd
File: server/etcdmain/grpc_proxy_logger_test.go (Go)

Code before:
// Copyright 2016 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package etcdmain

import (
	"context"
	"fmt"
	"io"
	"testing"
	"time"

	"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors"
	"github.com/grpc-ecosystem/go-grpc-middleware/v2/testing/testpb"
	"github.com/stretchr/testify/suite"

Review comment (security):
```suggestion
// Copyright 2025 The etcd Authors
```

Code after:
// Copyright 2025 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package etcdmain

import (
	"context"
	"fmt"
	"io"
	"testing"
	"time"

	"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors"
	"github.com/grpc-ecosystem/go-grpc-middleware/v2/testing/testpb"
	"github.com/stretchr/testify/suite"
Repository: etcd-io/etcd
File: tests/robustness/coverage/coverage_test.go (Go)

Code before:
		// Used to manage masterleases and events
	},
	"etcdserverpb.Maintenance/Status": {
		// Used to expose database size on apiserver's metrics endpoint
	},
}

func TestInterfaceUse(t *testing.T) {
	files, err := os.ReadDir("testdata")
	if err != nil {
		t.Fatal(err)
	}

	for _, file := range files {
		filename := file.Name()
		if filename == ".gitignore" {
			continue
		}
		t.Run(filename, func(t *testing.T) { testInterfaceUse(t, filename) })
	}
}

func testInterfaceUse(t *testing.T, filename string) {
	b, err := os.ReadFile(filepath.Join("testdata", filename))
	if err != nil {
		t.Fatalf("read test data: %v", err)
	}
	var dump Dump
	err = json.Unmarshal(b, &dump)
	if err != nil {
		t.Fatalf("unmarshal testdata %s: %v", filename, err)
	}
	if dump.Result == nil {
		t.Fatalf("missing result data")
	}
	traces := dump.Result

	callsByOperationName := make(map[string][]*tracev1.ResourceSpans)
	for _, trace := range traces.GetResourceSpans() {
		if getServiceName(trace) != "etcd" {
			continue
		}
		opName := getOperationName(trace)
		// Skip put key=_test after healthcheck in command tests.
		if opName == "etcdserverpb.KV/Put" && isCommandTestHC(trace) {
			continue
		}
		callsByOperationName[opName] = append(callsByOperationName[opName], trace)
	}
	delete(callsByOperationName, "")
	t.Logf("\n%s", printableCallTable(callsByOperationName))

Review comment (suggestion):
Shouldnt that be visible in `etcdserverpb.KV/Txn`. Think we need to add whether the PUT operation had lease attached.

Code after:
		// All calls should go through etcd-k8s interface
		args: []column{
			{name: "getOnFailure", matcher: keyIsEqualInt("failure_len", 1)},
			{name: "readOnly", matcher: isReadOnly},
		},
		keyAttrName: "compare_first_key",
		methods: []method{
			{
				name:    "Compaction",
				matcher: keyIsEqualStr("compare_first_key", "compact_rev_key"),
			},
			{
				name:    "OptimisticPutOrDelete",
				matcher: andMatcher(keyIsEqualInt("compare_len", 1), keyIsEqualInt("success_len", 1), notMatcher(isReadOnly)),
			},
		},
	},
	"etcdserverpb.KV/Compact": {
		// Compaction should move to using internal Etcd mechanism
		// Discussed in https://github.com/kubernetes/kubernetes/issues/80513
	},
	"etcdserverpb.Watch/Watch": {
		// Not part of the contract interface (yet)
	},
	"etcdserverpb.Lease/LeaseGrant": {
		// Used to manage masterleases and events
	},
	"etcdserverpb.Maintenance/Status": {
		// Used to expose database size on apiserver's metrics endpoint
	},
}

func TestInterfaceUse(t *testing.T) {
	files, err := os.ReadDir("testdata")
	if err != nil {
		t.Fatal(err)
	}

	for _, file := range files {
		filename := file.Name()
		if filename == ".gitignore" {
			continue
		}
		t.Run(filename, func(t *testing.T) { testInterfaceUse(t, filename) })
	}
}

func testInterfaceUse(t *testing.T, filename string) {
	b, err := os.ReadFile(filepath.Join("testdata", filename))
	if err != nil {
		t.Fatalf("read test data: %v", err)
Repository: etcd-io/etcd
File: tests/robustness/coverage/coverage_test.go (Go)

Code before:
				args := columnsToArgs(trace, td.args)

				if method == "" && !tracesWithNoMethod[args] {
					t.Errorf("New call pattern detected: %s(key=%s,%s)", op, pattern, argsToDescription(args, td.args))
					tracesWithNoMethod[args] = true
				}
				callCounts[row{method, pattern, args}]++
			}

			t.Logf("\n%s", printableMatcherTable(td.args, callCounts))
		})
	}
}

func extractPattern(trace *tracev1.ResourceSpans, key string) string {
	k, found := strAttr(trace, key)
	suffix := ""
	if strings.HasSuffix(k, "/") {
		suffix = "/"
	}
	if found {
		if k == "/registry/health" || k == "compact_rev_key" {
			return k
		}
		if !strings.HasPrefix(k, "/registry") {
			return "unexpected: " + k
		}
		switch strings.Count(strings.TrimRight(k, "/"), "/") {
		case 1:
			return "/registry" + suffix
		case 2:
			return "/registry/{resource}" + suffix
		case 3:
			return "/registry/{resource}/{namespace}" + suffix
		case 4:
			return "/registry/{resource}/{namespace}/{name}" + suffix
		case 5:
			return "/registry/{api-group}/{resource}/{namespace}/{name}" + suffix
		}
		return "unexpected: " + k
	}
	return ""
}

func columnsToArgs(trace *tracev1.ResourceSpans, cols []column) string {
	acc := make([]byte, len(cols))
	for i, col := range cols {
		if col.matcher(trace) {
			acc[i] = 'X'
		} else {
			acc[i] = notMatched

Review comment (suggestion):
Please don't change key. Return error if you want to signal issue.

Code after:
			for _, trace := range callsByOperationName[op] {
				args := columnsToArgs(trace, td.args)

				pattern, pFound := extractPattern(trace, td.keyAttrName)
				if !pFound && !tracesWithNoMethod[args] {
					t.Errorf("New key pattern detected: %s", pattern)
				}

				method, mFound := extractMethod(td.methods, trace)
				if !mFound && !tracesWithNoMethod[args] {
					t.Errorf("New call pattern detected: %s(key=%s,%s)", op, pattern, argsToDescription(args, td.args))
					tracesWithNoMethod[args] = true
				}

				callCounts[row{method, pattern, args}]++
			}

			t.Logf("\n%s", printableMatcherTable(td.args, callCounts))
		})
	}
}

func extractPattern(trace *tracev1.ResourceSpans, key string) (string, bool) {
	k, found := strAttr(trace, key)
	if !found {
		return "", false
	}
	if k == "/registry/health" || k == "compact_rev_key" {
		return k, true
	}
	if !strings.HasPrefix(k, "/registry") {
		return k, false
	}
	suffix := ""
	if strings.HasSuffix(k, "/") {
		suffix = "/"
	}
	switch strings.Count(strings.TrimRight(k, "/"), "/") {
	case 1:
		return "/registry" + suffix, true
	case 2:
		return "/registry/{resource}" + suffix, true
	case 3:
		return "/registry/{resource}/{namespace}" + suffix, true
	case 4:
		return "/registry/{resource}/{namespace}/{name}" + suffix, true
	case 5:
		return "/registry/{api-group}/{resource}/{namespace}/{name}" + suffix, true
	}
	return k, false
}
Repository: etcd-io/etcd
File: tests/robustness/coverage/coverage_test.go (Go)

Code before:

			callCounts := make(map[row]int)
			for _, trace := range callsByOperationName[op] {
				method := traceToInterfaceMethod(td.methods, trace)
				pattern := extractPattern(trace, td.keyAttrName)
				args := columnsToArgs(trace, td.args)

				if method == "" && !tracesWithNoMethod[args] {
					t.Errorf("New call pattern detected: %s(key=%s,%s)", op, pattern, argsToDescription(args, td.args))
					tracesWithNoMethod[args] = true
				}
				callCounts[row{method, pattern, args}]++
			}

			t.Logf("\n%s", printableMatcherTable(td.args, callCounts))
		})
	}
}

func extractPattern(trace *tracev1.ResourceSpans, key string) string {
	k, found := strAttr(trace, key)
	suffix := ""
	if strings.HasSuffix(k, "/") {
		suffix = "/"
	}
	if found {
		if k == "/registry/health" || k == "compact_rev_key" {
			return k
		}
		if !strings.HasPrefix(k, "/registry") {
			return "unexpected: " + k
		}
		switch strings.Count(strings.TrimRight(k, "/"), "/") {
		case 1:
			return "/registry" + suffix
		case 2:
			return "/registry/{resource}" + suffix
		case 3:
			return "/registry/{resource}/{namespace}" + suffix
		case 4:
			return "/registry/{resource}/{namespace}/{name}" + suffix
		case 5:
			return "/registry/{api-group}/{resource}/{namespace}/{name}" + suffix
		}
		return "unexpected: " + k
	}
	return ""
}

func columnsToArgs(trace *tracev1.ResourceSpans, cols []column) string {
	acc := make([]byte, len(cols))

Review comment (suggestion):
```suggestion
	if !found {
		return ""
	}
	...
```

Code after:
			// tracesWithNoMethod ensures that we print error only once when a
			// new call pattern is found.
			tracesWithNoMethod := make(map[string]bool)

			callCounts := make(map[row]int)
			for _, trace := range callsByOperationName[op] {
				args := columnsToArgs(trace, td.args)

				pattern, pFound := extractPattern(trace, td.keyAttrName)
				if !pFound && !tracesWithNoMethod[args] {
					t.Errorf("New key pattern detected: %s", pattern)
				}

				method, mFound := extractMethod(td.methods, trace)
				if !mFound && !tracesWithNoMethod[args] {
					t.Errorf("New call pattern detected: %s(key=%s,%s)", op, pattern, argsToDescription(args, td.args))
					tracesWithNoMethod[args] = true
				}

				callCounts[row{method, pattern, args}]++
			}

			t.Logf("\n%s", printableMatcherTable(td.args, callCounts))
		})
	}
}

func extractPattern(trace *tracev1.ResourceSpans, key string) (string, bool) {
	k, found := strAttr(trace, key)
	if !found {
		return "", false
	}
	if k == "/registry/health" || k == "compact_rev_key" {
		return k, true
	}
	if !strings.HasPrefix(k, "/registry") {
		return k, false
	}
	suffix := ""
	if strings.HasSuffix(k, "/") {
		suffix = "/"
	}
	switch strings.Count(strings.TrimRight(k, "/"), "/") {
	case 1:
		return "/registry" + suffix, true
	case 2:
		return "/registry/{resource}" + suffix, true
	case 3:
		return "/registry/{resource}/{namespace}" + suffix, true
	case 4:
		return "/registry/{resource}/{namespace}/{name}" + suffix, true
Repository: etcd-io/etcd
File: tests/integration/cache_test.go (Go)

Code before:
			t.Fatalf("Put overflow: %v", err)
		}
	}

	watchCtx, cancel := context.WithTimeout(ctx, 2*time.Second)
	defer cancel()
	ch := c.Watch(watchCtx, "/old/key", clientv3.WithRev(oldRev))

	select {
	case resp, ok := <-ch:
		if !ok || !resp.Canceled {
			t.Fatalf("expected canceled watch, got %+v closed=%v", resp, ok)
		}
		if resp.Err() == nil || (!errors.Is(resp.Err(), rpctypes.ErrCompacted) &&
			!errors.Is(resp.Err(), cache.ErrUnsupportedRequest)) {
			t.Fatalf("expected ErrCompacted (or temporary ErrUnsupportedRequest), got %v", resp.Err())
		}
	case <-watchCtx.Done():
		t.Fatal("watch did not cancel with compaction error within timeout")
	}
}

func generateEvents(t *testing.T, client *clientv3.Client, prefix string, n int) {
	t.Helper()
	for i := 0; i < n; i++ {
		key := fmt.Sprintf("%s%d", prefix, i)
		if _, err := client.Put(t.Context(), key, fmt.Sprintf("%d", i)); err != nil {
			t.Fatalf("Put(%q): %v", key, err)
		}
	}
}

type Watcher interface {
	Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan
}

type Getter interface {
	Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
}

func collectAndAssertAtomicEvents(t *testing.T, watch clientv3.WatchChan) (events []*clientv3.Event, ok bool) {
	deadline := time.After(time.Second)
	var lastRevision int64

	for {
		select {
		case resp, ok := <-watch:
			if !ok {
				return events, false
			}
			if len(resp.Events) != 0 && resp.Events[0].Kv.ModRevision == lastRevision {

Review comment (suggestion):
```suggestion
	prevIndex := 0
```
? Name `start` doesn't make sense.

Code after:
				}
				events = append(events, ev)
				lastRevision = ev.Kv.ModRevision
			}
		case <-deadline:
			return events, true
		case <-time.After(100 * time.Millisecond):
			return events, true
		}
	}
}

func applyEvents(ctx context.Context, t *testing.T, kv clientv3.KV, evs []*clientv3.Event) int64 {
	var lastRev int64
	for _, batches := range batchEventsByRevision(evs) {
		lastRev = applyEventBatch(ctx, t, kv, batches)
	}
	return lastRev
}

func batchEventsByRevision(events []*clientv3.Event) [][]*clientv3.Event {
	var batches [][]*clientv3.Event
	if len(events) == 0 {
		return batches
	}
	start := 0
	for end := 1; end < len(events); end++ {
		if events[end].Kv.ModRevision != events[start].Kv.ModRevision {
			batches = append(batches, events[start:end])
			start = end
		}
	}
	batches = append(batches, events[start:])
	return batches
}

func applyEventBatch(ctx context.Context, t *testing.T, kv clientv3.KV, batch []*clientv3.Event) int64 {
	ops := make([]clientv3.Op, 0, len(batch))
	for _, event := range batch {
		switch event.Type {
		case clientv3.EventTypePut:
			ops = append(ops, clientv3.OpPut(string(event.Kv.Key), string(event.Kv.Value)))
		case clientv3.EventTypeDelete:
			ops = append(ops, clientv3.OpDelete(string(event.Kv.Key)))
		default:
			t.Fatalf("unsupported event type: %v", event.Type)
		}
	}
	resp, err := kv.Txn(ctx).Then(ops...).Commit()
	if err != nil {
		t.Fatalf("Txn failed: %v", err)
Repository: etcd-io/etcd
File: tests/e2e/reproduce_18667_test.go (Go)

Code before:

	t.Logf("Compact on the latest revision %d", revision)
	_, err := cli.Compact(ctx, revision)
	require.NoError(t, err)

	t.Log("Send txn to make data inconsistent among etcdservers")
	cmp := clientv3.Compare(clientv3.Value("k1"), "=", "v1")
	then := []clientv3.Op{
		clientv3.OpPut("k2", "foo"),
		clientv3.OpGet("k1", clientv3.WithRev(revision-1)),
	}
	_, err = cli.Txn(ctx).If(cmp).Then(then...).Commit()
	require.Error(t, err)
	require.Contains(t, err.Error(), rpctypes.ErrCompacted.Error())

	t.Log("Verify: k2 equals to v2 in the etcdserver which the Txn was sent to")
	kv2, err := cli.Get(ctx, "k2")
	require.NoError(t, err)
	assert.Equal(t, "v2", string(kv2.Kvs[0].Value))

	t.Log("Verify: k2 equals to foo in other etcdservers")
	targetIdx = (targetIdx + 1) % clus.Cfg.ClusterSize
	cli = newClient(t, clus.Procs[targetIdx].EndpointsGRPC(), e2e.ClientConfig{})
	followerK2, err := cli.Get(ctx, "k2")
	require.NoError(t, err)
	assert.Equal(t, "foo", string(followerK2.Kvs[0].Value))
}


Review comment (bug):
```suggestion
	t.Log("Verify all members have consistent data on key 'k2'")
	for i := 0; i < clus.Cfg.ClusterSize; i++ {
		idx := (targetIdx + i) % clus.Cfg.ClusterSize
		cli = newClient(t, clus.Procs[idx].EndpointsGRPC(), e2e.ClientConfig{})
		resp, err := cli.Get(ctx, "k2")
		require.NoError(t, err)
		// All members are supposed to have the same key/value pair k2:v2.
		// However, the issue https://github.com/etcd-io/etcd/issues/18667
		// hasn't been resolved yet, so some members hold the wrong data
		// "k2:foo". Once the issue is fixed, we should remove the if-else
		// branch below, and all member should have consistent data k2:v2.
		if i == 0 {
			assert.Equal(t, "v2", string(resp.Kvs[0].Value))
		} else {
			assert.Equal(t, "foo", string(resp.Kvs[0].Value))
		}
	}		
```

Code after:

	t.Logf("Compact on the latest revision %d", revision)
	_, err := cli.Compact(ctx, revision)
	require.NoError(t, err)

	t.Log("Send txn to make data inconsistent among etcdservers")
	cmp := clientv3.Compare(clientv3.Value("k1"), "=", "v1")
	then := []clientv3.Op{
		clientv3.OpPut("k2", "foo"),
		clientv3.OpGet("k1", clientv3.WithRev(revision-1)),
	}
	_, err = cli.Txn(ctx).If(cmp).Then(then...).Commit()
	require.Error(t, err)
	require.Contains(t, err.Error(), rpctypes.ErrCompacted.Error())

	t.Log("Verify all members have consistent data on key 'k2'")
	for i := 0; i < clus.Cfg.ClusterSize; i++ {
		idx := (targetIdx + i) % clus.Cfg.ClusterSize
		cli = newClient(t, clus.Procs[idx].EndpointsGRPC(), e2e.ClientConfig{})
		resp, err := cli.Get(ctx, "k2")
		require.NoError(t, err)
		// TODO: All members are supposed to have the same key/value pair k2:v2.
		// However, the issue https://github.com/etcd-io/etcd/issues/18667
		// hasn't been resolved yet, so some members hold the wrong data
		// "k2:foo". Once the issue is fixed, we should remove the if-else
		// branch below, and all member should have consistent data k2:v2.
		if i == 0 {
			assert.Equal(t, "v2", string(resp.Kvs[0].Value))
		} else {
			assert.Equal(t, "foo", string(resp.Kvs[0].Value))
		}
	}
}
Repository: etcd-io/etcd
File: tests/e2e/reproduce_18667_test.go (Go)

Code before:
// Copyright 2024 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package e2e

import (
	"fmt"
	"math/rand"
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"

	"go.etcd.io/etcd/api/v3/v3rpc/rpctypes"
	clientv3 "go.etcd.io/etcd/client/v3"

Review comment (security):
```suggestion
// Copyright 2025 The etcd Authors
```

Code after:
// Copyright 2025 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package e2e

import (
	"fmt"
	"math/rand"
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"

	"go.etcd.io/etcd/api/v3/v3rpc/rpctypes"
	clientv3 "go.etcd.io/etcd/client/v3"