Skip to content

Commit

Permalink
OAK-4706: Run tests against SEGMENT_TAR fixture
Browse files Browse the repository at this point in the history
Switch to segment-tar as default test backend

git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/oak/trunk@1757748 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mduerig committed Aug 25, 2016
1 parent 6c12877 commit 7d97bb7
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/**
* helper class that return the list of available fixtures based on the {@code nsfixtures} system
* property ({@code -Dnsfixtures=SEGMENT_MK}).
* property ({@code -Dnsfixtures=SEGMENT_TAR}).
*
* See {@link FixturesHelper.Fixture} for a list of available fixtures
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class RootFuzzIT {

@Parameters
public static Collection<Object[]> fixtures() {
return NodeStoreFixtures.asJunitParameters(EnumSet.of(Fixture.DOCUMENT_NS, Fixture.SEGMENT_MK));
return NodeStoreFixtures.asJunitParameters(EnumSet.of(Fixture.DOCUMENT_NS, Fixture.SEGMENT_TAR));
}

private static final int OP_COUNT = 5000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ public AtomicCounterIT(NodeStoreFixture fixture) {

@BeforeClass
public static void assumptions() {
assumeTrue(FIXTURES.contains(Fixture.SEGMENT_MK));
assumeTrue(FIXTURES.contains(Fixture.SEGMENT_TAR));
}

@Test
public void concurrentSegmentIncrements() throws RepositoryException, InterruptedException,
ExecutionException {
// ensuring the run only on allowed fix
assumeTrue(NodeStoreFixtures.SEGMENT_MK.equals(fixture));
assumeTrue(NodeStoreFixtures.SEGMENT_TAR.equals(fixture));

// setting-up
Session session = getAdminSession();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* 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.jcr;

import java.io.File;
import java.util.Properties;

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

import org.apache.jackrabbit.oak.Oak;
import org.apache.jackrabbit.oak.query.QueryEngineSettings;
import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders;
import org.apache.jackrabbit.oak.segment.file.FileStore;
import org.apache.jackrabbit.oak.segment.file.FileStoreBuilder;

/**
* A repository stub implementation for Oak Segment Tar
*/
public class OakSegmentTarRepositoryStub extends OakRepositoryStub {

private final FileStore store;

private final Repository repository;

/**
* Constructor as required by the JCR TCK.
*
* @param settings repository settings
* @throws RepositoryException If an error occurs.
*/
public OakSegmentTarRepositoryStub(Properties settings) throws RepositoryException {
super(settings);

Session session = null;
try {
File directory = new File("target", "segment-tar-" + System.currentTimeMillis());
this.store = FileStoreBuilder.fileStoreBuilder(directory).withMaxFileSize(1).build();
Jcr jcr = new Jcr(new Oak(SegmentNodeStoreBuilders.builder(store).build()));
QueryEngineSettings qs = new QueryEngineSettings();
qs.setFullTextComparisonWithoutIndex(true);
jcr.with(qs);
preCreateRepository(jcr);
this.repository = jcr.createRepository();

session = getRepository().login(superuser);
TestContentLoader loader = new TestContentLoader();
loader.loadTestContent(session);
} catch (Exception e) {
throw new RepositoryException(e);
} finally {
if (session != null) {
session.logout();
}
}
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
store.close();
}
}));
}

/**
* Override in base class and perform additional configuration on the
* {@link Jcr} builder before the repository is created.
*
* @param jcr the builder.
*/
protected void preCreateRepository(Jcr jcr) {
}

/**
* Returns the configured repository instance.
*
* @return the configured repository instance.
*/
@Override
public synchronized Repository getRepository() {
return repository;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import org.apache.jackrabbit.api.JackrabbitRepository;
import org.apache.jackrabbit.oak.NodeStoreFixtures;
import org.apache.jackrabbit.oak.fixture.NodeStoreFixture;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
import org.apache.jackrabbit.test.AbstractJCRTest;
import org.apache.jackrabbit.test.NotExecutableException;
Expand Down Expand Up @@ -118,7 +117,7 @@ public void testGetItem() throws Exception {
*/
@Test
public void testNodeStoreSupport() throws Exception {
NodeStore nodeStore = NodeStoreFixtures.SEGMENT_MK.createNodeStore();
NodeStore nodeStore = NodeStoreFixtures.SEGMENT_TAR.createNodeStore();
JackrabbitRepository repository = (JackrabbitRepository) new Jcr(nodeStore).createRepository();
try {
assertTrue(repository.getDescriptorValue(Repository.OPTION_NODE_AND_PROPERTY_WITH_SAME_NAME_SUPPORTED).getBoolean());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
public class ManyChildrenTest {

NodeStoreFixture fixture = NodeStoreFixtures.DOCUMENT_NS;
// NodeStoreFixture fixture = NodeStoreFixture.SEGMENT_MK;


Repository repository;
Session session;
NodeStore nodeStore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static void main(String... args) throws Exception {

// @Before
public void login() throws RepositoryException {
f1 = NodeStoreFixtures.SEGMENT_MK;
f1 = NodeStoreFixtures.SEGMENT_TAR;
f2 = getMongo();

ns1 = f1.createNodeStore();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.jackrabbit.oak.jcr.OakDocumentMemRepositoryStub;
import org.apache.jackrabbit.oak.jcr.OakDocumentRDBRepositoryStub;
import org.apache.jackrabbit.oak.jcr.OakMongoNSRepositoryStub;
import org.apache.jackrabbit.oak.jcr.OakSegmentTarRepositoryStub;
import org.apache.jackrabbit.oak.jcr.OakTarMKRepositoryStub;
import org.apache.jackrabbit.test.RepositoryHelper;
import org.apache.jackrabbit.test.RepositoryHelperPool;
Expand Down Expand Up @@ -56,6 +57,9 @@ public TCKBase(String name) {
if (FIXTURES.contains(Fixture.SEGMENT_MK)) {
Setup.wrap(this, OakTarMKRepositoryStub.class.getName());
}
if (FIXTURES.contains(Fixture.SEGMENT_TAR)) {
Setup.wrap(this, OakSegmentTarRepositoryStub.class.getName());
}
if (FIXTURES.contains(Fixture.DOCUMENT_NS)) {
if (OakMongoNSRepositoryStub.isMongoDBAvailable()) {
Setup.wrap(this, OakMongoNSRepositoryStub.class.getName());
Expand Down
4 changes: 2 additions & 2 deletions oak-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
<!-- specifies on which fixture to run the integration testing tests.
override in profiles or provide from command line to change behaviour. Provide
more fixtures space separated. See org.apache.jackrabbit.oak.jcr.FixturesHelper#AVAILABLE_FIXTURES
for the possible values: SEGMENT_MK DOCUMENT_NS DOCUMENT_RDB -->
<fixtures>SEGMENT_MK</fixtures>
for the possible values: SEGMENT_MK SEGMENT_TAR DOCUMENT_NS DOCUMENT_RDB -->
<fixtures>SEGMENT_TAR</fixtures>

<!-- whether skip the surefire unit testing during the integration testing.
Override with -Dsurefire.skip.ut=true when needed -->
Expand Down
2 changes: 1 addition & 1 deletion oak-remote/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<packaging>bundle</packaging>

<properties>
<fixtures>MEMORY_NS,SEGMENT_MK</fixtures>
<fixtures>MEMORY_NS,SEGMENT_TAR</fixtures>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.commons.io.FileUtils.byteCountToDisplaySize;
import static org.apache.jackrabbit.oak.api.Type.STRING;
import static org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture.SEGMENT_MK;
import static org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture.SEGMENT_TAR;
import static org.apache.jackrabbit.oak.commons.FixturesHelper.getFixtures;
import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
import static org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions.defaultGCOptions;
Expand Down Expand Up @@ -77,6 +77,7 @@
import org.apache.jackrabbit.oak.stats.Clock;
import org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider;
import org.apache.jackrabbit.oak.stats.StatisticsProvider;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -96,8 +97,9 @@ private File getFileStoreFolder() {
return folder.getRoot();
}

@BeforeClass
public static void assumptions() {
assumeTrue(getFixtures().contains(SEGMENT_MK));
assumeTrue(getFixtures().contains(SEGMENT_TAR));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.apache.jackrabbit.oak.segment;

import static org.apache.jackrabbit.oak.commons.CIHelper.travis;
import static org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture.SEGMENT_MK;
import static org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture.SEGMENT_TAR;
import static org.apache.jackrabbit.oak.segment.file.FileStoreBuilder.fileStoreBuilder;
import static org.junit.Assume.assumeTrue;

Expand All @@ -32,7 +32,6 @@
import java.util.concurrent.atomic.AtomicBoolean;

import org.apache.jackrabbit.oak.api.Blob;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.commons.FixturesHelper;
import org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture;
import org.apache.jackrabbit.oak.segment.file.FileStore;
Expand All @@ -58,7 +57,7 @@ private File getFileStoreFolder() {
@BeforeClass
public static void checkFixtures() {
assumeTrue(!travis()); // FIXME OAK-2375. Often fails on Travis
assumeTrue(FIXTURES.contains(SEGMENT_MK));
assumeTrue(FIXTURES.contains(SEGMENT_TAR));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Sets.newTreeSet;
import static org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture.SEGMENT_MK;
import static org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture.SEGMENT_TAR;
import static org.apache.jackrabbit.oak.commons.FixturesHelper.getFixtures;
import static org.apache.jackrabbit.oak.segment.file.FileStoreBuilder.fileStoreBuilder;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -62,7 +62,7 @@ private File getFileStoreFolder() {

@BeforeClass
public static void assumptions() {
assumeTrue(getFixtures().contains(SEGMENT_MK));
assumeTrue(getFixtures().contains(SEGMENT_TAR));
}

@Test
Expand Down

0 comments on commit 7d97bb7

Please sign in to comment.