Skip to content

Commit

Permalink
Merge "[FAB-10104] Improve LedgerConfig UT coverage"
Browse files Browse the repository at this point in the history
  • Loading branch information
christo4ferris authored and Gerrit Code Review committed May 17, 2018
2 parents d863661 + 2605dda commit e3a2b75
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions core/ledger/ledgerconfig/ledger_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit e3a2b75

Please sign in to comment.