[ 
https://issues.apache.org/jira/browse/TAJO-1813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14740590#comment-14740590
 ] 

ASF GitHub Bot commented on TAJO-1813:
--------------------------------------

Github user hyunsik commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/749#discussion_r39261746
  
    --- Diff: 
tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalogExceptions.java
 ---
    @@ -0,0 +1,293 @@
    +/**
    + * 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.tajo.catalog;
    +
    +import org.apache.hadoop.fs.Path;
    +import org.apache.tajo.TajoConstants;
    +import org.apache.tajo.catalog.partition.PartitionDesc;
    +import org.apache.tajo.catalog.proto.CatalogProtos.AlterTablespaceProto;
    +import 
org.apache.tajo.catalog.proto.CatalogProtos.AlterTablespaceProto.AlterTablespaceCommand;
    +import 
org.apache.tajo.catalog.proto.CatalogProtos.AlterTablespaceProto.AlterTablespaceType;
    +import 
org.apache.tajo.catalog.proto.CatalogProtos.AlterTablespaceProto.SetLocation;
    +import org.apache.tajo.catalog.proto.CatalogProtos.IndexMethod;
    +import org.apache.tajo.catalog.proto.CatalogProtos.TableStatsProto;
    +import org.apache.tajo.catalog.proto.CatalogProtos.UpdateTableStatsProto;
    +import org.apache.tajo.common.TajoDataTypes.Type;
    +import org.apache.tajo.exception.*;
    +import org.apache.tajo.util.CommonTestingUtil;
    +import org.apache.tajo.util.KeyValueSet;
    +import org.junit.AfterClass;
    +import org.junit.BeforeClass;
    +import org.junit.Test;
    +
    +import java.net.URI;
    +import java.util.UUID;
    +
    +public class TestCatalogExceptions {
    +
    +  static CatalogServer server;
    +  static CatalogService catalog;
    +
    +  @BeforeClass
    +  public static void setup() throws Exception {
    +    server = new MiniCatalogServer();
    +    catalog = new LocalCatalogWrapper(server);
    +    CatalogTestingUtil.prepareBaseData(catalog, ((MiniCatalogServer) 
server).getTestDir());
    +  }
    +
    +  @AfterClass
    +  public static void tearDown() throws Exception {
    +    CatalogTestingUtil.cleanupBaseData(catalog);
    +    server.stop();
    +  }
    +
    +  @Test
    +  public void testCreateTablespaceWithWrongUri() throws Exception {
    +    // TODO
    +    catalog.createTablespace("wrong", "hdfs:");
    +  }
    +
    +  @Test(expected = DuplicateTablespaceException.class)
    +  public void testCreateDuplicateTablespace() throws Exception {
    +    catalog.createTablespace("space1", "hdfs://xxx.com/warehouse");
    +  }
    +
    +  @Test(expected = UndefinedTablespaceException.class)
    +  public void testDropUndefinedTablespace() throws Exception {
    +    catalog.dropTablespace("undefined");
    +  }
    +
    +  @Test(expected = InsufficientPrivilegeException.class)
    +  public void testDropDefaultTablespace() throws Exception {
    +    catalog.dropTablespace(TajoConstants.DEFAULT_TABLESPACE_NAME);
    +  }
    +
    +  @Test(expected = TajoInternalError.class)
    +  public void testAlterTablespaceWithWrongUri() throws Exception {
    +    catalog.alterTablespace(AlterTablespaceProto.newBuilder().
    +        setSpaceName("space1").
    +        addCommand(
    +            AlterTablespaceCommand.newBuilder().
    +                setType(AlterTablespaceType.LOCATION).
    +                setLocation(SetLocation.newBuilder()
    +                    .setUri("hdfs:"))).build());
    +  }
    +
    +  @Test(expected = UndefinedTablespaceException.class)
    +  public void testAlterUndefinedTablespace() throws Exception {
    +    catalog.alterTablespace(AlterTablespaceProto.newBuilder().
    +        setSpaceName("undefined").
    +        addCommand(
    +            AlterTablespaceCommand.newBuilder().
    +                setType(AlterTablespaceType.LOCATION).
    +                setLocation(SetLocation.newBuilder()
    +                    .setUri("hdfs://zzz.com/warehouse"))).build());
    +  }
    +
    +  @Test(expected = DuplicateDatabaseException.class)
    +  public void testCreateDuplicateDatabase() throws Exception {
    +    catalog.createDatabase("TestDatabase1", "space1");
    +  }
    +
    +  @Test(expected = UndefinedDatabaseException.class)
    +  public void testDropUndefinedDatabase() throws Exception {
    +    catalog.dropDatabase("undefined");
    +  }
    +
    +  @Test(expected = InsufficientPrivilegeException.class)
    +  public void testDropDefaultDatabase() throws Exception {
    +    catalog.dropDatabase(TajoConstants.DEFAULT_DATABASE_NAME);
    +  }
    +
    +  @Test()
    +  public void testCreateTableWithWrongUri() throws Exception {
    +    // TODO
    +    String tableName = "wrongUri";
    +    Schema schema = new Schema();
    +    schema.addColumn(CatalogUtil.buildFQName(tableName, "Column"), 
Type.BLOB);
    +    schema.addColumn(CatalogUtil.buildFQName(tableName, "column"), 
Type.INT4);
    +    schema.addColumn(CatalogUtil.buildFQName(tableName, "cOlumn"), 
Type.INT8);
    +    Path path = new Path(CommonTestingUtil.getTestDir(), tableName);
    +    catalog.createTable(
    +        new TableDesc(
    +            CatalogUtil.buildFQName("TestDatabase1", tableName),
    +            schema,
    +            new TableMeta("TEXT", new KeyValueSet()),
    +            path.toUri(), true));
    +  }
    +
    +  @Test(expected = DuplicateTableException.class)
    +  public void testCreateDuplicateTable() throws Exception {
    +    catalog.createTable(CatalogTestingUtil.buildTableDesc("TestDatabase1", 
"TestTable1",
    +        CommonTestingUtil.getTestDir().toString()));
    +  }
    +
    +  @Test(expected = UndefinedDatabaseException.class)
    +  public void dropTableOfUndefinedDatabase() throws Exception {
    +    catalog.dropTable(CatalogUtil.buildFQName("undefined", 
"testPartition1"));
    +  }
    +
    +  @Test(expected = UndefinedTableException.class)
    +  public void dropUndefinedTable() throws Exception {
    +    catalog.dropTable(CatalogUtil.buildFQName("TestDatabase1", 
"undefined"));
    +  }
    +
    +  @Test(expected = UndefinedTableException.class)
    +  public void testUpdateTableStatsOfUndefinedTable() throws Exception {
    +    catalog.updateTableStats(
    +        UpdateTableStatsProto.newBuilder().
    +            setTableName(CatalogUtil.buildFQName("TestDatabase1", 
"undefined")).
    +            setStats(
    +                TableStatsProto.newBuilder().
    +                    setNumRows(0).
    +                    setNumBytes(0).
    +                    build()).
    +            build());
    +  }
    +
    +  @Test
    +  public void testAddPartitionWithWrongUri() throws Exception {
    +    // TODO
    --- End diff --
    
    It seems to throw some exception, but it does not catch or handle the 
exception.


> Allow external catalog store for unit testing
> ---------------------------------------------
>
>                 Key: TAJO-1813
>                 URL: https://issues.apache.org/jira/browse/TAJO-1813
>             Project: Tajo
>          Issue Type: Task
>          Components: Catalog
>            Reporter: Jihoon Son
>            Assignee: Jihoon Son
>             Fix For: 0.11.0
>
>
> Tajo supports various kinds of database systems for catalog. However, it is 
> very difficult to test every function of catalog with them so far. 
> One easy way for testing is to use unit testing. We can easily test each 
> database system under various circumstances using existing tests.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to