gjacoby126 commented on a change in pull request #692: PHOENIX-5689:
TableNotFoundException in IndexUpgradeTool in case of v…
URL: https://github.com/apache/phoenix/pull/692#discussion_r372066177
##########
File path:
phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexUpgradeToolIT.java
##########
@@ -19,76 +19,121 @@
import org.apache.phoenix.mapreduce.index.IndexUpgradeTool;
import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.PropertiesUtil;
import org.apache.phoenix.util.ReadOnlyProps;
import org.apache.phoenix.util.SchemaUtil;
import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
+
+@RunWith(Parameterized.class)
public class IndexUpgradeToolIT extends BaseTest {
public static final String
VERIFY_COUNT_ASSERT_MESSAGE = "view-index count in system table
doesn't match";
+ private final boolean multiTenant;
+ private String tenantId = null;
+
+ public IndexUpgradeToolIT(boolean multiTenant) {
+ this.multiTenant = multiTenant;
+ }
+
+ @Parameters(name="isMultiTenant = {0}")
+ public static synchronized Collection<Boolean[]> data() {
+ return Arrays.asList(new Boolean[][] {
+ { true },{ false }
+ });
+ }
+
+ @BeforeClass
+ public static void setup() throws Exception {
+ Map<String, String> props = Collections.emptyMap();
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
@Test
public void verifyViewAndViewIndexes() throws Exception {
String tableName = generateUniqueName();
String schemaName = generateUniqueName();
- Map<String, String> props = Collections.emptyMap();
- setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
-
- try (Connection conn = DriverManager.getConnection(getUrl(), new
Properties())) {
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ if (multiTenant) {
+ tenantId = generateUniqueName();
+ props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId);
+ }
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
prepareForTest(conn, schemaName, tableName);
- IndexUpgradeTool iut = new IndexUpgradeTool();
- String viewQuery = iut.getViewSql(tableName, schemaName);
+ String viewQuery = IndexUpgradeTool.getViewSql(tableName,
schemaName);
ResultSet rs = conn.createStatement().executeQuery(viewQuery);
int countViews = 0;
List<String> views = new ArrayList<>();
- List<Integer> indexCount = new ArrayList<>();
+ List<String> tenants = new ArrayList<>();
while (rs.next()) {
views.add(rs.getString(1));
+ if(multiTenant) {
+ Assert.assertNotNull(rs.getString(2));
+ }
+ tenants.add(rs.getString(2));
countViews++;
}
Assert.assertEquals("view count in system table doesn't match", 2,
countViews);
+
for (int i = 0; i < views.size(); i++) {
String viewName =
SchemaUtil.getTableNameFromFullName(views.get(i));
- String viewIndexQuery = iut.getViewIndexesSql(viewName,
schemaName, null);
+ String viewIndexQuery =
IndexUpgradeTool.getViewIndexesSql(viewName, schemaName,
+ tenants.get(i));
Review comment:
A comment somewhere around here would be good to remind us that there are 2
indexes on the first tenant's view, 1, on the second, and so on, to explain the
assert, which is otherwise counterintuitive.
Alternately, you could have a map of tenant id -> expected view index count
that you build in the prepareForTest method and reference in the assert here,
but that might be overkill. Up to you.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services