Skip to content

Commit 8f6a397

Browse files
committed
OAK-11737: Improved RevisionsCommand test cases. Output actual applied settings. Fix include/exclude paths.
1 parent 73a948a commit 8f6a397

File tree

5 files changed

+68
-18
lines changed

5 files changed

+68
-18
lines changed

oak-run-commons/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ public static void garbageReport(DocumentNodeStore dns) {
7272

7373
public static VersionGarbageCollector createVersionGC(final DocumentNodeStore nodeStore, final VersionGCSupport gcSupport,
7474
boolean isFullGCDryRun, final DocumentNodeStoreBuilder<?> builder) {
75-
return new VersionGarbageCollector(nodeStore, gcSupport, isFullGCEnabled(builder), isFullGCDryRun,
75+
VersionGarbageCollector gc = new VersionGarbageCollector(nodeStore, gcSupport, isFullGCEnabled(builder), isFullGCDryRun,
7676
isEmbeddedVerificationEnabled(builder), builder.getFullGCMode(), builder.getFullGCDelayFactor(),
7777
builder.getFullGCBatchSize(), builder.getFullGCProgressSize(), builder.getFullGcMaxAgeMillis(),
7878
builder.getFullGCGeneration());
79+
gc.setFullGCPaths(builder.getFullGCIncludePaths(), builder.getFullGCExcludePaths());
80+
return gc;
7981
}
8082

8183
public static DocumentNodeState readNode(DocumentNodeStore documentNodeStore, Path path, RevisionVector rootRevision) {

oak-run/src/main/java/org/apache/jackrabbit/oak/run/RevisionsCommand.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -419,19 +419,19 @@ private VersionGarbageCollector bootstrapVGC(RevisionsOptions options, Closer cl
419419
useMemoryBlobStore(builder);
420420
// create a version GC that operates on a read-only DocumentNodeStore
421421
// and a GC support with a writable DocumentStore
422-
System.out.println("DryRun is enabled : " + options.isDryRun());
423-
System.out.println("EmbeddedVerification is enabled : " + options.isEmbeddedVerificationEnabled());
422+
VersionGarbageCollector gc = createVersionGC(builder.build(), gcSupport, options.isDryRun(), builder);
423+
System.out.println("DryRun is enabled : " + gc.isFullGCDryRun());
424+
System.out.println("EmbeddedVerification is enabled : " + gc.isEmbeddedVerificationEnabled());
424425
System.out.println("ResetFullGC is enabled : " + options.isResetFullGC());
425426
System.out.println("Compaction is enabled : " + options.doCompaction());
426-
System.out.println("IncludePaths are : " + Arrays.toString(options.getIncludePaths()));
427-
System.out.println("ExcludePaths are : " + Arrays.toString(options.getExcludePaths()));
428-
System.out.println("FullGcMode is : " + options.getFullGcMode());
429-
System.out.println("FullGcDelayFactory is : " + options.getFullGcDelayFactor());
430-
System.out.println("FullGcBatchSize is : " + options.getFullGcBatchSize());
431-
System.out.println("FullGcProgressSize is : " + options.getFullGcProgressSize());
427+
System.out.println("IncludePaths are : " + gc.getFullGCIncludePaths());
428+
System.out.println("ExcludePaths are : " + gc.getFullGCExcludePaths());
429+
System.out.println("FullGcMode is : " + VersionGarbageCollector.getFullGcMode());
430+
System.out.println("FullGcDelayFactor is : " + gc.getFullGcDelayFactor());
431+
System.out.println("FullGcBatchSize is : " + gc.getFullGcBatchSize());
432+
System.out.println("FullGcProgressSize is : " + gc.getFullGcProgressSize());
432433
System.out.println("FullGcMaxAgeInSecs is : " + options.getFullGcMaxAge());
433-
System.out.println("FullGcMaxAgeMillis is : " + builder.getFullGcMaxAgeMillis());
434-
VersionGarbageCollector gc = createVersionGC(builder.build(), gcSupport, options.isDryRun(), builder);
434+
System.out.println("FullGcMaxAgeMillis is : " + gc.getFullGcMaxAgeInMillis());
435435

436436
VersionGCOptions gcOptions = gc.getOptions();
437437
gcOptions = gcOptions.withDelayFactor(options.getDelay());

oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionsCommandTest.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ public void fullGC() {
195195
assertTrue(output.contains("ResetFullGC is enabled : false\n"));
196196
assertTrue(output.contains("Compaction is enabled : false\n"));
197197
assertTrue(output.contains("starting gc collect\n"));
198-
assertTrue(output.contains("IncludePaths are : [/]\n"));
198+
assertTrue(output.contains("IncludePaths are : []\n"));
199199
assertTrue(output.contains("ExcludePaths are : []\n"));
200-
assertTrue(output.contains("FullGcMode is : 0\n"));
201-
assertTrue(output.contains("FullGcDelayFactory is : 2.0\n"));
200+
assertTrue(output.contains("FullGcMode is : NONE\n"));
201+
assertTrue(output.contains("FullGcDelayFactor is : 2.0\n"));
202202
assertTrue(output.contains("FullGcBatchSize is : 1000\n"));
203203
assertTrue(output.contains("FullGcProgressSize is : 10000\n"));
204204
assertTrue(output.contains("FullGcMaxAgeInSecs is : 86400\n"));
@@ -220,7 +220,7 @@ public void fullGCWithDelayFactor() {
220220
ns.dispose();
221221

222222
String output = captureSystemOut(new RevisionsCmd("fullGC", "--fullGcDelayFactor", "2.5", "--entireRepo"));
223-
assertTrue(output.contains("FullGcDelayFactory is : 2.5\n"));
223+
assertTrue(output.contains("FullGcDelayFactor is : 2.5\n"));
224224
assertTrue(output.contains("starting gc collect"));
225225
}
226226

@@ -251,7 +251,19 @@ public void fullGCWithMode() {
251251
assertTrue(output.contains("ResetFullGC is enabled : false"));
252252
assertTrue(output.contains("Compaction is enabled : false"));
253253
assertTrue(output.contains("starting gc collect"));
254-
assertTrue(output.contains("FullGcMode is : 3"));
254+
assertTrue(output.contains("FullGcMode is : GAP_ORPHANS_EMPTYPROPS"));
255+
}
256+
257+
@Test
258+
public void fullGCWithModeAllOrphans() {
259+
ns.dispose();
260+
261+
String output = captureSystemOut(new RevisionsCmd("fullGC", "--entireRepo", "--fullGcMode", "4"));
262+
assertTrue(output.contains("DryRun is enabled : true"));
263+
assertTrue(output.contains("ResetFullGC is enabled : false"));
264+
assertTrue(output.contains("Compaction is enabled : false"));
265+
assertTrue(output.contains("starting gc collect"));
266+
assertTrue(output.contains("FullGcMode is : ALL_ORPHANS_EMPTYPROPS"));
255267
}
256268

257269
@Test

oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/FullGCMode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* Ultimately the goal is to clean up all possible garbage. After hardening these modes
2828
* might no longer be supported.
2929
*/
30-
enum FullGCMode {
30+
public enum FullGCMode {
3131
/**
3232
* no full GC is done at all
3333
*/

oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollector.java

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,45 @@ public class VersionGarbageCollector {
173173
private static FullGCMode fullGcMode = GAP_ORPHANS_EMPTYPROPS;
174174
private final long fullGcGen;
175175

176-
static FullGCMode getFullGcMode() {
176+
public static FullGCMode getFullGcMode() {
177177
return fullGcMode;
178178
}
179+
180+
public boolean isFullGCEnabled() {
181+
return fullGCEnabled;
182+
}
183+
184+
public boolean isFullGCDryRun() {
185+
return isFullGCDryRun;
186+
}
187+
188+
public boolean isEmbeddedVerificationEnabled() {
189+
return embeddedVerification;
190+
}
191+
192+
public double getFullGcDelayFactor() {
193+
return fullGCDelayFactor;
194+
}
195+
196+
public long getFullGcMaxAgeInMillis() {
197+
return fullGcMaxAgeInMillis;
198+
}
199+
200+
public int getFullGcBatchSize() {
201+
return fullGCBatchSize;
202+
}
203+
204+
public int getFullGcProgressSize() {
205+
return fullGCProgressSize;
206+
}
207+
208+
public Set<String> getFullGCIncludePaths() {
209+
return fullGCIncludePaths;
210+
}
211+
212+
public Set<String> getFullGCExcludePaths() {
213+
return fullGCExcludePaths;
214+
}
179215

180216
/**
181217
* Set the full GC mode to be used according to the provided configuration value.

0 commit comments

Comments
 (0)