Author: tomekr Date: Tue Dec 11 08:16:21 2018 New Revision: 1848658 URL: http://svn.apache.org/viewvc?rev=1848658&view=rev Log: OAK-7953: Test failure: JdbcToSegmentWithMetadataTest.validateMigration()
Modified: jackrabbit/oak/branches/1.8/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositorySidegrade.java jackrabbit/oak/branches/1.8/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/parser/MigrationOptions.java jackrabbit/oak/branches/1.8/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/parser/OptionParserFactory.java jackrabbit/oak/branches/1.8/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/AbstractOak2OakTest.java jackrabbit/oak/branches/1.8/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/JdbcToSegmentWithMetadataTest.java Modified: jackrabbit/oak/branches/1.8/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositorySidegrade.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositorySidegrade.java?rev=1848658&r1=1848657&r2=1848658&view=diff ============================================================================== --- jackrabbit/oak/branches/1.8/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositorySidegrade.java (original) +++ jackrabbit/oak/branches/1.8/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositorySidegrade.java Tue Dec 11 08:16:21 2018 @@ -34,6 +34,7 @@ import org.apache.jackrabbit.oak.api.Com import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.plugins.document.DocumentNodeState; import org.apache.jackrabbit.oak.plugins.migration.FilteringNodeState; import org.apache.jackrabbit.oak.upgrade.nodestate.NameFilteringNodeState; import org.apache.jackrabbit.oak.plugins.migration.NodeStateCopier; @@ -517,7 +518,7 @@ public class RepositorySidegrade { private NodeState wrapNodeState(NodeState source, boolean tracePaths, boolean filterPaths) { NodeState wrapped = source; - if (migrateDocumentMetadata) { + if (migrateDocumentMetadata && source instanceof DocumentNodeState) { wrapped = MetadataExposingNodeState.wrap(wrapped); } if (!isCompleteMigration() && filterPaths) { Modified: jackrabbit/oak/branches/1.8/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/parser/MigrationOptions.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/parser/MigrationOptions.java?rev=1848658&r1=1848657&r2=1848658&view=diff ============================================================================== --- jackrabbit/oak/branches/1.8/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/parser/MigrationOptions.java (original) +++ jackrabbit/oak/branches/1.8/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/parser/MigrationOptions.java Tue Dec 11 08:16:21 2018 @@ -32,7 +32,7 @@ public class MigrationOptions { private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); - private static final boolean ADD_SECONDARY_METADATA = Boolean.getBoolean("oak.upgrade.addSecondaryMetadata"); + private static final String ADD_SECONDARY_METADATA_PROP = "oak.upgrade.addSecondaryMetadata"; private final boolean copyBinaries; @@ -94,6 +94,8 @@ public class MigrationOptions { private final Boolean srcExternalBlobs; + private final Boolean addSecondaryMetadata; + public MigrationOptions(MigrationCliArguments args) throws CliArgumentException { this.disableMmap = args.hasOption(OptionParserFactory.DISABLE_MMAP); this.copyBinaries = args.hasOption(OptionParserFactory.COPY_BINARIES); @@ -148,6 +150,12 @@ public class MigrationOptions { } else { this.srcExternalBlobs = null; } + + if (System.getProperty(ADD_SECONDARY_METADATA_PROP) == null) { + this.addSecondaryMetadata = args.hasOption(OptionParserFactory.ADD_SECONDARY_METADATA); + } else { + this.addSecondaryMetadata = Boolean.getBoolean(ADD_SECONDARY_METADATA_PROP); + } } public boolean isCopyBinaries() { @@ -218,7 +226,7 @@ public class MigrationOptions { return forceCheckpoints; } - public boolean isAddSecondaryMetadata() { return ADD_SECONDARY_METADATA; } + public boolean isAddSecondaryMetadata() { return addSecondaryMetadata; } public String getSrcUser() { return srcUser; @@ -357,7 +365,7 @@ public class MigrationOptions { log.info("Checkpoints will be migrated even with the custom paths specified"); } - if (ADD_SECONDARY_METADATA) { + if (addSecondaryMetadata) { log.info("Secondary metadata will be added"); } Modified: jackrabbit/oak/branches/1.8/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/parser/OptionParserFactory.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/parser/OptionParserFactory.java?rev=1848658&r1=1848657&r2=1848658&view=diff ============================================================================== --- jackrabbit/oak/branches/1.8/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/parser/OptionParserFactory.java (original) +++ jackrabbit/oak/branches/1.8/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/parser/OptionParserFactory.java Tue Dec 11 08:16:21 2018 @@ -84,6 +84,8 @@ public class OptionParserFactory { public static final String FORCE_CHECKPOINTS = "force-checkpoints"; + public static final String ADD_SECONDARY_METADATA = "add-secondary-metadata"; + public static OptionParser create() { OptionParser op = new OptionParser(); addUsageOptions(op); @@ -157,5 +159,6 @@ public class OptionParserFactory { op.accepts(ONLY_VERIFY, "Performs only --" + VERIFY + ", without copying content"); op.accepts(SKIP_CHECKPOINTS, "Don't copy checkpoints on the full segment->segment migration"); op.accepts(FORCE_CHECKPOINTS, "Copy checkpoints even if the --include,exclude,merge-paths option is specified"); + op.accepts(ADD_SECONDARY_METADATA, "Adds the metadata required by secondary store"); } } Modified: jackrabbit/oak/branches/1.8/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/AbstractOak2OakTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/AbstractOak2OakTest.java?rev=1848658&r1=1848657&r2=1848658&view=diff ============================================================================== --- jackrabbit/oak/branches/1.8/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/AbstractOak2OakTest.java (original) +++ jackrabbit/oak/branches/1.8/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/AbstractOak2OakTest.java Tue Dec 11 08:16:21 2018 @@ -17,6 +17,8 @@ package org.apache.jackrabbit.oak.upgrade.cli; import static java.util.Collections.singletonMap; +import static org.apache.jackrabbit.oak.plugins.document.secondary.DelegatingDocumentNodeState.PROP_LAST_REV; +import static org.apache.jackrabbit.oak.plugins.document.secondary.DelegatingDocumentNodeState.PROP_REVISION; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -46,6 +48,8 @@ import org.apache.jackrabbit.oak.commons import org.apache.jackrabbit.oak.jcr.Jcr; import org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl; import org.apache.jackrabbit.oak.plugins.document.DocumentNodeState; +import org.apache.jackrabbit.oak.plugins.document.Revision; +import org.apache.jackrabbit.oak.plugins.document.RevisionVector; import org.apache.jackrabbit.oak.plugins.index.reference.ReferenceIndexProvider; import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeState; import org.apache.jackrabbit.oak.spi.commit.CommitInfo; @@ -166,6 +170,9 @@ public abstract class AbstractOak2OakTes if (supportsCheckpointMigration()) { verifyCheckpoint(); } + if (supportsMetadataMigration()) { + verifyMetadata(); + } } public static void verifyContent(Session session) throws RepositoryException { @@ -236,6 +243,18 @@ public abstract class AbstractOak2OakTes } } + private void verifyMetadata() { + NodeState root = destination.getRoot(); + assertTrue(root.hasProperty(PROP_REVISION)); + assertTrue(root.hasProperty(PROP_LAST_REV)); + RevisionVector.fromString(root.getString(PROP_REVISION)); + Revision.fromString(root.getString(PROP_LAST_REV)); + + NodeState appsNode = destination.getRoot().getChildNode("apps"); + assertTrue(appsNode.hasProperty(PROP_LAST_REV)); + Revision.fromString(appsNode.getString(PROP_LAST_REV)); + } + private static void assertSameRecord(NodeState ns1, NodeState ns2) { String recordId1 = getRecordId(ns1); String recordId2 = getRecordId(ns2); @@ -258,4 +277,8 @@ public abstract class AbstractOak2OakTes protected boolean supportsCheckpointMigration() { return false; } + + protected boolean supportsMetadataMigration() { + return false; + } } Modified: jackrabbit/oak/branches/1.8/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/JdbcToSegmentWithMetadataTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/JdbcToSegmentWithMetadataTest.java?rev=1848658&r1=1848657&r2=1848658&view=diff ============================================================================== --- jackrabbit/oak/branches/1.8/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/JdbcToSegmentWithMetadataTest.java (original) +++ jackrabbit/oak/branches/1.8/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/JdbcToSegmentWithMetadataTest.java Tue Dec 11 08:16:21 2018 @@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.upgrad import org.apache.jackrabbit.oak.upgrade.cli.container.JdbcNodeStoreContainer; import org.apache.jackrabbit.oak.upgrade.cli.container.NodeStoreContainer; import org.apache.jackrabbit.oak.upgrade.cli.container.SegmentNodeStoreContainer; -import org.junit.BeforeClass; import java.io.IOException; @@ -29,11 +28,6 @@ public class JdbcToSegmentWithMetadataTe private final NodeStoreContainer destination; - @BeforeClass - public static void setMetadataProperty() throws IOException { - System.setProperty("oak.upgrade.addSecondaryMetadata", "true"); - } - public JdbcToSegmentWithMetadataTest() throws IOException { source = new JdbcNodeStoreContainer(); destination = new SegmentNodeStoreContainer(); @@ -52,11 +46,16 @@ public class JdbcToSegmentWithMetadataTe @Override protected String[] getArgs() { return new String[] { "--src-user", "sa", "--src-password", "pwd", source.getDescription(), - destination.getDescription() }; + destination.getDescription() , "--add-secondary-metadata"}; } @Override protected boolean supportsCheckpointMigration() { return true; } + + @Override + protected boolean supportsMetadataMigration() { + return true; + } }