-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-29620 Refactor TestRSGroupsKillRS #8623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Sigma-Ma
wants to merge
1
commit into
apache:master
Choose a base branch
from
Sigma-Ma:HBASE-29620-refactor-TestRSGroupsKillRS
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+136
−60
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
...rc/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsKillRSWithDifferentVersions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| /* | ||
| * 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.hadoop.hbase.rsgroup; | ||
|
|
||
| import static org.apache.hadoop.hbase.util.Threads.sleep; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.hbase.HConstants; | ||
| import org.apache.hadoop.hbase.ServerName; | ||
| import org.apache.hadoop.hbase.TableName; | ||
| import org.apache.hadoop.hbase.ipc.MetaRWQueueRpcExecutor; | ||
| import org.apache.hadoop.hbase.master.HMaster; | ||
| import org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure; | ||
| import org.apache.hadoop.hbase.net.Address; | ||
| import org.apache.hadoop.hbase.testclassification.LargeTests; | ||
| import org.apache.hadoop.hbase.testclassification.RSGroupTests; | ||
| import org.apache.hadoop.hbase.util.VersionInfo; | ||
| import org.junit.jupiter.api.AfterAll; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeAll; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Tag; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.TestInfo; | ||
|
|
||
| @Tag(RSGroupTests.TAG) | ||
| @Tag(LargeTests.TAG) | ||
| public class TestRSGroupsKillRSWithDifferentVersions extends TestRSGroupsBase { | ||
|
|
||
| private static final String LOWER_VERSION = "0.0.0"; | ||
|
|
||
| public static final class HMasterForTest extends HMaster { | ||
|
|
||
| private volatile Address serverWithLowerVersion; | ||
|
|
||
| public HMasterForTest(Configuration conf) throws IOException { | ||
| super(conf); | ||
| } | ||
|
|
||
| void setServerWithLowerVersion(Address server) { | ||
| serverWithLowerVersion = server; | ||
| } | ||
|
|
||
| @Override | ||
| public String getRegionServerVersion(ServerName serverName) { | ||
| return serverName.getAddress().equals(serverWithLowerVersion) | ||
| ? LOWER_VERSION | ||
| : super.getRegionServerVersion(serverName); | ||
| } | ||
| } | ||
|
|
||
| @BeforeAll | ||
| public static void setUp() throws Exception { | ||
| TEST_UTIL.getConfiguration().setClass(HConstants.MASTER_IMPL, HMasterForTest.class, | ||
| HMaster.class); | ||
| // avoid all the handlers blocked when meta is offline, and regionServerReport can not be | ||
| // processed which causes dead lock. | ||
| TEST_UTIL.getConfiguration().setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10); | ||
| TEST_UTIL.getConfiguration() | ||
| .setFloat(MetaRWQueueRpcExecutor.META_CALL_QUEUE_READ_SHARE_CONF_KEY, 0.5f); | ||
| setUpTestBeforeClass(); | ||
| } | ||
|
|
||
| @AfterAll | ||
| public static void tearDown() throws Exception { | ||
| try { | ||
| tearDownAfterClass(); | ||
| } finally { | ||
| TEST_UTIL.getConfiguration().unset(HConstants.MASTER_IMPL); | ||
| } | ||
| } | ||
|
|
||
| @BeforeEach | ||
| public void beforeMethod(TestInfo testInfo) throws Exception { | ||
| setUpBeforeMethod(testInfo); | ||
| } | ||
|
|
||
| @AfterEach | ||
| public void afterMethod() throws Exception { | ||
| ((HMasterForTest) MASTER).setServerWithLowerVersion(null); | ||
| tearDownAfterMethod(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testLowerMetaGroupVersion() throws Exception { | ||
| String groupName = "meta_group"; | ||
| addGroup(groupName, 1); | ||
|
|
||
| Set<TableName> toAddTables = new HashSet<>(); | ||
| toAddTables.add(TableName.META_TABLE_NAME); | ||
| ADMIN.setRSGroup(toAddTables, groupName); | ||
| assertTrue(ADMIN.getConfiguredNamespacesAndTablesInRSGroup(groupName).getSecond() | ||
| .contains(TableName.META_TABLE_NAME)); | ||
|
|
||
| Address address = ADMIN.getRSGroup(groupName).getServers().iterator().next(); | ||
| ServerName serverName = getServerName(address); | ||
| String originVersion = MASTER.getRegionServerVersion(serverName); | ||
| TEST_UTIL.getMiniHBaseCluster().stopRegionServer(serverName); | ||
|
|
||
| // better wait for a while for region reassign | ||
| sleep(10000); | ||
| assertEquals(NUM_SLAVES_BASE - 1, | ||
| TEST_UTIL.getMiniHBaseCluster().getLiveRegionServerThreads().size()); | ||
| ((HMasterForTest) MASTER).setServerWithLowerVersion(address); | ||
| TEST_UTIL.getMiniHBaseCluster().startRegionServer(address.getHostName(), address.getPort()); | ||
| assertEquals(NUM_SLAVES_BASE, | ||
| TEST_UTIL.getMiniHBaseCluster().getLiveRegionServerThreads().size()); | ||
| assertTrue(VersionInfo.compareVersion(originVersion, | ||
| MASTER.getRegionServerVersion(getServerName(address))) > 0); | ||
| LOG.debug("wait for META assigned..."); | ||
| // SCP finished, which means all regions assigned too. | ||
| TEST_UTIL.waitFor(60000, () -> !TEST_UTIL.getHBaseCluster().getMaster().getProcedures().stream() | ||
| .anyMatch(p -> p instanceof ServerCrashProcedure)); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mutable field was introduced only to let the test override the version through reflection. Since the test now simulates the lower version through HMaster, the field is no longer needed, so getVersion() can return Version.version directly again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only place where we override this field by reflection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I checked the repository, and TestRSGroupsKillRS#setVersionInfoVersion is the only place that modifies VersionInfo.version through reflection.