Skip to content

Commit

Permalink
XWIKI-20477: Upgrade to Solr 9.4.1 and Lucene 9.8.0
Browse files Browse the repository at this point in the history
* fix solr cores migration
* add upgrade test (still need to explicitly check if the data can be found in the new cores but it was checked by hand)
  • Loading branch information
tmortagne committed Feb 15, 2024
1 parent bfb1bf3 commit ae68fec
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ protected void initializeCoreSchema() throws SolrException
@Override
public void migrate(XWikiSolrCore sourceCore, XWikiSolrCore targetCore) throws SolrException
{
// Set the current core
this.core = targetCore;

// Migrate the field types
migrateFieldTypes(sourceCore, targetCore);

Expand Down Expand Up @@ -384,10 +387,10 @@ private void migrateFields(XWikiSolrCore sourceCore, XWikiSolrCore targetCore) t
private void migrateFields(XWikiSolrCore sourceCore, XWikiSolrCore targetCore, boolean dynamic) throws SolrException
{
Map<String, Map<String, Object>> sourceFields =
dynamic ? this.solrSchemaUtils.getDynamicFields(this.core, false)
dynamic ? this.solrSchemaUtils.getDynamicFields(targetCore, false)
: this.solrSchemaUtils.getFields(sourceCore, false);
Map<String, Map<String, Object>> targetFields =
dynamic ? this.solrSchemaUtils.getDynamicFields(this.core, false)
dynamic ? this.solrSchemaUtils.getDynamicFields(targetCore, false)
: this.solrSchemaUtils.getFields(targetCore, false);
for (Map.Entry<String, Map<String, Object>> entry : sourceFields.entrySet()) {
if (!targetFields.containsKey(entry.getKey())) {
Expand Down Expand Up @@ -478,7 +481,14 @@ private void delete(SolrDocumentList documents, XWikiSolrCore core) throws SolrE
*/
protected void migrate(SolrDocument sourceDocument, SolrInputDocument targetDocument)
{
sourceDocument.getFieldValueMap().forEach(targetDocument::setField);
// The map returned by #getFieldValueMap() does not implement #entrySet
for (String fieldName : sourceDocument.getFieldNames()) {
// Fix special fields:
// * _version_: internal Solr field used for atomic updates
if (!fieldName.equals("_version_")) {
targetDocument.setField(fieldName, sourceDocument.getFieldValue(fieldName));
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private synchronized XWikiSolrCore getCore(String xwikiCoreName, int majorVersio
// Resolve the real Solr core name
String solrCoreName = toSolrCoreName(xwikiCoreName, majorVersion);

// Create the client
// Get the existing client
SolrClient solrClient = getInternalSolrClient(solrCoreName);

// Initialize the client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ public void initialize() throws InitializationException
recreateSearchCore();
}
} else {
// Remove search cores from previous locations
Path pre1601Path = this.solrHomePath.resolve(SolrClientInstance.CORE_NAME);
if (Files.exists(pre1601Path)) {
FileUtils.deleteDirectory(pre1601Path.toFile());
}

// Create the new search core
createSearchCore();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<module>xwiki-platform-distribution-flavor-test-upgrade-1410</module>
<module>xwiki-platform-distribution-flavor-test-upgrade-1310</module>
<module>xwiki-platform-distribution-flavor-test-upgrade-1210</module>
<module>xwiki-platform-distribution-flavor-test-upgrade-1210-custom</module>
<module>xwiki-platform-distribution-flavor-test-upgrade-1110</module>
<module>xwiki-platform-distribution-flavor-test-upgrade-1011</module>
<module>xwiki-platform-distribution-flavor-test-upgrade-911</module>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-distribution-flavor-test-upgrade</artifactId>
<version>16.1.0-SNAPSHOT</version>
</parent>
<artifactId>xwiki-platform-distribution-flavor-test-upgrade-1210</artifactId>
<name>XWiki Platform - Distribution - Flavor - Functional Tests - Upgrade - From ${upgradetest.previousflavor.version} with custom data</name>
<packaging>pom</packaging>
<description>XWiki Platform - Distribution - Flavor - Functional Tests - Upgrade - From ${upgradetest.previousflavor.version} with custom data</description>
<properties>
<upgradetest.previousflavor.version>12.10.11</upgradetest.previousflavor.version>
<upgradetest.previousdata.classifier>custom-0</upgradetest.previousdata.classifier>
</properties>
<dependencies>
<dependency>
<groupId>${upgradetest.previousdata.groupId}</groupId>
<artifactId>${upgradetest.previousdata.artifactId}</artifactId>
<!-- Using a fixed version instead of ${upgradetest.previousflavor.version} because of
https://issues.apache.org/jira/browse/MRELEASE-799, causing "The artifact (...) requires a different
version (...) than what is found (...) for the expression (upgradetest.previousflavor.version) in the
project (...)" otherwise, when using the release plugin -->
<version>12.10.11</version>
<type>zip</type>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Step 1: Compile the JUnit Selenium Tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<!-- Step 2: Process the test resources -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
<!-- Step 3: Prepare the application -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<!-- Step 4: Execute the tests (they start/stop XWiki) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.test.ui;

/**
* Execute upgrade tests.
*
* @version $Id$
*/
public class Upgrade1210Test extends UpgradeTest
{
@Override
protected void setupLogs()
{
validateConsole.getLogCaptureConfiguration().registerExpected(
// Caused by the fact that we upgrade from an old version of XWiki having these deprecated uses
"Deprecated usage of getter [com.xpn.xwiki.api.Document.getName]",

// Those deprecated are related to the Velocity upgrade performed in 12.0 (XCOMMONS-1529)
"Deprecated usage of method [org.apache.velocity.tools.generic.SortTool.sort]",
"Deprecated usage of getter [org.xwiki.velocity.tools.CollectionsTool.getSet]",
"Deprecated usage of method [org.apache.velocity.tools.generic.MathTool.toInteger]",
"Deprecated usage of method [org.xwiki.velocity.tools.CollectionsTool.sort]",

// The currently installed flavor is not valid anymore before the upgrade
"Invalid extension [org.xwiki.platform:xwiki-platform-distribution-flavor-mainwiki/10.11.1] on namespace "
+ "[wiki:xwiki] (InvalidExtensionException: Dependency [org.xwiki.platform:xwiki-platform-oldcore-"
+ "[10.11.1]] is incompatible with the core extension [org.xwiki.platform:xwiki-platform-legacy-oldcore");
}
}

0 comments on commit ae68fec

Please sign in to comment.