This is an automated email from the ASF dual-hosted git repository. mcvsubbu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
The following commit(s) were added to refs/heads/master by this push: new b8bc74f compatibility test: create/delete table operations (#6360) b8bc74f is described below commit b8bc74fa79437a4f30cf1daed55f66b48973b7f9 Author: Jiapeng Tao <50065407+jta...@users.noreply.github.com> AuthorDate: Mon Dec 21 19:57:27 2020 -0800 compatibility test: create/delete table operations (#6360) Co-authored-by: Jiapeng Tao <jia...@jiatao-mn1.linkedin.biz> --- .../pinot/compat/tests/ClusterDescriptor.java | 23 +++++++++ .../org/apache/pinot/compat/tests/TableOp.java | 55 ++++++++++++++++++++-- 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/pinot-integration-tests/src/test/java/org/apache/pinot/compat/tests/ClusterDescriptor.java b/pinot-integration-tests/src/test/java/org/apache/pinot/compat/tests/ClusterDescriptor.java new file mode 100644 index 0000000..46dbcd0 --- /dev/null +++ b/pinot-integration-tests/src/test/java/org/apache/pinot/compat/tests/ClusterDescriptor.java @@ -0,0 +1,23 @@ +/** + * 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.pinot.compat.tests; + +public class ClusterDescriptor { + public static final String CONTROLLER_URL = "localhost:9000"; +} diff --git a/pinot-integration-tests/src/test/java/org/apache/pinot/compat/tests/TableOp.java b/pinot-integration-tests/src/test/java/org/apache/pinot/compat/tests/TableOp.java index dfb9ab1..1eeb01e 100644 --- a/pinot-integration-tests/src/test/java/org/apache/pinot/compat/tests/TableOp.java +++ b/pinot-integration-tests/src/test/java/org/apache/pinot/compat/tests/TableOp.java @@ -19,6 +19,15 @@ package org.apache.pinot.compat.tests; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.io.File; +import java.io.IOException; +import org.apache.commons.io.FileUtils; +import org.apache.pinot.controller.helix.ControllerRequestURLBuilder; +import org.apache.pinot.controller.helix.ControllerTest; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.utils.JsonUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -45,6 +54,8 @@ public class TableOp extends BaseOp { private Op _op; private String _tableConfigFileName; + private static final Logger LOGGER = LoggerFactory.getLogger(TableOp.class); + public TableOp() { super(OpType.TABLE_OP); } @@ -77,12 +88,10 @@ public class TableOp extends BaseOp { boolean runOp() { switch (_op) { case CREATE: - System.out.println("Creating table from table config " + _tableConfigFileName + " and schema " + - _schemaFileName); - break; + createSchema(); + return createTable(); case DELETE: - System.out.println("Deleting table that has table config " + _tableConfigFileName); - break; + return deleteTable(); case UPDATE_CONFIG: System.out.println("Updating table config to " + _tableConfigFileName); break; @@ -92,4 +101,40 @@ public class TableOp extends BaseOp { } return true; } + + private boolean createSchema() { + try { + ControllerTest.sendPostRequest( + ControllerRequestURLBuilder.baseUrl(ClusterDescriptor.CONTROLLER_URL).forSchemaCreate(), + FileUtils.readFileToString(new File(_schemaFileName))); + return true; + } catch (IOException e) { + LOGGER.error("Failed to create schema with file: {}", _schemaFileName, e); + return false; + } + } + + private boolean createTable() { + try { + ControllerTest.sendPostRequest( + ControllerRequestURLBuilder.baseUrl(ClusterDescriptor.CONTROLLER_URL).forTableCreate(), + FileUtils.readFileToString(new File(_tableConfigFileName))); + return true; + } catch (IOException e) { + LOGGER.error("Failed to create table with file: {}", _tableConfigFileName, e); + return false; + } + } + + private boolean deleteTable() { + try { + TableConfig tableConfig = JsonUtils.fileToObject(new File(_tableConfigFileName), TableConfig.class); + ControllerTest.sendDeleteRequest( + ControllerRequestURLBuilder.baseUrl(ClusterDescriptor.CONTROLLER_URL).forTableDelete(tableConfig.getTableName())); + return true; + } catch (IOException e) { + LOGGER.error("Failed to delete table with file: {}", _tableConfigFileName, e); + return false; + } + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org