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
@@ -0,0 +1,39 @@
/*
* 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.ignite.compatibility.testframework.plugins;

import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.processors.rollingupgrade.RollingUpgradeProcessor;
import org.apache.ignite.spi.IgniteNodeValidationResult;
import org.jetbrains.annotations.Nullable;

/** Disabled rolling upgrade processor. */
public class DisabledRollingUpgradeProcessor extends RollingUpgradeProcessor {
/**
* @param ctx Kernal context.
*/
public DisabledRollingUpgradeProcessor(GridKernalContext ctx) {
super(ctx);
}

/** {@inheritDoc} */
@Nullable @Override public IgniteNodeValidationResult validateNode(ClusterNode node) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@ public class TestCompatibilityPluginProvider implements PluginProvider {
/** {@inheritDoc} */
@Nullable @Override public Object createComponent(PluginContext ctx, Class cls) {
if (DiscoveryNodeValidationProcessor.class == cls)
return new DisabledValidationProcessor(kCtx);
try {
Class.forName("org.apache.ignite.internal.processors.rollingupgrade.RollingUpgradeProcessor");

return new DisabledRollingUpgradeProcessor(kCtx);
}
Comment thread
timoninmaxim marked this conversation as resolved.
catch (ClassNotFoundException ignore) {
return new DisabledValidationProcessor(kCtx);
}

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.function.BiFunction;
import java.util.function.Function;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.failure.FailureContext;
Expand All @@ -38,6 +39,7 @@
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.typedef.CI3;
import org.apache.ignite.internal.util.typedef.F;
Expand Down Expand Up @@ -150,7 +152,14 @@ public DistributedProcess(
initCoordinator(p, topVer);

try {
IgniteInternalFuture<R> fut = exec.apply((I)msg.request());
IgniteInternalFuture<R> fut;

if (ctx.rollingUpgrade().enabled()) {
fut = new GridFinishedFuture<>(new IgniteException("Failed to start distributed process "
+ type + ": rolling upgrade is enabled"));
}
else
fut = exec.apply((I)msg.request());

fut.listen(() -> {
if (fut.error() != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* 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.ignite.internal.processors.cache.persistence.snapshot;

import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;

import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause;

/** */
public class IgniteSnapshotRollingUpgradeTest extends GridCommonAbstractTest {
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

cfg.setDataStorageConfiguration(new DataStorageConfiguration()
.setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)));

return cfg;
}

/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
stopAllGrids();

cleanPersistenceDir();
}

/** Tests that snapshot creation fails when rolling upgrade is enabled. */
@Test
public void testSnapshotCreationFailsDuringRollingUpgrade() throws Exception {
IgniteEx srv = startGrid(0);

srv.cluster().state(ClusterState.ACTIVE);

IgniteProductVersion curVer = srv.context().discovery().localNode().version();

IgniteProductVersion targetVer = IgniteProductVersion.fromString(curVer.major()
+ "." + curVer.minor()
+ "." + curVer.maintenance() + 1);

srv.context().rollingUpgrade().enable(targetVer, false);

assertTrue(srv.context().rollingUpgrade().enabled());

Throwable ex = assertThrowsWithCause(
() -> srv.snapshot().createSnapshot("test").get(getTestTimeout()),
IgniteException.class
);

assertTrue(ex.getMessage().contains("Failed to start distributed process START_SNAPSHOT: rolling upgrade is enabled"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManagerSelfTest;
import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotRemoteRequestTest;
import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotRestoreFromRemoteTest;
import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotRollingUpgradeTest;
import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotWithMetastorageTest;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.DynamicSuite;
Expand Down Expand Up @@ -56,5 +57,6 @@ public static void addSnapshotTests(List<Class<?>> suite, Collection<Class> igno
GridTestUtils.addTestIfNeeded(suite, IgniteClusterSnapshotRestoreSelfTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, IgniteClusterSnapshotHandlerTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, IgniteSnapshotRestoreFromRemoteTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, IgniteSnapshotRollingUpgradeTest.class, ignoredTests);
}
}
Loading