gokceni commented on a change in pull request #720: PHOENIX-5747 Add upsert tests for immutable table indexes URL: https://github.com/apache/phoenix/pull/720#discussion_r386745434
########## File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexExtendedIT.java ########## @@ -0,0 +1,258 @@ +/* + * 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.index; + +import com.google.common.collect.Maps; +import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.client.HTable; +import org.apache.hadoop.hbase.client.Mutation; +import org.apache.hadoop.hbase.client.Result; +import org.apache.hadoop.hbase.client.ResultScanner; +import org.apache.hadoop.hbase.client.Scan; +import org.apache.hadoop.hbase.coprocessor.ObserverContext; +import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; +import org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver; +import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress; +import org.apache.hadoop.hbase.util.Bytes; +import org.apache.phoenix.end2end.BaseUniqueNamesOwnClusterIT; +import org.apache.phoenix.hbase.index.IndexRegionObserver; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.schema.PIndexState; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.util.EncodedColumnsUtil; +import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.ReadOnlyProps; +import org.apache.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.TestUtil; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class ImmutableIndexExtendedIT extends BaseUniqueNamesOwnClusterIT { + + private final String tableDDLOptions; + + public ImmutableIndexExtendedIT() { + StringBuilder optionBuilder = new StringBuilder("IMMUTABLE_ROWS=true"); + this.tableDDLOptions = optionBuilder.toString(); + } + + @BeforeClass + public static void doSetup() throws Exception { + Map<String, String> props = Maps.newHashMapWithExpectedSize(1); + props.put(HConstants.HBASE_CLIENT_RETRIES_NUMBER, "5"); + setUpTestDriver(new ReadOnlyProps(props)); + } + + public static class PreMutationFailingRegionObserver extends SimpleRegionObserver { + + @Override public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c, + MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException { + System.out.println("preBatchMutate my coproc " + this); + throw new IOException(); + } + } + + public static class PostMutationFailingRegionObserver extends SimpleRegionObserver { + + @Override public void postBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c, + MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException { + System.out.println("postBatchMutate my coproc " + this); + throw new IOException(); + } + } + + public static class FailOnceMutationRegionObserver extends SimpleRegionObserver { + + private boolean failOnce = true; + + @Override public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c, + MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException { + System.out.println("Fail once my coproc " + this); + if (failOnce) { + // next attempt don't raise + failOnce = false; + throw new IOException(); + } + } + } + + private void createAndPopulateTable(Connection conn, String tableName, int rowCount) + throws Exception { + String ddl = "CREATE TABLE " + tableName + + " (id integer not null primary key, val1 varchar(10), val2 varchar(10), val3 varchar(10))" + + tableDDLOptions; + Review comment: nit: have only 1 line as empty line between statements rather than multiple empty lines through your code ---------------------------------------------------------------- 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
