Github user kadirozde commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/359#discussion_r226685573
--- Diff:
phoenix-core/src/it/java/org/apache/phoenix/end2end/DropTableWithViewsIT.java
---
@@ -0,0 +1,169 @@
+/*
+ * 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 static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.phoenix.coprocessor.TableViewFinderResult;
+import org.apache.phoenix.coprocessor.ViewFinder;
+import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
+
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.query.QueryServicesOptions;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.TableNotFoundException;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.SchemaUtil;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class DropTableWithViewsIT extends SplitSystemCatalogIT {
+
+ private final boolean isMultiTenant;
+ private final boolean columnEncoded;
+ private final String TENANT_SPECIFIC_URL1 = getUrl() + ';' +
TENANT_ID_ATTRIB + "=" + TENANT1;
+
+ public DropTableWithViewsIT(boolean isMultiTenant, boolean
columnEncoded) {
+ this.isMultiTenant = isMultiTenant;
+ this.columnEncoded = columnEncoded;
+ }
+
+ @Parameters(name="DropTableWithViewsIT_multiTenant={0},
columnEncoded={1}") // name is used by failsafe as file name in reports
+ public static Collection<Boolean[]> data() {
+ return Arrays.asList(new Boolean[][] {
+ { false, false }, { false, true },
+ { true, false }, { true, true } });
+ }
+
+ private String generateDDL(String format) {
+ return generateDDL("", format);
+ }
+
+ private String generateDDL(String options, String format) {
+ StringBuilder optionsBuilder = new StringBuilder(options);
+ if (!columnEncoded) {
+ if (optionsBuilder.length()!=0)
+ optionsBuilder.append(",");
+ optionsBuilder.append("COLUMN_ENCODED_BYTES=0");
+ }
+ if (isMultiTenant) {
+ if (optionsBuilder.length()!=0)
+ optionsBuilder.append(",");
+ optionsBuilder.append("MULTI_TENANT=true");
+ }
+ return String.format(format, isMultiTenant ? "TENANT_ID VARCHAR
NOT NULL, " : "",
+ isMultiTenant ? "TENANT_ID, " : "", optionsBuilder.toString());
+ }
+
+ @Test
+ public void testDropTableWithChildViews() throws Exception {
--- End diff --
That is not the right way of doing an integration testing. That would be
more of a unit test. I should not call an internal function directly and verify
that it works for the purpose of integration testing. This is one reason not to
that. The second reason is that I wanted to verify that the coprocessor
(TaskRegionObserver) is initialized, it creates an instance of
DropChildViewsTask, and this instance is run at regular intervals in addition
to DropChildViewsTask functions correctly. The third reason is that even I
create another instance of DropChildViewsTask and call it directly, I would not
know which instance processed the drop child tasks in the system task table. A
view tree can have more one level of views and the run method of
DropChildViewsTask needs to be called once for each level. This also introduces
concurrency which is not supported by the current implementation. Please note
that I set the scheduling interval to 1 sec (in BaseTest.java) for testing
purpose. Sin
ce the test sleeps only half this interval at a time, this test should be done
in 2.5 seconds on average (for a view tree of depth 2). The sleeping logic here
can only sleep extra 0.5 sec at most. Of course, if the threads are not
scheduled on time, this test can take longer. For that reason, the test waits
up to 10 seconds.
---