-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-27938 - PE load any custom implementation of tests at runtime #5307
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ | |
| import java.util.Locale; | ||
| import java.util.Map; | ||
| import java.util.NoSuchElementException; | ||
| import java.util.Properties; | ||
| import java.util.Queue; | ||
| import java.util.Random; | ||
| import java.util.TreeMap; | ||
|
|
@@ -359,13 +360,11 @@ static boolean checkTable(Admin admin, TestOptions opts) throws IOException { | |
| // recreate the table when user has requested presplit or when existing | ||
| // {RegionSplitPolicy,replica count} does not match requested, or when the | ||
| // number of column families does not match requested. | ||
| if ( | ||
| (exists && opts.presplitRegions != DEFAULT_OPTS.presplitRegions) | ||
| || (!isReadCmd && desc != null | ||
| && !StringUtils.equals(desc.getRegionSplitPolicyClassName(), opts.splitPolicy)) | ||
| if ((exists && opts.presplitRegions != DEFAULT_OPTS.presplitRegions | ||
| && opts.presplitRegions != admin.getRegions(tableName).size()) | ||
| || (!isReadCmd && desc != null && !StringUtils.equals(desc.getRegionSplitPolicyClassName(), opts.splitPolicy)) | ||
| || (!isReadCmd && desc != null && desc.getRegionReplication() != opts.replicas) | ||
| || (desc != null && desc.getColumnFamilyCount() != opts.families) | ||
| ) { | ||
| || (desc != null && desc.getColumnFamilyCount() != opts.families)) { | ||
| needsDelete = true; | ||
| // wait, why did it delete my table?!? | ||
| LOG.debug(MoreObjects.toStringHelper("needsDelete").add("needsDelete", needsDelete) | ||
|
|
@@ -728,6 +727,7 @@ static class TestOptions { | |
| boolean cacheBlocks = true; | ||
| Scan.ReadType scanReadType = Scan.ReadType.DEFAULT; | ||
| long bufferSize = 2l * 1024l * 1024l; | ||
| Properties commandProperties; | ||
|
|
||
| public TestOptions() { | ||
| } | ||
|
|
@@ -784,8 +784,13 @@ public TestOptions(TestOptions that) { | |
| this.cacheBlocks = that.cacheBlocks; | ||
| this.scanReadType = that.scanReadType; | ||
| this.bufferSize = that.bufferSize; | ||
| this.commandProperties = that.commandProperties; | ||
| } | ||
|
|
||
|
|
||
| public Properties getCommandProperties() { | ||
| return commandProperties; | ||
| } | ||
|
|
||
| public int getCaching() { | ||
| return this.caching; | ||
| } | ||
|
|
@@ -1149,10 +1154,10 @@ private static long nextRandomSeed() { | |
| protected final Configuration conf; | ||
| protected final TestOptions opts; | ||
|
|
||
| private final Status status; | ||
| protected final Status status; | ||
|
|
||
| private String testName; | ||
| private Histogram latencyHistogram; | ||
| protected Histogram latencyHistogram; | ||
| private Histogram replicaLatencyHistogram; | ||
| private Histogram valueSizeHistogram; | ||
| private Histogram rpcCallsHistogram; | ||
|
|
@@ -2308,7 +2313,7 @@ protected byte[] generateRow(final int i) { | |
| } | ||
|
|
||
| @Override | ||
| boolean testRow(final int i, final long startTime) throws IOException { | ||
| protected boolean testRow(final int i, final long startTime) throws IOException { | ||
| byte[] row = generateRow(i); | ||
| Put put = new Put(row); | ||
| for (int family = 0; family < opts.families; family++) { | ||
|
|
@@ -2976,6 +2981,19 @@ static TestOptions parseOpts(Queue<String> args) { | |
| continue; | ||
| } | ||
|
|
||
| final String commandPropertiesFile = "--commandPropertiesFile="; | ||
| if (cmd.startsWith(commandPropertiesFile)) { | ||
| String fileName = String.valueOf(cmd.substring(commandPropertiesFile.length())); | ||
| Properties properties = new Properties(); | ||
| try { | ||
| properties.load(PerformanceEvaluation.class.getClassLoader().getResourceAsStream(fileName)); | ||
| opts.commandProperties = properties; | ||
| } catch (IOException e) { | ||
| LOG.error("Failed to load metricIds from properties file", e); | ||
| } | ||
| continue; | ||
| } | ||
|
|
||
| validateParsedOpts(opts); | ||
|
|
||
| if (isCommandClass(cmd)) { | ||
|
|
@@ -3089,9 +3107,21 @@ public int run(String[] args) throws Exception { | |
| } | ||
|
|
||
| private static boolean isCommandClass(String cmd) { | ||
| return COMMANDS.containsKey(cmd); | ||
| return !COMMANDS.containsKey(cmd) ? isCustomTestClass(cmd) : true; | ||
|
||
| } | ||
|
|
||
| private static boolean isCustomTestClass(String cmd) { | ||
| Class<? extends Test> cmdClass; | ||
| try { | ||
| cmdClass = (Class<? extends Test>) PerformanceEvaluation.class.getClassLoader().loadClass(cmd); | ||
| addCommandDescriptor(cmdClass, cmd, "custom command"); | ||
| return true; | ||
| } catch (Throwable th) { | ||
| LOG.info("No class found for command: " + cmd, th); | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| private static Class<? extends TestBase> determineCommandClass(String cmd) { | ||
| CmdDescriptor descriptor = COMMANDS.get(cmd); | ||
| return descriptor != null ? descriptor.getCmdClass() : null; | ||
|
|
||
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 change this to protected?
Uh oh!
There was an error while loading. Please reload this page.
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.
to override this in impl class, so that we can customise row format. If the custom test knows the dataset, it would be beneficial to repro any specific scenario, like if I have the rowkey similar to what tsdb puts, I can create scan load on particular dataset and write load on another and try to get closer to prod scenarios
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.
But the methods in TestBase class are all package private? Even if you change this to protected, you can not inherit this class in other package because you can not call the constructor?
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.
I was managing them by using the same package name, removing it