(t *testing.T)
| 1977 | } |
| 1978 | |
| 1979 | func TestStoreCompactMaxSegments(t *testing.T) { |
| 1980 | tmpDir, _ := ioutil.TempDir("", "mossStore") |
| 1981 | defer os.RemoveAll(tmpDir) |
| 1982 | |
| 1983 | var store *Store |
| 1984 | var coll Collection |
| 1985 | |
| 1986 | var err error |
| 1987 | |
| 1988 | store, coll, err = OpenStoreCollection(tmpDir, |
| 1989 | StoreOptions{ |
| 1990 | CompactionPercentage: 100, CompactionLevelMaxSegments: 5, |
| 1991 | CompactionLevelMultiplier: 100000}, |
| 1992 | StorePersistOptions{CompactionConcern: CompactionAllow}) |
| 1993 | |
| 1994 | if err != nil || store == nil { |
| 1995 | t.Errorf("Moss-OpenStoreCollection failed, err: %v", err) |
| 1996 | } |
| 1997 | |
| 1998 | numBatches := 200 |
| 1999 | itemsPerBatch := 100 |
| 2000 | itemCount := 0 |
| 2001 | |
| 2002 | for bi := 0; bi < numBatches; bi++ { |
| 2003 | batch, err1 := coll.NewBatch(itemsPerBatch, itemsPerBatch*15) |
| 2004 | if err1 != nil { |
| 2005 | t.Errorf("Expected NewBatch() to succeed!") |
| 2006 | } |
| 2007 | |
| 2008 | for i := 0; i < itemsPerBatch; i++ { |
| 2009 | k := []byte(fmt.Sprintf("key%d", i)) |
| 2010 | v := []byte(fmt.Sprintf("val%d", i)) |
| 2011 | itemCount++ |
| 2012 | |
| 2013 | batch.Set(k, v) |
| 2014 | } |
| 2015 | |
| 2016 | err1 = coll.ExecuteBatch(batch, WriteOptions{}) |
| 2017 | if err1 != nil { |
| 2018 | t.Errorf("Expected ExecuteBatch() to work!") |
| 2019 | } |
| 2020 | waitForPersistence(coll) |
| 2021 | } |
| 2022 | |
| 2023 | sstats, err := store.Stats() |
| 2024 | if err != nil { |
| 2025 | t.Errorf("expected no stats err") |
| 2026 | } |
| 2027 | if sstats == nil { |
| 2028 | t.Errorf("expected non-nil stats") |
| 2029 | } |
| 2030 | if sstats["total_persists"].(uint64) <= 0 { |
| 2031 | t.Errorf("expected >0 total_persists") |
| 2032 | } |
| 2033 | if sstats["total_compactions"].(uint64) <= 0 { |
| 2034 | t.Errorf("expected >0 total_compactions") |
| 2035 | } |
| 2036 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…