-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial PR for the framework reusing Vanilla Spark's unit tests (#10743)
* initial PR for the framework resuing Vanila Spark's UTs (borrow from Gluten) Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * fix shim complain Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * fix other shim compile issue Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * fix Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * fix for scala 2.13 Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * more to shim Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * clean pom Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * move everything to shim Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * 2.13 Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * move to spark330 Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * fix Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * fix bug Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * fix blossom ci Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * address license comment Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * address suites util package Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * address reason comment Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * address other comments Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * fix bug Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * address 2rd round of comments Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * get rid of UNKNOW_ISSUE Signed-off-by: Hongbin Ma (Mahone) <[email protected]> --------- Signed-off-by: Hongbin Ma (Mahone) <[email protected]>
- Loading branch information
Showing
22 changed files
with
1,822 additions
and
0 deletions.
There are no files selected for viewing
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
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
205 changes: 205 additions & 0 deletions
205
tests/src/test/java/com/nvidia/spark/rapids/TestStats.java
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,205 @@ | ||
/* | ||
* Copyright (c) 2024, NVIDIA CORPORATION. | ||
* | ||
* 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.nvidia.spark.rapids; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.Stack; | ||
|
||
/** Only use in UT Env. It's not thread safe. */ | ||
public class TestStats { | ||
private static final String HEADER_FORMAT = "<tr><th>%s</th><th colspan=5>%s</th></tr>"; | ||
private static final String ROW_FORMAT = | ||
"<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>"; | ||
|
||
private static boolean UT_ENV = false; | ||
private static final Map<String, CaseInfo> caseInfos = new HashMap<>(); | ||
private static String currentCase; | ||
public static int offloadRapidsUnitNumber = 0; | ||
public static int testUnitNumber = 0; | ||
|
||
// use the rapids backend to execute the query | ||
public static boolean offloadRapids = true; | ||
public static int suiteTestNumber = 0; | ||
public static int offloadRapidsTestNumber = 0; | ||
|
||
public static void beginStatistic() { | ||
UT_ENV = true; | ||
} | ||
|
||
public static void reset() { | ||
offloadRapids = false; | ||
suiteTestNumber = 0; | ||
offloadRapidsTestNumber = 0; | ||
testUnitNumber = 0; | ||
offloadRapidsUnitNumber = 0; | ||
resetCase(); | ||
caseInfos.clear(); | ||
} | ||
|
||
private static int totalSuiteTestNumber = 0; | ||
public static int totalOffloadRapidsTestNumber = 0; | ||
|
||
public static int totalTestUnitNumber = 0; | ||
public static int totalOffloadRapidsCaseNumber = 0; | ||
|
||
public static void printMarkdown(String suitName) { | ||
if (!UT_ENV) { | ||
return; | ||
} | ||
|
||
String title = "print_markdown_" + suitName; | ||
|
||
String info = | ||
"Case Count: %d, OffloadRapids Case Count: %d, " | ||
+ "Unit Count %d, OffloadRapids Unit Count %d"; | ||
|
||
System.out.println( | ||
String.format( | ||
HEADER_FORMAT, | ||
title, | ||
String.format( | ||
info, | ||
TestStats.suiteTestNumber, | ||
TestStats.offloadRapidsTestNumber, | ||
TestStats.testUnitNumber, | ||
TestStats.offloadRapidsUnitNumber))); | ||
|
||
caseInfos.forEach( | ||
(key, value) -> | ||
System.out.println( | ||
String.format( | ||
ROW_FORMAT, | ||
title, | ||
key, | ||
value.status, | ||
value.type, | ||
String.join("<br/>", value.fallbackExpressionName), | ||
String.join("<br/>", value.fallbackClassName)))); | ||
|
||
totalSuiteTestNumber += suiteTestNumber; | ||
totalOffloadRapidsTestNumber += offloadRapidsTestNumber; | ||
totalTestUnitNumber += testUnitNumber; | ||
totalOffloadRapidsCaseNumber += offloadRapidsUnitNumber; | ||
System.out.println( | ||
"total_markdown_ totalCaseNum:" | ||
+ totalSuiteTestNumber | ||
+ " offloadRapids: " | ||
+ totalOffloadRapidsTestNumber | ||
+ " total unit: " | ||
+ totalTestUnitNumber | ||
+ " offload unit: " | ||
+ totalOffloadRapidsCaseNumber); | ||
} | ||
|
||
public static void addFallBackClassName(String className) { | ||
if (!UT_ENV) { | ||
return; | ||
} | ||
|
||
if (caseInfos.containsKey(currentCase) && !caseInfos.get(currentCase).stack.isEmpty()) { | ||
CaseInfo info = caseInfos.get(currentCase); | ||
caseInfos.get(currentCase).fallbackExpressionName.add(info.stack.pop()); | ||
caseInfos.get(currentCase).fallbackClassName.add(className); | ||
} | ||
} | ||
|
||
public static void addFallBackCase() { | ||
if (!UT_ENV) { | ||
return; | ||
} | ||
|
||
if (caseInfos.containsKey(currentCase)) { | ||
caseInfos.get(currentCase).type = "fallback"; | ||
} | ||
} | ||
|
||
public static void addExpressionClassName(String className) { | ||
if (!UT_ENV) { | ||
return; | ||
} | ||
|
||
if (caseInfos.containsKey(currentCase)) { | ||
CaseInfo info = caseInfos.get(currentCase); | ||
info.stack.add(className); | ||
} | ||
} | ||
|
||
public static Set<String> getFallBackClassName() { | ||
if (!UT_ENV) { | ||
return Collections.emptySet(); | ||
} | ||
|
||
if (caseInfos.containsKey(currentCase)) { | ||
return Collections.unmodifiableSet(caseInfos.get(currentCase).fallbackExpressionName); | ||
} | ||
|
||
return Collections.emptySet(); | ||
} | ||
|
||
public static void addIgnoreCaseName(String caseName) { | ||
if (!UT_ENV) { | ||
return; | ||
} | ||
|
||
if (caseInfos.containsKey(caseName)) { | ||
caseInfos.get(caseName).type = "fatal"; | ||
} | ||
} | ||
|
||
public static void resetCase() { | ||
if (!UT_ENV) { | ||
return; | ||
} | ||
|
||
if (caseInfos.containsKey(currentCase)) { | ||
caseInfos.get(currentCase).stack.clear(); | ||
} | ||
currentCase = ""; | ||
} | ||
|
||
public static void startCase(String caseName) { | ||
if (!UT_ENV) { | ||
return; | ||
} | ||
|
||
caseInfos.putIfAbsent(caseName, new CaseInfo()); | ||
currentCase = caseName; | ||
} | ||
|
||
public static void endCase(boolean status) { | ||
if (!UT_ENV) { | ||
return; | ||
} | ||
|
||
if (caseInfos.containsKey(currentCase)) { | ||
caseInfos.get(currentCase).status = status ? "success" : "error"; | ||
} | ||
|
||
resetCase(); | ||
} | ||
} | ||
|
||
class CaseInfo { | ||
final Stack<String> stack = new Stack<>(); | ||
Set<String> fallbackExpressionName = new HashSet<>(); | ||
Set<String> fallbackClassName = new HashSet<>(); | ||
String type = ""; | ||
String status = ""; | ||
} |
Oops, something went wrong.