This is an automated email from the ASF dual-hosted git repository. dlmarion pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
commit 2b0db6f3e598e6a210e509f5b341e64a5631375a Merge: 00381f90e2 bc8df24ff8 Author: Dave Marion <dlmar...@apache.org> AuthorDate: Fri Apr 4 21:28:59 2025 +0000 Merge branch '2.1' .../apache/accumulo/server/util/UpgradeUtil.java | 4 +- .../accumulo/test/upgrade/UpgradeUtilIT.java | 101 +++++++++++++++++++++ 2 files changed, 103 insertions(+), 2 deletions(-) diff --cc server/base/src/main/java/org/apache/accumulo/server/util/UpgradeUtil.java index 6cc1537b75,db97283b30..b4dd2e0a27 --- a/server/base/src/main/java/org/apache/accumulo/server/util/UpgradeUtil.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/UpgradeUtil.java @@@ -18,18 -18,21 +18,18 @@@ */ package org.apache.accumulo.server.util; -import org.apache.accumulo.core.Constants; +import static org.apache.accumulo.core.Constants.ZFATE; +import static org.apache.accumulo.core.Constants.ZPREPARE_FOR_UPGRADE; + - import org.apache.accumulo.core.cli.Help; + import org.apache.accumulo.core.cli.ConfigOpts; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.conf.SiteConfiguration; -import org.apache.accumulo.core.data.InstanceId; -import org.apache.accumulo.core.fate.zookeeper.ServiceLock; -import org.apache.accumulo.core.fate.zookeeper.ServiceLock.ServiceLockPath; import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter; import org.apache.accumulo.core.fate.zookeeper.ZooUtil.NodeExistsPolicy; -import org.apache.accumulo.core.volume.VolumeConfiguration; -import org.apache.accumulo.server.fs.VolumeManager; +import org.apache.accumulo.core.zookeeper.ZooSession; +import org.apache.accumulo.server.ServerContext; import org.apache.accumulo.server.security.SecurityUtil; import org.apache.accumulo.start.spi.KeywordExecutable; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.Path; import org.apache.zookeeper.KeeperException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --cc test/src/main/java/org/apache/accumulo/test/upgrade/UpgradeUtilIT.java index 0000000000,89671ff24f..73037661ec mode 000000,100644..100644 --- a/test/src/main/java/org/apache/accumulo/test/upgrade/UpgradeUtilIT.java +++ b/test/src/main/java/org/apache/accumulo/test/upgrade/UpgradeUtilIT.java @@@ -1,0 -1,102 +1,101 @@@ + /* + * 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 + * + * https://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.accumulo.test.upgrade; + + import static org.junit.jupiter.api.Assertions.assertEquals; + import static org.junit.jupiter.api.Assertions.assertFalse; + import static org.junit.jupiter.api.Assertions.assertThrows; + import static org.junit.jupiter.api.Assertions.assertTrue; + + import java.util.UUID; + + import org.apache.accumulo.core.Constants; ++import org.apache.accumulo.core.fate.zookeeper.ZooReader; ++import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter; + import org.apache.accumulo.core.fate.zookeeper.ZooUtil.NodeExistsPolicy; + import org.apache.accumulo.harness.AccumuloClusterHarness; + import org.apache.accumulo.minicluster.ServerType; + import org.apache.accumulo.server.ServerContext; + import org.apache.accumulo.server.util.UpgradeUtil; + import org.apache.accumulo.test.util.Wait; + import org.junit.jupiter.api.Test; + + public class UpgradeUtilIT extends AccumuloClusterHarness { + + @Test + public void testPrepareFailsDueToManagerUp() throws Exception { + ServerContext ctx = getCluster().getServerContext(); ++ ZooReader zr = ctx.getZooSession().asReader(); ++ ZooReaderWriter zrw = ctx.getZooSession().asReaderWriter(); + - ctx.getZooReaderWriter().putPersistentData( - ctx.getZooKeeperRoot() + Constants.ZPREPARE_FOR_UPGRADE, new byte[0], - NodeExistsPolicy.SKIP); - assertTrue(ctx.getZooReader().exists(ctx.getZooKeeperRoot() + Constants.ZPREPARE_FOR_UPGRADE)); ++ zrw.putPersistentData(Constants.ZPREPARE_FOR_UPGRADE, new byte[0], NodeExistsPolicy.SKIP); ++ assertTrue(zr.exists(Constants.ZPREPARE_FOR_UPGRADE)); + + System.setProperty("accumulo.properties", "file://" + getCluster().getAccumuloPropertiesPath()); + IllegalStateException ise = assertThrows(IllegalStateException.class, + () -> new UpgradeUtil().execute(new String[] {"--prepare"})); + assertEquals("Manager is running, shut it down and retry this operation", ise.getMessage()); - assertFalse(ctx.getZooReader().exists(ctx.getZooKeeperRoot() + Constants.ZPREPARE_FOR_UPGRADE)); ++ assertFalse(zr.exists(Constants.ZPREPARE_FOR_UPGRADE)); + + } + + @Test + public void testPrepareFailsDueToFateTransactions() throws Exception { + ServerContext ctx = getCluster().getServerContext(); ++ ZooReader zr = ctx.getZooSession().asReader(); ++ ZooReaderWriter zrw = ctx.getZooSession().asReaderWriter(); + - ctx.getZooReaderWriter().putPersistentData( - ctx.getZooKeeperRoot() + Constants.ZPREPARE_FOR_UPGRADE, new byte[0], - NodeExistsPolicy.SKIP); - assertTrue(ctx.getZooReader().exists(ctx.getZooKeeperRoot() + Constants.ZPREPARE_FOR_UPGRADE)); ++ zrw.putPersistentData(Constants.ZPREPARE_FOR_UPGRADE, new byte[0], NodeExistsPolicy.SKIP); ++ assertTrue(zr.exists(Constants.ZPREPARE_FOR_UPGRADE)); + - assertTrue(ctx.getZooReader().getChildren(ctx.getZooKeeperRoot() + Constants.ZFATE).isEmpty()); - ctx.getZooReaderWriter().putEphemeralData( - ctx.getZooKeeperRoot() + Constants.ZFATE + "/" + UUID.randomUUID(), new byte[0]); - assertFalse(ctx.getZooReader().getChildren(ctx.getZooKeeperRoot() + Constants.ZFATE).isEmpty()); ++ assertTrue(zr.getChildren(Constants.ZFATE).isEmpty()); ++ zrw.putEphemeralData(Constants.ZFATE + "/" + UUID.randomUUID(), new byte[0]); ++ assertFalse(zr.getChildren(Constants.ZFATE).isEmpty()); + + getCluster().getClusterControl().stopAllServers(ServerType.MANAGER); - Wait.waitFor(() -> ctx.getZooReader() - .getChildren(ctx.getZooKeeperRoot() + Constants.ZMANAGER_LOCK).isEmpty()); ++ Wait.waitFor(() -> zr.getChildren(Constants.ZMANAGER_LOCK).isEmpty()); + + System.setProperty("accumulo.properties", "file://" + getCluster().getAccumuloPropertiesPath()); + IllegalStateException ise = assertThrows(IllegalStateException.class, + () -> new UpgradeUtil().execute(new String[] {"--prepare"})); + assertTrue(ise.getMessage() + .startsWith("Cannot complete upgrade preparation because FATE transactions exist.")); - assertFalse(ctx.getZooReader().exists(ctx.getZooKeeperRoot() + Constants.ZPREPARE_FOR_UPGRADE)); ++ assertFalse(zr.exists(Constants.ZPREPARE_FOR_UPGRADE)); + + } + + @Test + public void testPrepareSucceeds() throws Exception { + ServerContext ctx = getCluster().getServerContext(); ++ ZooReader zr = ctx.getZooSession().asReader(); ++ ZooReaderWriter zrw = ctx.getZooSession().asReaderWriter(); + - ctx.getZooReaderWriter().putPersistentData( - ctx.getZooKeeperRoot() + Constants.ZPREPARE_FOR_UPGRADE, new byte[0], - NodeExistsPolicy.SKIP); - assertTrue(ctx.getZooReader().exists(ctx.getZooKeeperRoot() + Constants.ZPREPARE_FOR_UPGRADE)); ++ zrw.putPersistentData(Constants.ZPREPARE_FOR_UPGRADE, new byte[0], NodeExistsPolicy.SKIP); ++ assertTrue(zr.exists(Constants.ZPREPARE_FOR_UPGRADE)); + + getCluster().getClusterControl().stopAllServers(ServerType.MANAGER); - Wait.waitFor(() -> ctx.getZooReader() - .getChildren(ctx.getZooKeeperRoot() + Constants.ZMANAGER_LOCK).isEmpty()); ++ Wait.waitFor(() -> zr.getChildren(Constants.ZMANAGER_LOCK).isEmpty()); + + System.setProperty("accumulo.properties", "file://" + getCluster().getAccumuloPropertiesPath()); + new UpgradeUtil().execute(new String[] {"--prepare"}); - assertTrue(ctx.getZooReader().exists(ctx.getZooKeeperRoot() + Constants.ZPREPARE_FOR_UPGRADE)); ++ assertTrue(zr.exists(Constants.ZPREPARE_FOR_UPGRADE)); + + } + + }