You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@tajo.apache.org by jihoonson <gi...@git.apache.org> on 2015/09/09 09:05:01 UTC

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

GitHub user jihoonson opened a pull request:

    https://github.com/apache/tajo/pull/749

    TAJO-1813: Allow external catalog store for unit testing

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jihoonson/tajo-2 TAJO-1813

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/tajo/pull/749.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #749
    
----
commit d3404c9e8353dca8046005704b6d12774827f7c9
Author: Jihoon Son <ji...@apache.org>
Date:   2015-09-09T07:05:01Z

    TAJO-1813

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by hyunsik <gi...@git.apache.org>.
Github user hyunsik commented on the pull request:

    https://github.com/apache/tajo/pull/749#issuecomment-140610051
  
    +1 
    The patch looks good to me. Ship it!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by jihoonson <gi...@git.apache.org>.
Github user jihoonson commented on the pull request:

    https://github.com/apache/tajo/pull/749#issuecomment-139753618
  
    @hyunsik thank you for your review. I updated the patch according to your comment except wrong URI tests. The problem is that we cannot test against wrong URI input because it doesn't cause any errors. I think we need to handle this problem at another issue.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/tajo/pull/749


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by hyunsik <gi...@git.apache.org>.
Github user hyunsik commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/749#discussion_r39261289
  
    --- Diff: tajo-catalog/tajo-catalog-server/src/main/resources/schemas/postgresql/postgresql.xml ---
    @@ -21,6 +21,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://tajo.apache.org/catalogstore ../DBMSSchemaDefinition.xsd ">
       <!--
           Catalog base version history
    +      * 9 - TODO
    --- End diff --
    
    You seem to miss this description.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by jihoonson <gi...@git.apache.org>.
Github user jihoonson commented on the pull request:

    https://github.com/apache/tajo/pull/749#issuecomment-139436292
  
    This patch is ready for review.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by hyunsik <gi...@git.apache.org>.
Github user hyunsik commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/749#discussion_r39261266
  
    --- Diff: tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/mysql.xml ---
    @@ -19,6 +19,7 @@
     <tns:store xmlns:tns="http://tajo.apache.org/catalogstore" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tajo.apache.org/catalogstore ../DBMSSchemaDefinition.xsd ">
       <!--
         Catalog base version history
    +    * 9 - TODO
    --- End diff --
    
    You may miss this description.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by jihoonson <gi...@git.apache.org>.
Github user jihoonson commented on the pull request:

    https://github.com/apache/tajo/pull/749#issuecomment-138809217
  
    This patch is only to test catalog.
    I've added two more unit tests, i.e., ```TestCatalogAgainstCaseSensitivity``` and ```TestCatalogExceptions```. As shown in those names, one of them is to test catalog functionalities against text case sensitivity and the other is to test if catalog throws exceptions properly.
    I've verified every unit test of ```tajo-catalog-server``` with pgsql, mysql, mariadb, and derby.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by jihoonson <gi...@git.apache.org>.
Github user jihoonson commented on the pull request:

    https://github.com/apache/tajo/pull/749#issuecomment-138926109
  
    I miss tests for some partition APIs and nested fields. I'll add them.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by hyunsik <gi...@git.apache.org>.
Github user hyunsik commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/749#discussion_r39261237
  
    --- Diff: tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/mariadb.xml ---
    @@ -19,6 +19,7 @@
     <tns:store xmlns:tns="http://tajo.apache.org/catalogstore" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tajo.apache.org/catalogstore ../DBMSSchemaDefinition.xsd ">
       <!--
           Catalog base version history
    +      * 9 - TODO
    --- End diff --
    
    You may misse this description.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by hyunsik <gi...@git.apache.org>.
Github user hyunsik commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/749#discussion_r39259603
  
    --- Diff: tajo-catalog/tajo-catalog-server/pom.xml ---
    @@ -127,6 +127,15 @@
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-surefire-report-plugin</artifactId>
           </plugin>
    +      <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><configuration>
    +        <systemProperties>
    +          <tajo.test>TRUE</tajo.test>
    +        </systemProperties>
    +        <additionalClasspathElements>
    +          <additionalClasspathElement>/home/jihoon/다운로드/postgresql-9.4-1201.jdbc4.jar</additionalClasspathElement>
    --- End diff --
    
    It seems to be a mistake?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by hyunsik <gi...@git.apache.org>.
Github user hyunsik commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/749#discussion_r39261287
  
    --- Diff: tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/oracle.xml ---
    @@ -19,6 +19,7 @@
     <tns:store xmlns:tns="http://tajo.apache.org/catalogstore" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tajo.apache.org/catalogstore ../DBMSSchemaDefinition.xsd ">
       <!--
           Catalog base version history
    +      * 9 - TODO
    --- End diff --
    
    You seem to miss this description.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by hyunsik <gi...@git.apache.org>.
Github user hyunsik commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/749#discussion_r39261725
  
    --- 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:");
    --- End diff --
    
    It seems to throw some exception, but it does not catch or handle the exception.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by hyunsik <gi...@git.apache.org>.
Github user hyunsik commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/749#discussion_r39259558
  
    --- Diff: tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogService.java ---
    @@ -169,7 +169,7 @@ PartitionDescProto getPartition(String databaseName, String tableName, String pa
       void addPartitions(String databaseName, String tableName, List<PartitionDescProto> partitions
         , boolean ifNotExists) throws UndefinedTableException, DuplicatePartitionException, UndefinedPartitionMethodException, UndefinedDatabaseException;
     
    -  boolean createIndex(IndexDesc index);
    +  void createIndex(IndexDesc index) throws DuplicateIndexException;
    --- End diff --
    
    If index creation is based on table, it may need ``Undefined(Table|Database)Exception``.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by hyunsik <gi...@git.apache.org>.
Github user hyunsik commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/749#discussion_r39259540
  
    --- Diff: tajo-catalog/tajo-catalog-client/src/main/java/org/apache/tajo/catalog/AbstractCatalogClient.java ---
    @@ -598,18 +604,15 @@ public final boolean existsTable(final String tableName) {
       }
     
       @Override
    -  public final boolean createIndex(final IndexDesc index) {
    +  public final void createIndex(final IndexDesc index) throws DuplicateIndexException {
    --- End diff --
    
    If index creation is based on table, it may need ``Undefined(Table|Database)Exception``.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by hyunsik <gi...@git.apache.org>.
Github user hyunsik commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/749#discussion_r39261741
  
    --- 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
    --- End diff --
    
    It seems to throw some exception, but it does not catch or handle the exception.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by hyunsik <gi...@git.apache.org>.
Github user hyunsik commented on the pull request:

    https://github.com/apache/tajo/pull/749#issuecomment-139518419
  
    It's excellent! I leaved some comments.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] tajo pull request: TAJO-1813: Allow external catalog store for uni...

Posted by hyunsik <gi...@git.apache.org>.
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.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---