[CARBONDATA-2216][Test] Fix bugs in sdv tests

This closes #2012


Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/62e33e5f
Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/62e33e5f
Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/62e33e5f

Branch: refs/heads/datamap-rebase1
Commit: 62e33e5ff73914ce67dfe2d3b8bff906aa8df15e
Parents: 65cb0d6
Author: xuchuanyin <xuchuan...@hust.edu.cn>
Authored: Wed Feb 28 16:02:55 2018 +0800
Committer: Jacky Li <jacky.li...@qq.com>
Committed: Sun Mar 4 22:52:56 2018 +0800

----------------------------------------------------------------------
 .../cluster/sdv/generated/MergeIndexTestCase.scala   | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/62e33e5f/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/generated/MergeIndexTestCase.scala
----------------------------------------------------------------------
diff --git 
a/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/generated/MergeIndexTestCase.scala
 
b/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/generated/MergeIndexTestCase.scala
index c0abe4e..b886b11 100644
--- 
a/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/generated/MergeIndexTestCase.scala
+++ 
b/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/generated/MergeIndexTestCase.scala
@@ -92,18 +92,29 @@ class MergeIndexTestCase extends QueryTest with 
BeforeAndAfterAll {
     val table = 
CarbonMetadata.getInstance().getCarbonTable("default","carbon_automation_nonmerge")
     new CarbonIndexFileMergeWriter().mergeCarbonIndexFilesOfSegment("0.1", 
table.getTablePath, false)
     assert(getIndexFileCount("default", "carbon_automation_nonmerge", "0.1") 
== 0)
+    assert(getMergedIndexFileCount("default", "carbon_automation_nonmerge", 
"0.1") == 1)
     checkAnswer(sql("""Select count(*) from carbon_automation_nonmerge"""), 
rows)
   }
 
   private def getIndexFileCount(dbName: String, tableName: String, segment: 
String): Int = {
+    getFileCount(dbName, tableName, segment, CarbonTablePath.INDEX_FILE_EXT)
+  }
+
+  private def getMergedIndexFileCount(dbName: String, tableName: String, 
segment: String): Int = {
+    getFileCount(dbName, tableName, segment, 
CarbonTablePath.MERGE_INDEX_FILE_EXT)
+  }
+
+  private def getFileCount(dbName: String,
+      tableName: String,
+      segment: String,
+      suffix: String): Int = {
     val carbonTable = CarbonMetadata.getInstance().getCarbonTable(dbName, 
tableName)
     val identifier = carbonTable.getAbsoluteTableIdentifier
     val path = CarbonTablePath
       .getSegmentPath(identifier.getTablePath, segment)
     val carbonFiles = FileFactory.getCarbonFile(path).listFiles(new 
CarbonFileFilter {
       override def accept(file: CarbonFile): Boolean = {
-        file.getName.endsWith(CarbonTablePath
-          .INDEX_FILE_EXT)
+        file.getName.endsWith(suffix)
       }
     })
     if (carbonFiles != null) {

Reply via email to