-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
2892fb0
commit de80f85
Showing
4 changed files
with
111 additions
and
32 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
core/src/test/scala/com/pingcap/tispark/accumulator/AccumulatorSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* | ||
* Copyright 2022 PingCAP, Inc. | ||
* | ||
* Licensed 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 com.pingcap.tispark.accumulator; | ||
|
||
import org.apache.log4j.spi.LoggingEvent | ||
import org.apache.log4j.{AppenderSkeleton, Logger} | ||
import org.apache.spark.sql.BaseTiSparkTest | ||
|
||
import java.util | ||
import java.util.stream.Collectors; | ||
|
||
class AccumulatorSuite extends BaseTiSparkTest { | ||
test("cacheInvalidateCallback does not work") { | ||
val listLogAppender = new ListLogAppender | ||
val logger = Logger.getRootLogger | ||
logger.addAppender(listLogAppender) | ||
try { | ||
tidbStmt.execute("DROP TABLE IF EXISTS `t1`") | ||
tidbStmt.execute(""" | ||
|CREATE TABLE `t1` ( | ||
|`a` BIGINT(20) NOT NULL, | ||
|`b` varchar(255) NOT NULL, | ||
|`c` varchar(255) DEFAULT NULL | ||
|) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin | ||
""".stripMargin) | ||
spark.sql("SELECT * FROM t1").show() | ||
tidbStmt.execute( | ||
"SPLIT TABLE t1 BETWEEN (-9223372036854775808) AND (-8223372036854775808) REGIONS 300") | ||
spark.sql("SELECT * FROM t1").show() | ||
} finally { | ||
logger.removeAppender(listLogAppender) | ||
} | ||
val cacheInvalidateListenerLog = listLogAppender.getLog | ||
.stream() | ||
.filter(e => | ||
e.getMessage.toString.contains( | ||
"Failed to send notification back to driver since CacheInvalidateCallBack is null in executor node")) | ||
.collect(Collectors.toList[LoggingEvent]) | ||
assert(cacheInvalidateListenerLog.size() == 0) | ||
} | ||
|
||
class ListLogAppender extends AppenderSkeleton { | ||
|
||
final private val log = new util.ArrayList[LoggingEvent]() | ||
|
||
override def requiresLayout = false | ||
|
||
override protected def append(loggingEvent: LoggingEvent): Unit = { | ||
log.add(loggingEvent) | ||
} | ||
|
||
override def close(): Unit = {} | ||
|
||
def getLog = new util.ArrayList[LoggingEvent](log) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters