-
Notifications
You must be signed in to change notification settings - Fork 10.2k
tests: migrate hashkv tests(e2e/integration) to common test framework #20584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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 Once the patch is verified, the new status will be reflected by the 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. |
f6f8936
to
c30ceeb
Compare
if tc.config.ClusterSize < 2 { | ||
t.Skip("Skipping test for single-member cluster") | ||
} |
There was a problem hiding this comment.
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.
if tc.config.ClusterSize < 2 { | ||
t.Skip("Skipping test for single-member cluster") | ||
} |
There was a problem hiding this comment.
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.
if tc.config.ClusterSize < 2 { | ||
t.Skip("Skipping test for single-member cluster") | ||
} |
There was a problem hiding this comment.
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.
c30ceeb
to
c417fbb
Compare
|
||
// TestVerifyHashKVAfterTwoCompactsOnTombstone tests that HashKV is consistent | ||
// across all members after two physical compactions on tombstone revisions. | ||
func TestVerifyHashKVAfterTwoCompactsOnTombstone(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migrate this e2e test:
Line 102 in 991ea7e
func TestVerifyHashKVAfterTwoCompactionsOnTombstone_MixVersions(t *testing.T) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migrate this e2e test:
Line 139 in 991ea7e
func TestVerifyHashKVAfterCompactionOnLastTombstone_MixVersions(t *testing.T) { |
There was a problem hiding this comment.
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"}) |
There was a problem hiding this comment.
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.
etcd/server/storage/mvcc/testutil/hash.go
Lines 31 to 83 in 991ea7e
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.
Would you review this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM & thx
[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 |
/ok-to-test |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted filessee 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.
🚀 New features to boost your workflow:
|
I'll fix it tomorrow. |
/retest-required
|
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 |
Signed-off-by: Kota <[email protected]>
c417fbb
to
56231c5
Compare
cc. @serathius @ahrtr I fixed the failed test. Would you check it again? |
What
Migrate HashKV tests to the common test framework and remove legacy e2e/integration suites.
Test Migration Mapping
Cluster-wide consistency check:
TestVerifyHashKVAfterCompact
: Ensure that HashKV is consistent across all members after a physical compactionTestVerifyHashKVAfterTwoCompactsOnTombstone
: 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
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-> minor version of
/etcd-last-release
can be calculated like this: 7 - 1 = 6Check the latest
v3.6.*
versionInstall etcd
v3.6.4
as/etcd-last-release
Check versions
Before Migration
E2E
Integration
After Migration
E2E
Integration
Ref
close #20551