Skip to content

Conversation

yagikota
Copy link
Contributor

@yagikota yagikota commented Aug 29, 2025

What

Migrate HashKV tests to the common test framework and remove legacy e2e/integration suites.

Test Migration Mapping

Before Migration After Migration
TestVerifyHashKVAfterCompact (E2E) TestVerifyHashKVAfterCompact (common)
TestVerifyHashKVAfterTwoCompactionsOnTombstone_MixVersions (E2E) TestVerifyHashKVAfterTwoCompactsOnTombstone (common)
TestVerifyHashKVAfterCompactionOnLastTombstone_MixVersions (E2E) TestVerifyHashKVAfterCompactOnLastTombstone (common)
TestCompactionHash (Integration) TestVerifyHashKVAfterCompactAndDefrag (common)

Cluster-wide consistency check:

  • TestVerifyHashKVAfterCompact: Ensure that HashKV is consistent across all members after a physical compaction
  • TestVerifyHashKVAfterTwoCompactsOnTombstone: Ensure that HashKV is consistent across all members after two physical compactions on tombstone revisions.
  • TestVerifyHashKVAfterCompactOnLastTombstone: Ensure that HashKV is consistent across all members after a physical compaction on the last tombstone revision.

Member-local consistency check:

  • TestVerifyHashKVAfterCompactAndDefrag: Ensure that HashKV is consistent within a member before and after a physical compaction and defragmentation.

Other note

  • Use context.WithTimeout(t.Context(), 30*time.Second) (30s timeouts) to reduce flakiness due to CI variance.

Why

This migration is part of #13637

How to test?

Requirement

Check the ./bin/etcd version

./bin/etcd --version 
etcd Version: 3.7.0-alpha.0
Git SHA: 8e2a54a1e
Go Version: go1.24.6
Go OS/Arch: darwin/arm64

-> minor version of /etcd-last-release can be calculated like this: 7 - 1 = 6

Check the latest v3.6.* version

git ls-remote --tags https://github.com/etcd-io/etcd.git "v3.6.*" \
  | awk -F'/' '{print $NF}' \
  | sed 's/\^{}//' \
  | sort -V \
  | tail -1
v3.6.4

Install etcd v3.6.4 as /etcd-last-release

curl -L https://github.com/etcd-io/etcd/releases/download/v3.6.4/etcd-v3.6.4-darwin-arm64.zip -o /tmp/etcd-v3.6.4-darwin-arm64.zip
unzip -q /tmp/etcd-v3.6.4-darwin-arm64.zip -d /tmp/etcd-v3.6.4
mkdir -p ./bin
mv /tmp/etcd-v3.6.4/etcd-v3.6.4-darwin-arm64/etcd ./bin/etcd-last-release
chmod +x ./bin/etcd-last-release
./bin/etcd-last-release --version

Check versions

./bin/etcd --version
etcd Version: 3.7.0-alpha.0
Git SHA: 8e2a54a1e
Go Version: go1.24.6
Go OS/Arch: darwin/arm64

./bin/etcd-last-release --version
etcd Version: 3.6.4
Git SHA: 5400cdc
Go Version: go1.23.11
Go OS/Arch: darwin/arm64

Before Migration

E2E

go test -v -count=1 . -run 'TestVerifyHashKV'
...
--- PASS: TestVerifyHashKVAfterCompact (36.13s)
    --- PASS: TestVerifyHashKVAfterCompact/compactedOnTombstone=false_-_current-version_-_Keys=[key0] (4.42s)
    --- PASS: TestVerifyHashKVAfterCompact/compactedOnTombstone=false_-_current-version_-_Keys=[key0_key1] (4.36s)
    --- PASS: TestVerifyHashKVAfterCompact/compactedOnTombstone=false_-_quorum-last-version_-_Keys=[key0] (4.29s)
    --- PASS: TestVerifyHashKVAfterCompact/compactedOnTombstone=false_-_quorum-last-version_-_Keys=[key0_key1] (4.77s)
    --- PASS: TestVerifyHashKVAfterCompact/compactedOnTombstone=true_-_current-version_-_Keys=[key0] (4.54s)
    --- PASS: TestVerifyHashKVAfterCompact/compactedOnTombstone=true_-_current-version_-_Keys=[key0_key1] (4.57s)
    --- PASS: TestVerifyHashKVAfterCompact/compactedOnTombstone=true_-_quorum-last-version_-_Keys=[key0] (4.62s)
    --- PASS: TestVerifyHashKVAfterCompact/compactedOnTombstone=true_-_quorum-last-version_-_Keys=[key0_key1] (4.56s)
...
--- PASS: TestVerifyHashKVAfterTwoCompactionsOnTombstone_MixVersions (4.07s)
...
--- PASS: TestVerifyHashKVAfterCompactionOnLastTombstone_MixVersions (7.90s)
    --- PASS: TestVerifyHashKVAfterCompactionOnLastTombstone_MixVersions/#[key0] (3.68s)
    --- PASS: TestVerifyHashKVAfterCompactionOnLastTombstone_MixVersions/#[key0_key1] (4.22s)
PASS
ok  	go.etcd.io/etcd/tests/v3/e2e	48.409s

Integration

go test -v . -run 'TestCompactionHash'
...
--- PASS: TestCompactionHash (17.31s)
PASS
ok  	go.etcd.io/etcd/tests/v3/integration	17.670s

After Migration

E2E

go test -v -count=1 -tags=e2e . -run TestVerifyHashKV | grep -C 3 "PASS:"
    logger.go:146: 2025-08-30T13:50:44.520+0900	INFO	closing server...	{"name": "TestVerifyHashKVAfterCompactKeyskey0_key1CompactedOnTombstonetrueQuorumLastVersion-test-2"}
    logger.go:146: 2025-08-30T13:50:44.520+0900	INFO	removing directory	{"data-dir": "/var/folders/8g/rzqb0glj7m76zbc7h30wtp_80000gn/T/TestVerifyHashKVAfterCompactKeys=key0_key1CompactedOnTombstone=trueQuorumLastVersion3340053303/003"}
    logger.go:146: 2025-08-30T13:50:44.522+0900	INFO	closed test cluster.
--- PASS: TestVerifyHashKVAfterCompact (101.34s)
    --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=false (23.46s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=false/NoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=false/PeerTLS (6.62s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=false/PeerAutoTLS (5.57s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=false/ClientTLS (0.00s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=false/ClientAutoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=false/MinorityLastVersion (5.72s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=false/QuorumLastVersion (5.55s)
    --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=true (24.62s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=true/NoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=true/PeerTLS (5.70s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=true/PeerAutoTLS (6.92s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=true/ClientTLS (0.00s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=true/ClientAutoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=true/MinorityLastVersion (6.11s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=true/QuorumLastVersion (5.88s)
    --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=false (26.13s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=false/NoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=false/PeerTLS (7.39s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=false/PeerAutoTLS (6.04s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=false/ClientTLS (0.00s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=false/ClientAutoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=false/MinorityLastVersion (5.86s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=false/QuorumLastVersion (6.84s)
    --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=true (27.12s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=true/NoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=true/PeerTLS (7.36s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=true/PeerAutoTLS (5.81s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=true/ClientTLS (0.00s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=true/ClientAutoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=true/MinorityLastVersion (6.12s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=true/QuorumLastVersion (7.83s)
=== RUN   TestVerifyHashKVAfterTwoCompactsOnTombstone
    testing.go:25: Changing working directory to: /var/folders/8g/rzqb0glj7m76zbc7h30wtp_80000gn/T/TestVerifyHashKVAfterTwoCompactsOnTombstone914536006/001
=== RUN   TestVerifyHashKVAfterTwoCompactsOnTombstone/NoTLS
--
    logger.go:146: 2025-08-30T13:51:08.278+0900	INFO	closing server...	{"name": "TestVerifyHashKVAfterTwoCompactsOnTombstoneQuorumLastVersion-test-2"}
    logger.go:146: 2025-08-30T13:51:08.278+0900	INFO	removing directory	{"data-dir": "/var/folders/8g/rzqb0glj7m76zbc7h30wtp_80000gn/T/TestVerifyHashKVAfterTwoCompactsOnTombstoneQuorumLastVersion683134729/003"}
    logger.go:146: 2025-08-30T13:51:08.279+0900	INFO	closed test cluster.
--- PASS: TestVerifyHashKVAfterTwoCompactsOnTombstone (23.76s)
    --- SKIP: TestVerifyHashKVAfterTwoCompactsOnTombstone/NoTLS (0.00s)
    --- PASS: TestVerifyHashKVAfterTwoCompactsOnTombstone/PeerTLS (6.31s)
    --- PASS: TestVerifyHashKVAfterTwoCompactsOnTombstone/PeerAutoTLS (5.69s)
    --- SKIP: TestVerifyHashKVAfterTwoCompactsOnTombstone/ClientTLS (0.00s)
    --- SKIP: TestVerifyHashKVAfterTwoCompactsOnTombstone/ClientAutoTLS (0.00s)
    --- PASS: TestVerifyHashKVAfterTwoCompactsOnTombstone/MinorityLastVersion (5.44s)
    --- PASS: TestVerifyHashKVAfterTwoCompactsOnTombstone/QuorumLastVersion (6.32s)
=== RUN   TestVerifyHashKVAfterCompactOnLastTombstone
    testing.go:25: Changing working directory to: /var/folders/8g/rzqb0glj7m76zbc7h30wtp_80000gn/T/TestVerifyHashKVAfterCompactOnLastTombstone1514676280/001
=== RUN   TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0]
--
    logger.go:146: 2025-08-30T13:51:55.407+0900	INFO	closing server...	{"name": "TestVerifyHashKVAfterCompactOnLastTombstoneKeyskey0_key1QuorumLastVersion-test-2"}
    logger.go:146: 2025-08-30T13:51:55.407+0900	INFO	removing directory	{"data-dir": "/var/folders/8g/rzqb0glj7m76zbc7h30wtp_80000gn/T/TestVerifyHashKVAfterCompactOnLastTombstoneKeys=key0_key1QuorumLastVersion1127597365/003"}
    logger.go:146: 2025-08-30T13:51:55.409+0900	INFO	closed test cluster.
--- PASS: TestVerifyHashKVAfterCompactOnLastTombstone (47.13s)
    --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0] (23.78s)
        --- SKIP: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0]/NoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0]/PeerTLS (5.69s)
        --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0]/PeerAutoTLS (7.30s)
        --- SKIP: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0]/ClientTLS (0.00s)
        --- SKIP: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0]/ClientAutoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0]/MinorityLastVersion (5.61s)
        --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0]/QuorumLastVersion (5.18s)
    --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0_key1] (23.34s)
        --- SKIP: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0_key1]/NoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0_key1]/PeerTLS (7.06s)
        --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0_key1]/PeerAutoTLS (5.17s)
        --- SKIP: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0_key1]/ClientTLS (0.00s)
        --- SKIP: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0_key1]/ClientAutoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0_key1]/MinorityLastVersion (5.15s)
        --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0_key1]/QuorumLastVersion (5.96s)
=== RUN   TestVerifyHashKVAfterCompactAndDefrag
    testing.go:25: Changing working directory to: /var/folders/8g/rzqb0glj7m76zbc7h30wtp_80000gn/T/TestVerifyHashKVAfterCompactAndDefrag4166688390/001
=== RUN   TestVerifyHashKVAfterCompactAndDefrag/NoTLS
--
    logger.go:146: 2025-08-30T13:52:27.747+0900	INFO	closing server...	{"name": "TestVerifyHashKVAfterCompactAndDefragQuorumLastVersion-test-2"}
    logger.go:146: 2025-08-30T13:52:27.747+0900	INFO	removing directory	{"data-dir": "/var/folders/8g/rzqb0glj7m76zbc7h30wtp_80000gn/T/TestVerifyHashKVAfterCompactAndDefragQuorumLastVersion4156009066/003"}
    logger.go:146: 2025-08-30T13:52:27.748+0900	INFO	closed test cluster.
--- PASS: TestVerifyHashKVAfterCompactAndDefrag (32.34s)
    --- PASS: TestVerifyHashKVAfterCompactAndDefrag/NoTLS (3.29s)
    --- PASS: TestVerifyHashKVAfterCompactAndDefrag/PeerTLS (5.14s)
    --- PASS: TestVerifyHashKVAfterCompactAndDefrag/PeerAutoTLS (5.38s)
    --- PASS: TestVerifyHashKVAfterCompactAndDefrag/ClientTLS (2.70s)
    --- PASS: TestVerifyHashKVAfterCompactAndDefrag/ClientAutoTLS (2.93s)
    --- PASS: TestVerifyHashKVAfterCompactAndDefrag/MinorityLastVersion (7.38s)
    --- PASS: TestVerifyHashKVAfterCompactAndDefrag/QuorumLastVersion (5.52s)
PASS
ok  	go.etcd.io/etcd/tests/v3/common	204.921s

Integration

go test -v -count=1 -tags=integration . -run TestVerifyHashKV | grep -C 3 "PASS:"
    hashkv_test.go:44: Skipping test for single-member cluster
=== RUN   TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=true/ClientAutoTLS
    hashkv_test.go:44: Skipping test for single-member cluster
--- PASS: TestVerifyHashKVAfterCompact (10.53s)
    --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=false (2.67s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=false/NoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=false/PeerTLS (1.25s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=false/PeerAutoTLS (1.42s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=false/ClientTLS (0.00s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=false/ClientAutoTLS (0.00s)
    --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=true (2.62s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=true/NoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=true/PeerTLS (1.35s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=true/PeerAutoTLS (1.27s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=true/ClientTLS (0.00s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0]/CompactedOnTombstone=true/ClientAutoTLS (0.00s)
    --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=false (2.60s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=false/NoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=false/PeerTLS (1.26s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=false/PeerAutoTLS (1.34s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=false/ClientTLS (0.00s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=false/ClientAutoTLS (0.00s)
    --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=true (2.64s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=true/NoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=true/PeerTLS (1.22s)
        --- PASS: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=true/PeerAutoTLS (1.42s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=true/ClientTLS (0.00s)
        --- SKIP: TestVerifyHashKVAfterCompact/Keys=[key0_key1]/CompactedOnTombstone=true/ClientAutoTLS (0.00s)
=== RUN   TestVerifyHashKVAfterTwoCompactsOnTombstone
--
    hashkv_test.go:85: Skipping test for single-member cluster
=== RUN   TestVerifyHashKVAfterTwoCompactsOnTombstone/ClientAutoTLS
    hashkv_test.go:85: Skipping test for single-member cluster
--- PASS: TestVerifyHashKVAfterTwoCompactsOnTombstone (2.96s)
    --- SKIP: TestVerifyHashKVAfterTwoCompactsOnTombstone/NoTLS (0.00s)
    --- PASS: TestVerifyHashKVAfterTwoCompactsOnTombstone/PeerTLS (1.54s)
    --- PASS: TestVerifyHashKVAfterTwoCompactsOnTombstone/PeerAutoTLS (1.42s)
    --- SKIP: TestVerifyHashKVAfterTwoCompactsOnTombstone/ClientTLS (0.00s)
    --- SKIP: TestVerifyHashKVAfterTwoCompactsOnTombstone/ClientAutoTLS (0.00s)
=== RUN   TestVerifyHashKVAfterCompactOnLastTombstone
--
    hashkv_test.go:127: Skipping test for single-member cluster
=== RUN   TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0_key1]/ClientAutoTLS
    hashkv_test.go:127: Skipping test for single-member cluster
--- PASS: TestVerifyHashKVAfterCompactOnLastTombstone (5.46s)
    --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0] (2.76s)
        --- SKIP: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0]/NoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0]/PeerTLS (1.35s)
        --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0]/PeerAutoTLS (1.40s)
        --- SKIP: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0]/ClientTLS (0.00s)
        --- SKIP: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0]/ClientAutoTLS (0.00s)
    --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0_key1] (2.70s)
        --- SKIP: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0_key1]/NoTLS (0.00s)
        --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0_key1]/PeerTLS (1.39s)
        --- PASS: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0_key1]/PeerAutoTLS (1.31s)
        --- SKIP: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0_key1]/ClientTLS (0.00s)
        --- SKIP: TestVerifyHashKVAfterCompactOnLastTombstone/Keys=[key0_key1]/ClientAutoTLS (0.00s)
=== RUN   TestVerifyHashKVAfterCompactAndDefrag
--
    logger.go:146: 2025-08-30T13:54:26.225+0900	INFO	grpc	[[core] [Channel #3859 SubChannel #3860]Subchannel Connectivity change to SHUTDOWN]
    logger.go:146: 2025-08-30T13:54:26.225+0900	INFO	grpc	[[core] [Channel #3859 SubChannel #3860]Subchannel deleted]
    logger.go:146: 2025-08-30T13:54:26.225+0900	INFO	grpc	[[core] [Channel #3859]Channel deleted]
--- PASS: TestVerifyHashKVAfterCompactAndDefrag (4.79s)
    --- PASS: TestVerifyHashKVAfterCompactAndDefrag/NoTLS (0.53s)
    --- PASS: TestVerifyHashKVAfterCompactAndDefrag/PeerTLS (1.44s)
    --- PASS: TestVerifyHashKVAfterCompactAndDefrag/PeerAutoTLS (1.61s)
    --- PASS: TestVerifyHashKVAfterCompactAndDefrag/ClientTLS (0.59s)
    --- PASS: TestVerifyHashKVAfterCompactAndDefrag/ClientAutoTLS (0.62s)
PASS
ok  	go.etcd.io/etcd/tests/v3/common	24.097s

Ref

close #20551

@k8s-ci-robot
Copy link

Hi @yagikota. Thanks for your PR.

I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@yagikota yagikota marked this pull request as draft August 29, 2025 17:14
@yagikota yagikota changed the title tests: migrate hashkv tests(e2e/integration) to common test framework [WIP]tests: migrate hashkv tests(e2e/integration) to common test framework Aug 29, 2025
@yagikota yagikota force-pushed the migrate-hashkv-test branch 2 times, most recently from f6f8936 to c30ceeb Compare August 30, 2025 03:39
Comment on lines +43 to +45
if tc.config.ClusterSize < 2 {
t.Skip("Skipping test for single-member cluster")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test scope is across cluster members, so it can be skipped in the single-member case.

Comment on lines +84 to +86
if tc.config.ClusterSize < 2 {
t.Skip("Skipping test for single-member cluster")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test scope is across cluster members, so it can be skipped in the single-member case.

Comment on lines +126 to +128
if tc.config.ClusterSize < 2 {
t.Skip("Skipping test for single-member cluster")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test scope is across cluster members, so it can be skipped in the single-member case.

@yagikota yagikota force-pushed the migrate-hashkv-test branch from c30ceeb to c417fbb Compare August 30, 2025 04:14

// TestVerifyHashKVAfterTwoCompactsOnTombstone tests that HashKV is consistent
// across all members after two physical compactions on tombstone revisions.
func TestVerifyHashKVAfterTwoCompactsOnTombstone(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migrate this e2e test:

func TestVerifyHashKVAfterTwoCompactionsOnTombstone_MixVersions(t *testing.T) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before migration, this test covered only mixed-version, but now covers all cluster cases in e2eClusterTestCases or integrationClusterTestCases

Issues around compaction/tombstones/HashKV can occur even in same-binary clusters, so I think we do not need to restrict these tests to mixed-version only. 🤔


// TestVerifyHashKVAfterCompactOnLastTombstone tests that HashKV is consistent
// across all members after a physical compaction on the last tombstone revision.
func TestVerifyHashKVAfterCompactOnLastTombstone(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migrate this e2e test:

func TestVerifyHashKVAfterCompactionOnLastTombstone_MixVersions(t *testing.T) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defer clus.Close()

cc := testutils.MustClient(clus.Client())
tombstoneRevs, _ := populateDataForHashKV(t, cc, []string{"key0"})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the previous integration test, the number of operations to populate sample data was more than 1,000.

const (
// CompactionCycle is high prime used to test hash calculation between compactions.
CompactionCycle = 71
)
func TestCompactionHash(ctx context.Context, t *testing.T, h CompactionHashTestCase, compactionBatchLimit int) {
var totalRevisions int64 = 1210
assert.Less(t, int64(compactionBatchLimit), totalRevisions)
assert.Less(t, int64(CompactionCycle*10), totalRevisions)
var rev int64
for ; rev < totalRevisions; rev += CompactionCycle {
testCompactionHash(ctx, t, h, rev, rev+CompactionCycle)
}
testCompactionHash(ctx, t, h, rev, rev+totalRevisions)
}
type CompactionHashTestCase interface {
Put(ctx context.Context, key, value string) error
Delete(ctx context.Context, key string) error
HashByRev(ctx context.Context, rev int64) (KeyValueHash, error)
Defrag(ctx context.Context) error
Compact(ctx context.Context, rev int64) error
}
type KeyValueHash struct {
Hash uint32
CompactRevision int64
Revision int64
}
func testCompactionHash(ctx context.Context, t *testing.T, h CompactionHashTestCase, start, stop int64) {
for i := start; i <= stop; i++ {
if i%67 == 0 {
err := h.Delete(ctx, PickKey(i+83))
require.NoErrorf(t, err, "error on delete")
} else {
err := h.Put(ctx, PickKey(i), fmt.Sprint(i))
require.NoErrorf(t, err, "error on put")
}
}
hash1, err := h.HashByRev(ctx, stop)
require.NoErrorf(t, err, "error on hash (rev %v)", stop)
err = h.Compact(ctx, stop)
require.NoErrorf(t, err, "error on compact (rev %v)", stop)
err = h.Defrag(ctx)
require.NoErrorf(t, err, "error on defrag")
hash2, err := h.HashByRev(ctx, stop)
require.NoErrorf(t, err, "error on hash (rev %v)", stop)
assert.Equalf(t, hash1, hash2, "hashes do not match on rev %v", stop)
}

For now, we keep it at ~ 40 operations using populateDataForHashKV.

This test validates an invariant rather than throughput, so higher operation counts don't improve the quality of the test.

@yagikota yagikota marked this pull request as ready for review August 30, 2025 04:56
@yagikota yagikota changed the title [WIP]tests: migrate hashkv tests(e2e/integration) to common test framework tests: migrate hashkv tests(e2e/integration) to common test framework Aug 30, 2025
@yagikota
Copy link
Contributor Author

@serathius

Would you review this PR?

Copy link
Member

@serathius serathius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM & thx

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahrtr, serathius, yagikota

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@serathius
Copy link
Member

/ok-to-test

Copy link

codecov bot commented Aug 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.78%. Comparing base (57f21e2) to head (56231c5).
⚠️ Report is 27 commits behind head on main.

Additional details and impacted files

see 26 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #20584      +/-   ##
==========================================
- Coverage   69.15%   68.78%   -0.37%     
==========================================
  Files         420      418       -2     
  Lines       34776    34689      -87     
==========================================
- Hits        24049    23862     -187     
- Misses       9333     9437     +104     
+ Partials     1394     1390       -4     

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 57f21e2...56231c5. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yagikota
Copy link
Contributor Author

yagikota commented Aug 30, 2025

I'll fix it tomorrow.

@yagikota
Copy link
Contributor Author

yagikota commented Aug 30, 2025

/retest-required

Hmm, maybe I cannot use this command.

@yagikota
Copy link
Contributor Author

yagikota commented Aug 31, 2025

link

hashkv_test.go:175: 
        	Error Trace:	/home/prow/go/src/github.com/etcd-io/etcd/tests/common/hashkv_test.go:175
        	Error:      	Received unexpected error:
        	            	context done before matching log found: context deadline exceeded
        	Test:       	TestVerifyHashKVAfterCompactAndDefrag/ClientAutoTLS

-> Use context.WithTimeout(t.Context(), 30*time.Second) (30s timeouts) to reduce flakiness due to CI variance

@yagikota yagikota force-pushed the migrate-hashkv-test branch from c417fbb to 56231c5 Compare August 31, 2025 02:30
@yagikota
Copy link
Contributor Author

cc. @serathius @ahrtr

I fixed the failed test. Would you check it again?

@serathius serathius merged commit 963a72e into etcd-io:main Sep 1, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Migrate tests/e2e/hashkv_test.go to common testing framework
4 participants