Skip to content

Commit

Permalink
[LIVY-573][TESTS][THRIFT] Add tests for operation logs retrieval
Browse files Browse the repository at this point in the history
## What changes were proposed in this pull request?
Add unit test for operation logs retrieval.

## How was this patch tested?
New unit tests and existing unit test

Author: yihengwang <[email protected]>

Closes apache#199 from yiheng/fix_573.
  • Loading branch information
yiheng authored and mgaido91 committed Aug 19, 2019
1 parent cae9d97 commit 22c73e3
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package org.apache.livy.thriftserver

import java.sql.{Connection, Date, SQLException, Statement}

import org.apache.hive.jdbc.HiveStatement

import org.apache.livy.LivyConf


Expand Down Expand Up @@ -177,6 +179,17 @@ trait CommonThriftTests {
assert(columnsResultSet.getString(23) == "NO")
assert(!columnsResultSet.next())
}

def operationLogRetrievalTest(statement: Statement): Unit = {
statement.execute("select 1")
val logIterator = statement.asInstanceOf[HiveStatement].getQueryLog().iterator()
statement.close()

// Only execute statement support operation log retrieval and it only produce one log
assert(logIterator.next() ==
"Livy session has not yet started. Please wait for it to be ready...")
assert(!logIterator.hasNext)
}
}

class BinaryThriftServerSuite extends ThriftServerBaseTest with CommonThriftTests {
Expand Down Expand Up @@ -295,6 +308,12 @@ class BinaryThriftServerSuite extends ThriftServerBaseTest with CommonThriftTest
getColumnsTest(connection)
}
}

test("operation log retrieval test") {
withJdbcStatement { statement =>
operationLogRetrievalTest(statement)
}
}
}

class HttpThriftServerSuite extends ThriftServerBaseTest with CommonThriftTests {
Expand Down Expand Up @@ -331,4 +350,10 @@ class HttpThriftServerSuite extends ThriftServerBaseTest with CommonThriftTests
getColumnsTest(connection)
}
}

test("operation log retrieval test") {
withJdbcStatement { statement =>
operationLogRetrievalTest(statement)
}
}
}

0 comments on commit 22c73e3

Please sign in to comment.