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
20 changes: 13 additions & 7 deletions phoenix-pherf/pom.xml
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,11 +73,15 @@
<artifactId>commons-math3</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>org.apache.phoenix.thirdparty</groupId>
<artifactId>phoenix-shaded-commons-cli</artifactId>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>org.apache.phoenix.thirdparty</groupId>
<artifactId>phoenix-shaded-commons-cli</artifactId>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
Expand DownExpand Up@@ -133,7 +137,7 @@
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<directory>src/it/resources</directory>
</resource>
<resource>
<directory>config</directory>
Expand DownExpand Up@@ -221,7 +225,7 @@
<artifactSet>
<includes>
<include>org.apache.phoenix:phoenix-pherf</include>
<include>com.google.guava:guava</include>
<include>org.apache.phoenix.thirdparty:phoenix-shaded-guava</include>
<include>com.googlecode.java-diff-utils:diffutils</include>
<include>org.apache.commons:commons-lang3</include>
<include>org.apache.commons:commons-math3</include>
Expand All@@ -230,6 +234,8 @@
<include>org.apache.commons:commons-csv</include>
<include>commons-lang:commons-lang</include>
<include>commons-io:commons-io</include>
<include>com.google.code.gson:gson</include>
<include>com.lmax:disruptor</include>
</includes>
</artifactSet>
<filters>
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,6 +23,7 @@
import org.apache.phoenix.pherf.result.ResultValue;
import org.apache.phoenix.pherf.result.file.ResultFileDetails;
import org.apache.phoenix.pherf.result.impl.CSVFileResultHandler;
import org.junit.Ignore;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you remove this unused import from the next PR. Don't need to fix it now

import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.ExpectedSystemExit;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,6 +25,7 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
import org.apache.phoenix.end2end.ParallelStatsDisabledIT;
import org.apache.phoenix.pherf.configuration.XMLConfigParser;
import org.apache.phoenix.pherf.result.ResultUtil;
import org.apache.phoenix.pherf.schema.SchemaReader;
Expand All@@ -37,9 +38,9 @@
import org.junit.experimental.categories.Category;

@Category(NeedsOwnMiniClusterTest.class)
public class ResultBaseTestIT extends BaseTest {
protected static final String matcherScenario = ".*scenario/.*test.*xml";
protected static final String matcherSchema = ".*datamodel/.*test.*sql";
public class ResultBaseTestIT extends ParallelStatsDisabledIT {
protected static final String matcherScenario = ".*scenario/.*test_scenario.*xml";
protected static final String matcherSchema = ".*datamodel/.*test_schema.*sql";

protected static PhoenixUtil util = PhoenixUtil.create(true);
protected static Properties properties;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -78,7 +78,7 @@ public void testSchemaReader() {
private void assertApplySchemaTest() {
try {
util.setZookeeper("localhost");
SchemaReader reader = new SchemaReader(util, ".*datamodel/.*test.*sql");
SchemaReader reader = new SchemaReader(util, ".*datamodel/.*test_schema.*sql");

List<Path> resources = new ArrayList<>(reader.getResourceList());
assertTrue("Could not pull list of schema files.", resources.size() > 0);
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
/*
* 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.phoenix.pherf.workload.mt.tenantoperation;
Comment thread
yanxinyi marked this conversation as resolved.

import org.apache.phoenix.end2end.ParallelStatsDisabledIT;
import org.apache.phoenix.pherf.PherfConstants;
import org.apache.phoenix.pherf.XMLConfigParserTest;
import org.apache.phoenix.pherf.configuration.DataModel;
import org.apache.phoenix.pherf.configuration.XMLConfigParser;
import org.apache.phoenix.pherf.schema.SchemaReader;
import org.apache.phoenix.pherf.util.PhoenixUtil;
import org.junit.BeforeClass;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class MultiTenantOperationBaseIT extends ParallelStatsDisabledIT {
enum TestOperationGroup {
upsertOp, queryOp1, queryOp2, idleOp, udfOp
}

static enum TestTenantGroup {
tg1, tg2, tg3
}
protected static final String matcherScenario = ".*scenario/.*test_mt_workload.*xml";
protected static final String matcherSchema = ".*datamodel/.*test_schema_mt*.*sql";

protected static PhoenixUtil util = PhoenixUtil.create(true);
protected static Properties properties;
protected static SchemaReader reader;
protected static XMLConfigParser parser;
protected static List<Path> resources;

@BeforeClass public static synchronized void setUp() throws Exception {
PherfConstants constants = PherfConstants.create();
properties = constants.getProperties(PherfConstants.PHERF_PROPERTIES, false);

PhoenixUtil.setZookeeper("localhost");
reader = new SchemaReader(util, matcherSchema);
parser = new XMLConfigParser(matcherScenario);
reader.applySchema();
resources = new ArrayList<>(reader.getResourceList());

assertTrue("Could not pull list of schema files.", resources.size() > 0);
assertNotNull("Could not read schema file.", reader.resourceToString(resources.get(0)));

}

public DataModel readTestDataModel(String resourceName) throws Exception {
URL scenarioUrl = XMLConfigParserTest.class.getResource(resourceName);
assertNotNull(scenarioUrl);
Path p = Paths.get(scenarioUrl.toURI());
return XMLConfigParser.readDataModel(p);
}

}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
/*
* 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.phoenix.pherf.workload.mt.tenantoperation;
Comment thread
yanxinyi marked this conversation as resolved.

import org.apache.phoenix.pherf.configuration.DataModel;
import org.apache.phoenix.pherf.configuration.LoadProfile;
import org.apache.phoenix.pherf.configuration.Scenario;
import org.apache.phoenix.pherf.util.PhoenixUtil;
import org.apache.phoenix.pherf.workload.mt.Operation;
import org.apache.phoenix.pherf.workload.mt.OperationStats;
import org.apache.phoenix.thirdparty.com.google.common.base.Function;
import org.apache.phoenix.thirdparty.com.google.common.base.Supplier;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
* Tests focused on tenant operations and their validations
*/
public class TenantOperationIT extends MultiTenantOperationBaseIT {
private static final Logger LOGGER = LoggerFactory.getLogger(TenantOperationIT.class);
Comment thread
yanxinyi marked this conversation as resolved.

@Test
public void testVariousOperations() throws Exception {
int numTenantGroups = 3;
int numOpGroups = 5;
int numRuns = 10;
int numOperations = 10;

PhoenixUtil pUtil = PhoenixUtil.create();
DataModel model = readTestDataModel("/scenario/test_mt_workload.xml");
for (Scenario scenario : model.getScenarios()) {
LOGGER.debug(String.format("Testing %s", scenario.getName()));
LoadProfile loadProfile = scenario.getLoadProfile();
assertEquals("tenant group size is not as expected: ",
numTenantGroups, loadProfile.getTenantDistribution().size());
assertEquals("operation group size is not as expected: ",
numOpGroups, loadProfile.getOpDistribution().size());

TenantOperationFactory opFactory = new TenantOperationFactory(pUtil, model, scenario);
TenantOperationEventGenerator evtGen = new TenantOperationEventGenerator(
opFactory.getOperations(), model, scenario);

assertEquals("operation group size from the factory is not as expected: ",
numOpGroups, opFactory.getOperations().size());

int numRowsInserted = 0;
for (int i = 0; i < numRuns; i++) {
int ops = numOperations;
loadProfile.setNumOperations(ops);
while (ops-- > 0) {
TenantOperationInfo info = evtGen.next();
Supplier<Function<TenantOperationInfo, OperationStats>> opSupplier =
opFactory.getOperationSupplier(info);
OperationStats stats = opSupplier.get().apply(info);
LOGGER.info(pUtil.getGSON().toJson(stats));
if (info.getOperation().getType() == Operation.OperationType.PRE_RUN) continue;
switch (TestOperationGroup.valueOf(info.getOperationGroupId())) {
case upsertOp:
assertTrue(opSupplier.getClass()
.isAssignableFrom(UpsertOperationSupplier.class));
numRowsInserted += stats.getRowCount();
break;
case queryOp1:
case queryOp2:
assertTrue(opFactory.getOperationSupplier(info).getClass()
.isAssignableFrom(QueryOperationSupplier.class));

// expected row count == num rows inserted
assertEquals(numRowsInserted, stats.getRowCount());
break;
case idleOp:
assertTrue(opFactory.getOperationSupplier(info).getClass()
.isAssignableFrom(IdleTimeOperationSupplier.class));
assertEquals(0, stats.getRowCount());
// expected think time (no-op) to be ~50ms
assertTrue(40 < stats.getDurationInMs() && stats.getDurationInMs() < 60);
break;
case udfOp:
assertTrue(opFactory.getOperationSupplier(info).getClass()
.isAssignableFrom(UserDefinedOperationSupplier.class));
assertEquals(0, stats.getRowCount());
break;
default:
Assert.fail();
}
}
}
}
}
}
Loading