Skip to content

Commit f2a3ed6

Browse files
committed
[FAB-10094] Add tests for rebuilding ledger components
This CR adds tests for dropping and rebuling different ledger components such as statedb, block storage indexes, and config history db. This CR also adds test that makes sure that v1.2 can work with and rebuild components from ledger created by v1.1 code Change-Id: Ieeadba0b458c896bde3d07fba07c329bae05cf91 Signed-off-by: manish <manish.sethi@gmail.com>
1 parent 4853a5e commit f2a3ed6

File tree

20 files changed

+201
-0
lines changed

20 files changed

+201
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package tests
8+
9+
import (
10+
"testing"
11+
)
12+
13+
func TestRebuildComponents(t *testing.T) {
14+
env := newEnv(defaultConfig, t)
15+
defer env.cleanup()
16+
17+
h1, h2 := newTestHelperCreateLgr("ledger1", t), newTestHelperCreateLgr("ledger2", t)
18+
dataHelper := newSampleDataHelper(t)
19+
20+
dataHelper.populateLedger(h1)
21+
dataHelper.populateLedger(h2)
22+
23+
dataHelper.verifyLedgerContent(h1)
24+
dataHelper.verifyLedgerContent(h2)
25+
26+
t.Run("rebuild only statedb",
27+
func(t *testing.T) {
28+
env.closeAllLedgersAndDrop(rebuildableStatedb)
29+
h1, h2 := newTestHelperOpenLgr("ledger1", t), newTestHelperOpenLgr("ledger2", t)
30+
dataHelper.verifyLedgerContent(h1)
31+
dataHelper.verifyLedgerContent(h2)
32+
},
33+
)
34+
35+
t.Run("rebuild statedb and config history",
36+
func(t *testing.T) {
37+
env.closeAllLedgersAndDrop(rebuildableStatedb + rebuildableConfigHistory)
38+
h1, h2 := newTestHelperOpenLgr("ledger1", t), newTestHelperOpenLgr("ledger2", t)
39+
dataHelper.verifyLedgerContent(h1)
40+
dataHelper.verifyLedgerContent(h2)
41+
},
42+
)
43+
44+
t.Run("rebuild statedb and block index",
45+
func(t *testing.T) {
46+
env.closeAllLedgersAndDrop(rebuildableStatedb + rebuildableBlockIndex)
47+
h1, h2 := newTestHelperOpenLgr("ledger1", t), newTestHelperOpenLgr("ledger2", t)
48+
dataHelper.verifyLedgerContent(h1)
49+
dataHelper.verifyLedgerContent(h2)
50+
},
51+
)
52+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#SPDX-License-Identifier: Apache-2.0
2+
3+
# level db snapshot contains '.log' files
4+
!**/*.log
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MANIFEST-000000

core/ledger/kvledger/tests/testdata/v11/sample_ledgers/ledgersData/historyLeveldb/000001.log

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MANIFEST-000000

0 commit comments

Comments
 (0)