Commit e3a2b752 authored by Christopher Ferris's avatar Christopher Ferris Committed by Gerrit Code Review
Browse files

Merge "[FAB-10104] Improve LedgerConfig UT coverage"

parents d8636618 2605ddac
......@@ -63,6 +63,13 @@ func TestLedgerConfigPathDefault(t *testing.T) {
testutil.AssertEquals(t,
GetBlockStorePath(),
"/var/hyperledger/production/ledgersData/chains")
testutil.AssertEquals(t,
GetPvtdataStorePath(),
"/var/hyperledger/production/ledgersData/pvtdataStore")
testutil.AssertEquals(t,
GetInternalBookkeeperPath(),
"/var/hyperledger/production/ledgersData/bookkeeper")
}
func TestLedgerConfigPath(t *testing.T) {
......@@ -84,6 +91,12 @@ func TestLedgerConfigPath(t *testing.T) {
testutil.AssertEquals(t,
GetBlockStorePath(),
"/tmp/hyperledger/production/ledgersData/chains")
testutil.AssertEquals(t,
GetPvtdataStorePath(),
"/tmp/hyperledger/production/ledgersData/pvtdataStore")
testutil.AssertEquals(t,
GetInternalBookkeeperPath(),
"/tmp/hyperledger/production/ledgersData/bookkeeper")
}
func TestGetQueryLimitDefault(t *testing.T) {
......@@ -106,6 +119,54 @@ func TestGetQueryLimit(t *testing.T) {
testutil.AssertEquals(t, updatedValue, 5000) //test config returns 5000
}
func TestMaxBatchUpdateSizeDefault(t *testing.T) {
setUpCoreYAMLConfig()
defaultValue := GetMaxBatchUpdateSize()
testutil.AssertEquals(t, defaultValue, 1000) //test default config is 1000
}
func TestMaxBatchUpdateSizeUnset(t *testing.T) {
viper.Reset()
defaultValue := GetMaxBatchUpdateSize()
testutil.AssertEquals(t, defaultValue, 500) // 500 if maxBatchUpdateSize is not set
}
func TestMaxBatchUpdateSize(t *testing.T) {
setUpCoreYAMLConfig()
defer ledgertestutil.ResetConfigToDefaultValues()
viper.Set("ledger.state.couchDBConfig.maxBatchUpdateSize", 2000)
updatedValue := GetMaxBatchUpdateSize()
testutil.AssertEquals(t, updatedValue, 2000) //test config returns 2000
}
func TestPvtdataStorePurgeIntervalDefault(t *testing.T) {
setUpCoreYAMLConfig()
defaultValue := GetPvtdataStorePurgeInterval()
testutil.AssertEquals(t, defaultValue, uint64(100)) //test default config is 100
}
func TestPvtdataStorePurgeIntervalUnset(t *testing.T) {
viper.Reset()
defaultValue := GetPvtdataStorePurgeInterval()
testutil.AssertEquals(t, defaultValue, uint64(100)) // 100 if purgeInterval is not set
}
func TestIsQueryReadHasingEnabled(t *testing.T) {
testutil.AssertEquals(t, IsQueryReadsHashingEnabled(), true)
}
func TestGetMaxDegreeQueryReadsHashing(t *testing.T) {
testutil.AssertEquals(t, GetMaxDegreeQueryReadsHashing(), uint32(50))
}
func TestPvtdataStorePurgeInterval(t *testing.T) {
setUpCoreYAMLConfig()
defer ledgertestutil.ResetConfigToDefaultValues()
viper.Set("ledger.pvtdataStore.purgeInterval", 1000)
updatedValue := GetPvtdataStorePurgeInterval()
testutil.AssertEquals(t, updatedValue, uint64(1000)) //test config returns 1000
}
func TestIsHistoryDBEnabledDefault(t *testing.T) {
setUpCoreYAMLConfig()
defaultValue := IsHistoryDBEnabled()
......@@ -134,6 +195,12 @@ func TestIsAutoWarmIndexesEnabledDefault(t *testing.T) {
testutil.AssertEquals(t, defaultValue, true) //test default config is true
}
func TestIsAutoWarmIndexesEnabledUnset(t *testing.T) {
viper.Reset()
defaultValue := IsAutoWarmIndexesEnabled()
testutil.AssertEquals(t, defaultValue, true) //test default config is true
}
func TestIsAutoWarmIndexesEnabledTrue(t *testing.T) {
setUpCoreYAMLConfig()
defer ledgertestutil.ResetConfigToDefaultValues()
......@@ -156,6 +223,12 @@ func TestGetWarmIndexesAfterNBlocksDefault(t *testing.T) {
testutil.AssertEquals(t, defaultValue, 1) //test default config is true
}
func TestGetWarmIndexesAfterNBlocksUnset(t *testing.T) {
viper.Reset()
defaultValue := GetWarmIndexesAfterNBlocks()
testutil.AssertEquals(t, defaultValue, 1) //test default config is true
}
func TestGetWarmIndexesAfterNBlocks(t *testing.T) {
setUpCoreYAMLConfig()
defer ledgertestutil.ResetConfigToDefaultValues()
......@@ -164,6 +237,10 @@ func TestGetWarmIndexesAfterNBlocks(t *testing.T) {
testutil.AssertEquals(t, updatedValue, 10)
}
func TestGetMaxBlockfileSize(t *testing.T) {
testutil.AssertEquals(t, GetMaxBlockfileSize(), 67108864)
}
func setUpCoreYAMLConfig() {
//call a helper method to load the core.yaml
ledgertestutil.SetupCoreYAMLConfig()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment