Skip to content

Commit

Permalink
PHOENIX-4260 Breakup NotQueryIT into multiple test classes
Browse files Browse the repository at this point in the history
  • Loading branch information
samarthjain committed Sep 29, 2017
1 parent f1b4578 commit cfe4c93
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 44 deletions.
Expand Up @@ -51,27 +51,41 @@ public abstract class BaseQueryIT extends ParallelStatsDisabledIT {
protected static final String tenantId = getOrganizationId(); protected static final String tenantId = getOrganizationId();
protected static final String ATABLE_INDEX_NAME = "ATABLE_IDX"; protected static final String ATABLE_INDEX_NAME = "ATABLE_IDX";
protected static final long BATCH_SIZE = 3; protected static final long BATCH_SIZE = 3;
protected static final String[] INDEX_DDLS = new String[] { protected static final String NO_INDEX = "";
"CREATE INDEX %s ON %s (a_integer DESC) INCLUDE (" protected static final String[] GLOBAL_INDEX_DDLS =
+ " A_STRING, " + " B_STRING, " + " A_DATE) %s", new String[] {
"CREATE INDEX %s ON %s (a_integer, a_string) INCLUDE (" "CREATE INDEX %s ON %s (a_integer DESC) INCLUDE (" + " A_STRING, "
+ " B_STRING, " + " A_DATE) %s", + " B_STRING, " + " A_DATE) %s",
"CREATE INDEX %s ON %s (a_integer) INCLUDE (" "CREATE INDEX %s ON %s (a_integer, a_string) INCLUDE (" + " B_STRING, "
+ " A_STRING, " + " B_STRING, " + " A_DATE) %s", + " A_DATE) %s",
"CREATE LOCAL INDEX %s ON %s (a_integer DESC) INCLUDE (" "CREATE INDEX %s ON %s (a_integer) INCLUDE (" + " A_STRING, "
+ " A_STRING, " + " B_STRING, " + " A_DATE) %s", + " B_STRING, " + " A_DATE) %s",
"CREATE LOCAL INDEX %s ON %s (a_integer, a_string) INCLUDE (" + " B_STRING, " NO_INDEX };
+ " A_DATE) %s", protected static final String[] LOCAL_INDEX_DDLS =
"CREATE LOCAL INDEX %s ON %s (a_integer) INCLUDE (" new String[] {
+ " A_STRING, " + " B_STRING, " + " A_DATE) %s", "CREATE LOCAL INDEX %s ON %s (a_integer DESC) INCLUDE (" + " A_STRING, "
"" }; + " B_STRING, " + " A_DATE) %s",

"CREATE LOCAL INDEX %s ON %s (a_integer, a_string) INCLUDE (" + " B_STRING, "
+ " A_DATE) %s",
"CREATE LOCAL INDEX %s ON %s (a_integer) INCLUDE (" + " A_STRING, "
+ " B_STRING, " + " A_DATE) %s" };
protected static String[] INDEX_DDLS;
static {
INDEX_DDLS = new String[GLOBAL_INDEX_DDLS.length + LOCAL_INDEX_DDLS.length];
int i = 0;
for (String s : GLOBAL_INDEX_DDLS) {
INDEX_DDLS[i++] = s;
}
for (String s : LOCAL_INDEX_DDLS) {
INDEX_DDLS[i++] = s;
}
}
protected Date date; protected Date date;
private String indexDDL; private String indexDDL;
private String tableDDLOptions; private String tableDDLOptions;
protected String tableName; protected String tableName;
protected String indexName; protected String indexName;

private static final Logger logger = LoggerFactory.getLogger(BaseQueryIT.class); private static final Logger logger = LoggerFactory.getLogger(BaseQueryIT.class);


public BaseQueryIT(String idxDdl, boolean mutable, boolean columnEncoded, public BaseQueryIT(String idxDdl, boolean mutable, boolean columnEncoded,
Expand All @@ -81,23 +95,23 @@ public BaseQueryIT(String idxDdl, boolean mutable, boolean columnEncoded,
optionBuilder.append("COLUMN_ENCODED_BYTES=0"); optionBuilder.append("COLUMN_ENCODED_BYTES=0");
} }
if (!mutable) { if (!mutable) {
if (optionBuilder.length()>0) if (optionBuilder.length() > 0) optionBuilder.append(",");
optionBuilder.append(",");
optionBuilder.append("IMMUTABLE_ROWS=true"); optionBuilder.append("IMMUTABLE_ROWS=true");
if (!columnEncoded) { if (!columnEncoded) {
optionBuilder.append(",IMMUTABLE_STORAGE_SCHEME="+PTableImpl.ImmutableStorageScheme.ONE_CELL_PER_COLUMN); optionBuilder.append(",IMMUTABLE_STORAGE_SCHEME="
+ PTableImpl.ImmutableStorageScheme.ONE_CELL_PER_COLUMN);
} }
} }
if (keepDeletedCells) { if (keepDeletedCells) {
if (optionBuilder.length()>0) if (optionBuilder.length() > 0) optionBuilder.append(",");
optionBuilder.append(",");
optionBuilder.append("KEEP_DELETED_CELLS=true"); optionBuilder.append("KEEP_DELETED_CELLS=true");
} }
this.tableDDLOptions = optionBuilder.toString(); this.tableDDLOptions = optionBuilder.toString();
try { try {
this.tableName = this.tableName =
initATableValues(generateUniqueName(), tenantId, getDefaultSplits(tenantId), initATableValues(generateUniqueName(), tenantId, getDefaultSplits(tenantId),
date = new Date(System.currentTimeMillis()), null, getUrl(), tableDDLOptions); date = new Date(System.currentTimeMillis()), null, getUrl(),
tableDDLOptions);
} catch (Exception e) { } catch (Exception e) {
logger.error("Exception when creating aTable ", e); logger.error("Exception when creating aTable ", e);
throw e; throw e;
Expand All @@ -116,13 +130,26 @@ public BaseQueryIT(String idxDdl, boolean mutable, boolean columnEncoded,
} }
} }
} }

@Parameters(name="indexDDL={0},mutable={1},columnEncoded={2}") @Parameters(name = "indexDDL={0},mutable={1},columnEncoded={2}")
public static Collection<Object> data() { public static Collection<Object> allIndexes() {
List<Object> testCases = Lists.newArrayList(); List<Object> testCases = Lists.newArrayList();
for (String indexDDL : INDEX_DDLS) { for (String indexDDL : INDEX_DDLS) {
for (boolean mutable : new boolean[]{false}) { for (boolean mutable : new boolean[] { false }) {
for (boolean columnEncoded : new boolean[]{false}) { for (boolean columnEncoded : new boolean[] { false }) {
testCases.add(new Object[] { indexDDL, mutable, columnEncoded });
}
}
}
return testCases;
}

@Parameters(name = "localIndexDDL={0}")
public static Collection<Object> localIndexes() {
List<Object> testCases = Lists.newArrayList();
for (String indexDDL : LOCAL_INDEX_DDLS) {
for (boolean mutable : new boolean[] { false }) {
for (boolean columnEncoded : new boolean[] { false }) {
testCases.add(new Object[] { indexDDL, mutable, columnEncoded }); testCases.add(new Object[] { indexDDL, mutable, columnEncoded });
} }
} }
Expand Down
Expand Up @@ -59,7 +59,7 @@ public CaseStatementIT(String indexDDL, boolean mutable, boolean columnEncoded)


@Parameters(name="CaseStatementIT_{index}") // name is used by failsafe as file name in reports @Parameters(name="CaseStatementIT_{index}") // name is used by failsafe as file name in reports
public static Collection<Object> data() { public static Collection<Object> data() {
return QueryIT.data(); return QueryIT.allIndexes();
} }


@Test @Test
Expand Down
Expand Up @@ -49,7 +49,7 @@ public CastAndCoerceIT(String indexDDL, boolean mutable, boolean columnEncoded)


@Parameters(name="CastAndCoerceIT_{index}") // name is used by failsafe as file name in reports @Parameters(name="CastAndCoerceIT_{index}") // name is used by failsafe as file name in reports
public static Collection<Object> data() { public static Collection<Object> data() {
return QueryIT.data(); return QueryIT.allIndexes();
} }


@Test @Test
Expand Down
Expand Up @@ -58,7 +58,7 @@ public GroupByIT(String indexDDL, boolean mutable, boolean columnEncoded) throws


@Parameters(name="GroupByIT_{index}") // name is used by failsafe as file name in reports @Parameters(name="GroupByIT_{index}") // name is used by failsafe as file name in reports
public static Collection<Object> data() { public static Collection<Object> data() {
return QueryIT.data(); return QueryIT.allIndexes();
} }


@Test @Test
Expand Down
Expand Up @@ -57,7 +57,7 @@ public InQueryIT(String idxDdl, boolean mutable, boolean columnEncoded, boolean


@Parameters(name="InQueryIT_{index}") // name is used by failsafe as file name in reports @Parameters(name="InQueryIT_{index}") // name is used by failsafe as file name in reports
public static Collection<Object> data() { public static Collection<Object> data() {
return QueryIT.data(); return QueryIT.allIndexes();
} }


@Test @Test
Expand Down
Expand Up @@ -53,7 +53,7 @@ public IntArithmeticIT(String indexDDL, boolean mutable, boolean columnEncoded)


@Parameters(name="IntArithmeticIT_{index}") // name is used by failsafe as file name in reports @Parameters(name="IntArithmeticIT_{index}") // name is used by failsafe as file name in reports
public static Collection<Object> data() { public static Collection<Object> data() {
return QueryIT.data(); return QueryIT.allIndexes();
} }


@Test @Test
Expand Down
Expand Up @@ -35,32 +35,24 @@
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Properties; import java.util.Properties;


import org.apache.phoenix.util.PhoenixRuntime;
import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.PropertiesUtil;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;


import com.google.common.primitives.Doubles; import com.google.common.primitives.Doubles;
import com.google.common.primitives.Floats; import com.google.common.primitives.Floats;




@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class NotQueryIT extends BaseQueryIT { public abstract class NotQueryIT extends BaseQueryIT {


public NotQueryIT(String indexDDL, boolean mutable, boolean columnEncoded) throws Exception { protected NotQueryIT(String indexDDL, boolean mutable, boolean columnEncoded) throws Exception {
super(indexDDL, mutable, columnEncoded, false); super(indexDDL, mutable, columnEncoded, false);
} }


@Parameters(name="NotQueryIT_{index}") // name is used by failsafe as file name in reports
public static Collection<Object> data() {
return QueryIT.data();
}

@Test @Test
public void testNotInList() throws Exception { public void testNotInList() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and entity_id NOT IN (?,?,?,?,?,?)"; String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and entity_id NOT IN (?,?,?,?,?,?)";
Expand Down
@@ -0,0 +1,43 @@
/*
* 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.end2end;

import java.util.Collection;
import java.util.List;

import org.junit.runners.Parameterized.Parameters;

import com.google.common.collect.Lists;

public class NotQueryWithGlobalImmutableIndexesIT extends NotQueryIT {

public NotQueryWithGlobalImmutableIndexesIT(String indexDDL, boolean mutable,
boolean columnEncoded) throws Exception {
super(indexDDL, mutable, columnEncoded);
}

@Parameters(name = "globalIndexDDL={0}")
public static Collection<Object> globalIndexes() {
List<Object> testCases = Lists.newArrayList();
for (String indexDDL : GLOBAL_INDEX_DDLS) {
testCases.add(new Object[] { indexDDL, false, false });
}
return testCases;
}

}
@@ -0,0 +1,43 @@
/*
* 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.end2end;

import java.util.Collection;
import java.util.List;

import org.junit.runners.Parameterized.Parameters;

import com.google.common.collect.Lists;

public class NotQueryWithLocalImmutableIndexesIT extends NotQueryIT {

public NotQueryWithLocalImmutableIndexesIT(String indexDDL, boolean mutable,
boolean columnEncoded) throws Exception {
super(indexDDL, mutable, columnEncoded);
}

@Parameters(name = "localIndexDDL={0}")
public static Collection<Object> localIndexes() {
List<Object> testCases = Lists.newArrayList();
for (String indexDDL : LOCAL_INDEX_DDLS) {
testCases.add(new Object[] { indexDDL, false, false });
}
return testCases;
}

}
Expand Up @@ -53,7 +53,7 @@ public class RangeScanIT extends BaseQueryIT {


@Parameters(name="RangeScanIT_{index}") // name is used by failsafe as file name in reports @Parameters(name="RangeScanIT_{index}") // name is used by failsafe as file name in reports
public static Collection<Object> data() { public static Collection<Object> data() {
return QueryIT.data(); return QueryIT.allIndexes();
} }


public RangeScanIT(String indexDDL, boolean mutable, boolean columnEncoded) throws Exception { public RangeScanIT(String indexDDL, boolean mutable, boolean columnEncoded) throws Exception {
Expand Down
Expand Up @@ -51,7 +51,7 @@ public UngroupedIT(String idxDdl, boolean mutable, boolean columnEncoded)


@Parameters(name="UngroupedIT_{index}") // name is used by failsafe as file name in reports @Parameters(name="UngroupedIT_{index}") // name is used by failsafe as file name in reports
public static Collection<Object> data() { public static Collection<Object> data() {
return QueryIT.data(); return QueryIT.allIndexes();
} }


@Test @Test
Expand Down

0 comments on commit cfe4c93

Please sign in to comment.