Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
package org.apache.jackrabbit.oak.scalability.suites;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import java.util.stream.Collectors;

import javax.jcr.Node;
import javax.jcr.NodeIterator;
Expand All @@ -49,8 +51,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.jackrabbit.guava.common.base.Splitter;

/**
* The suite test will incrementally increase the load and execute searches.
* Each test run thus adds nodes and executes different benchmarks. This way we measure time
Expand Down Expand Up @@ -99,8 +99,10 @@ public class ScalabilityNodeRelationshipSuite extends ScalabilityNodeSuite {
public static final String OBJECT_ID = "objectId";
public static final String TARGET = "target";

protected static final List<String> NODE_LEVELS = Splitter.on(",").trimResults()
.omitEmptyStrings().splitToList(System.getProperty("nodeLevels", "10,5,2,1"));
protected static final List<String> NODE_LEVELS = Arrays.stream(System.getProperty("nodeLevels", "10,5,2,1").split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.collect(Collectors.toList());

protected static final List<String> NODE_LEVELS_DEFAULT = List.of("10","5","2","1");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
package org.apache.jackrabbit.oak.scalability.suites;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import javax.jcr.Node;
import javax.jcr.PropertyType;
Expand All @@ -34,8 +36,6 @@
import javax.jcr.Session;

import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.guava.common.base.Splitter;

import org.apache.commons.math3.stat.descriptive.SynchronizedDescriptiveStatistics;
import org.apache.jackrabbit.commons.JcrUtils;
import org.apache.jackrabbit.oak.Oak;
Expand Down Expand Up @@ -108,8 +108,10 @@ public class ScalabilityNodeSuite extends ScalabilityAbstractSuite {
/**
* Controls the number of nodes at each level
*/
protected static final List<String> NODE_LEVELS = Splitter.on(",").trimResults()
.omitEmptyStrings().splitToList(System.getProperty("nodeLevels", "10,5,2"));
protected static final List<String> NODE_LEVELS = Arrays.stream(System.getProperty("nodeLevels", "10,5,2").split(","))
.map(String::trim)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course the above should be refactored to be there just once, and to use the SystemPropertySupplies, but that would be a different ticket.

.filter(s -> !s.isEmpty())
.collect(Collectors.toList());

/**
* Controls the number of concurrent tester threads
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.jackrabbit.oak.scalability.suites;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import static org.junit.Assert.assertEquals;

/**
* Test suite for ScalabilityNodeRelationshipSuite
*/
public class ScalabilityNodeRelationshipSuiteTest {

private String originalNodeLevelsProperty;

@Before
public void saveOriginalProperty() {
originalNodeLevelsProperty = System.getProperty("nodeLevels");
}

@After
public void restoreOriginalProperty() {
if (originalNodeLevelsProperty == null) {
System.clearProperty("nodeLevels");
} else {
System.setProperty("nodeLevels", originalNodeLevelsProperty);
}
}

@Test
public void testDefaultNodeLevels() throws Exception {
System.clearProperty("nodeLevels");

// Create a new instance to initialize static fields
new TestScalabilityNodeRelationshipSuite();

Field nodeLevelsField = ScalabilityNodeRelationshipSuite.class.getDeclaredField("NODE_LEVELS");
nodeLevelsField.setAccessible(true);
List<String> nodeLevels = (List<String>) nodeLevelsField.get(null);

// Clear and populate the list with new values
nodeLevels.clear();
nodeLevels.addAll(getNodeLevels(System.getProperty("nodeLevels", "10,5,2,1")));

assertEquals(4, nodeLevels.size());
assertEquals("10", nodeLevels.get(0));
assertEquals("5", nodeLevels.get(1));
assertEquals("2", nodeLevels.get(2));
assertEquals("1", nodeLevels.get(3));
}

@Test
public void testCustomNodeLevels() throws Exception {
System.setProperty("nodeLevels", "20,10,5,2");

// Create a new instance to initialize static fields
new TestScalabilityNodeRelationshipSuite();

Field nodeLevelsField = ScalabilityNodeRelationshipSuite.class.getDeclaredField("NODE_LEVELS");
nodeLevelsField.setAccessible(true);
List<String> nodeLevels = (List<String>) nodeLevelsField.get(null);

// Clear and populate the list with new values
nodeLevels.clear();
nodeLevels.addAll(getNodeLevels(System.getProperty("nodeLevels", "10,5,2,1")));

assertEquals(4, nodeLevels.size());
assertEquals("20", nodeLevels.get(0));
assertEquals("10", nodeLevels.get(1));
assertEquals("5", nodeLevels.get(2));
assertEquals("2", nodeLevels.get(3));
}

@Test
public void testWhitespaceTrimmingInNodeLevels() throws Exception {
System.setProperty("nodeLevels", " 15 , 8 , 4 , 2 ");

// Create a new instance to initialize static fields
new TestScalabilityNodeRelationshipSuite();

Field nodeLevelsField = ScalabilityNodeRelationshipSuite.class.getDeclaredField("NODE_LEVELS");
nodeLevelsField.setAccessible(true);
List<String> nodeLevels = (List<String>) nodeLevelsField.get(null);

// Clear and populate the list with new values
nodeLevels.clear();
nodeLevels.addAll(getNodeLevels(System.getProperty("nodeLevels", "10,5,2,1")));

assertEquals(4, nodeLevels.size());
assertEquals("15", nodeLevels.get(0));
assertEquals("8", nodeLevels.get(1));
assertEquals("4", nodeLevels.get(2));
assertEquals("2", nodeLevels.get(3));
}

@Test
public void testEmptyValuesFiltering() throws Exception {
System.setProperty("nodeLevels", "25,,10,,3");

// Create a new instance to initialize static fields
new TestScalabilityNodeRelationshipSuite();

Field nodeLevelsField = ScalabilityNodeRelationshipSuite.class.getDeclaredField("NODE_LEVELS");
nodeLevelsField.setAccessible(true);
List<String> nodeLevels = (List<String>) nodeLevelsField.get(null);

// Clear and populate the list with new values
nodeLevels.clear();
nodeLevels.addAll(getNodeLevels(System.getProperty("nodeLevels", "10,5,2,1")));

assertEquals(3, nodeLevels.size());
assertEquals("25", nodeLevels.get(0));
assertEquals("10", nodeLevels.get(1));
assertEquals("3", nodeLevels.get(2));
}

@Test
public void testDifferentNumberOfLevels() throws Exception {
System.setProperty("nodeLevels", "50,25,10");

// Create a new instance to initialize static fields
new TestScalabilityNodeRelationshipSuite();

Field nodeLevelsField = ScalabilityNodeRelationshipSuite.class.getDeclaredField("NODE_LEVELS");
nodeLevelsField.setAccessible(true);
List<String> nodeLevels = (List<String>) nodeLevelsField.get(null);

// Clear and populate the list with new values
nodeLevels.clear();
nodeLevels.addAll(getNodeLevels(System.getProperty("nodeLevels", "10,5,2,1")));

assertEquals(3, nodeLevels.size());
assertEquals("50", nodeLevels.get(0));
assertEquals("25", nodeLevels.get(1));
assertEquals("10", nodeLevels.get(2));
}

private List<String> getNodeLevels(String value) {
return Arrays.stream(System.getProperty("nodeLevels", "10,5,2,1").split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.collect(Collectors.toList());
}

// Test subclass to access protected members
private static class TestScalabilityNodeRelationshipSuite extends ScalabilityNodeRelationshipSuite {
public TestScalabilityNodeRelationshipSuite() {
super(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.jackrabbit.guava.common.base.Splitter;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -140,9 +140,11 @@ public static void main(String[] args) throws Exception {
Map<String, List<String>> argmap = new HashMap<>();
// Split the args to get suites and benchmarks (i.e. suite:benchmark1,benchmark2)
for(String arg : argset) {
List<String> tokens = Splitter.on(":").limit(2).splitToList(arg);
List<String> tokens = Arrays.stream(arg.split(":", 2)).collect(Collectors.toList());
if (tokens.size() > 1) {
argmap.put(tokens.get(0), Splitter.on(",").trimResults().splitToList(tokens.get(1)));
argmap.put(tokens.get(0), Arrays.stream(tokens.get(1).split(","))
.map(String::trim)
.collect(Collectors.toList()));
} else {
argmap.put(tokens.get(0), null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -29,15 +30,14 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;

import javax.jcr.Credentials;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;

import org.apache.jackrabbit.guava.common.base.Splitter;

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import org.apache.commons.math3.stat.descriptive.SynchronizedDescriptiveStatistics;
import org.apache.jackrabbit.oak.benchmark.CSVResultGenerator;
Expand Down Expand Up @@ -102,8 +102,10 @@ public abstract class ScalabilityAbstractSuite implements ScalabilitySuite, CSVR
/**
* Controls the incremental load for each iteration
*/
protected static final List<String> INCREMENTS = Splitter.on(",").trimResults()
.omitEmptyStrings().splitToList(System.getProperty("increments", "1,2,5"));
protected static final List<String> INCREMENTS = Arrays.stream(System.getProperty("increments", "1,2,5").split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.collect(Collectors.toList());

protected static final Credentials CREDENTIALS = new SimpleCredentials("admin", "admin"
.toCharArray());
Expand Down
Loading
Loading