Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 16 additions & 1 deletion .github/workflows/third_party_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,24 @@ jobs:
allow-licenses: >-
BSD-2-Clause, BSD-3-Clause, BSD-2-Clause-Views, MIT, MIT-0, ISC,
Apache-2.0, EPL-2.0, MPL-2.0, CC0-1.0, Python-2.0, BlueOak-1.0.0
# ([String]). Packages excluded from the license check, in purl format (optional).
# The action matches a purl on type and name only - it ignores the version - so an entry
# here allows every version of that package.
#
# caniuse-lite is browser-compatibility data used only by the UI build toolchain.
# Keep this exception package-specific because CC-BY-4.0 is not generally allow-listed.
allow-dependencies-licenses: pkg:npm/caniuse-lite@1.0.30001809
#
# Both JUnit coordinates are test-scope dependencies that no release artifact ships;
# fail-on-scopes below covers `development`, which is why they reach this check at all.
# org.junit.jupiter:junit-jupiter is EPL-2.0, a licence allow-licenses above already
# carries, but GitHub's dependency graph reports it as LicenseRef-bad-non-standard, so
# every pull request that adds a module with a JUnit 5 test fails on a licence the
# project has already approved. junit:junit is EPL-1.0, an ASF Category B licence, and
# the JUnit 4 tests that need it run through junit-vintage-engine.
allow-dependencies-licenses: >-
pkg:npm/caniuse-lite@1.0.30001809,
pkg:maven/org.junit.jupiter/junit-jupiter,
pkg:maven/junit/junit
# ([String]). Acknowledged advisories that must not fail the review (optional)
# org.codehaus.jackson:jackson-mapper-asl (GHSA-c27h-mcmw-48hv, GHSA-r6j9-8759-g62w):
# legacy Jackson 1.x is EOL and neither advisory has a fixed version. Hive's metastore
Expand Down
20 changes: 20 additions & 0 deletions fe/check/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,26 @@ under the License.
<property name="message" value="Trailing whitespace found."/>
<property name="fileExtensions" value=".java"/>
</module>
<!--
JUnit 4 is gone from this reactor. It is not a style preference: junit-vintage-engine is
still declared in fe/pom.xml only because the be-java-extensions modules have not been
migrated yet, and it is what drags in junit:junit - the one EPL-1.0 artifact in the build,
and a licence the Dependency License Review workflow has to carry a package exception for.
Every JUnit 4 test that comes back keeps both of those alive, so the gate is here rather
than in review. checkstyle runs at the validate phase with includeTestSourceDirectory, so
this fires on a plain `mvn test` too, not only in CI.

The pattern deliberately matches anywhere on the line, not just an import: a fully
qualified `@org.junit.After` needs no import, and the jupiter engine silently IGNORES it
rather than failing, so a teardown written that way stops running and takes its cleanup
with it. That is exactly how one survived in this tree.
-->
<module name="RegexpSingleline">
<property name="id" value="banJUnit4"/>
<property name="format" value="(?&lt;![\w.])(?:junit\.framework|junit\.textui|org\.junit)\.(?!jupiter\.|platform\.)"/>
<property name="message" value="JUnit 3/4 is not allowed; write the test with JUnit 5. org.junit.Test -&gt; org.junit.jupiter.api.Test, org.junit.Assert -&gt; Assertions (the message argument moves to the END of the call), @Before/@After -&gt; @BeforeEach/@AfterEach, @BeforeClass/@AfterClass -&gt; @BeforeAll/@AfterAll, @Ignore -&gt; @Disabled, @Rule TemporaryFolder -&gt; @TempDir, and @Test(expected=) or the ExpectedException rule -&gt; Assertions.assertThrows."/>
<property name="fileExtensions" value=".java"/>
</module>
<!--
Best effort guard against writing credentials to the log: catches a value whose name says it
holds a token/password/secret/peer identity being passed straight to a log call, either as a
Expand Down
10 changes: 10 additions & 0 deletions fe/check/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ under the License.
"https://checkstyle.org/dtds/suppressions_1_2.dtd">

<suppressions>
<!--
TEMPORARY. be-java-extensions is the one place left with JUnit 4 tests; those modules are
being rewritten in apache/doris#66729, so they are migrated there rather than conflicted
with here. Delete this suppression once that lands, and junit-vintage-engine in fe/pom.xml
with it - at that point nothing in this reactor runs a JUnit 4 test, and junit:junit stops
reaching the build. (The workflow's pkg:maven/junit/junit exception stays: the standalone
samples/ projects still declare junit:junit directly.)
-->
<suppress files="[\\/]be-java-extensions[\\/]" id="banJUnit4"/>

<!-- Excludes test files from having Javadocs for classes and methods -->
<suppress files="[\\/]jmockit[\\/]" checks=".*" />
<suppress files="[\\/]test[\\/]" checks="MissingJavadocMethod" />
Expand Down
54 changes: 26 additions & 28 deletions fe/fe-common/src/test/java/org/apache/doris/common/ConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

package org.apache.doris.common;

import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Field;
import java.nio.file.Files;
Expand All @@ -28,7 +28,7 @@
import java.util.Map;

public class ConfigTest {
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
Config config = new Config();
// create an empty config file to initialize Config
Expand All @@ -46,10 +46,10 @@ public void testSensitiveConfigIsMaskedWhenSet() {
Config.fe_meta_auth_token = "super-secret-token";

Map<String, String> dumped = ConfigBase.dump();
Assert.assertEquals(ConfigBase.SENSITIVE_CONF_MASK, dumped.get("fe_meta_auth_token"));
Assertions.assertEquals(ConfigBase.SENSITIVE_CONF_MASK, dumped.get("fe_meta_auth_token"));

String value = configInfoValue("fe_meta_auth_token");
Assert.assertEquals(ConfigBase.SENSITIVE_CONF_MASK, value);
Assertions.assertEquals(ConfigBase.SENSITIVE_CONF_MASK, value);
} finally {
Config.fe_meta_auth_token = old;
}
Expand All @@ -63,8 +63,8 @@ public void testAuthTokenIsMaskedWhenSet() {
try {
Config.auth_token = "super-secret-auth-token";

Assert.assertEquals(ConfigBase.SENSITIVE_CONF_MASK, ConfigBase.dump().get("auth_token"));
Assert.assertEquals(ConfigBase.SENSITIVE_CONF_MASK, configInfoValue("auth_token"));
Assertions.assertEquals(ConfigBase.SENSITIVE_CONF_MASK, ConfigBase.dump().get("auth_token"));
Assertions.assertEquals(ConfigBase.SENSITIVE_CONF_MASK, configInfoValue("auth_token"));
} finally {
Config.auth_token = old;
}
Expand All @@ -77,8 +77,8 @@ public void testEmptySensitiveConfigIsNotMasked() {
try {
Config.fe_meta_auth_token = "";

Assert.assertEquals("", ConfigBase.dump().get("fe_meta_auth_token"));
Assert.assertEquals("", configInfoValue("fe_meta_auth_token"));
Assertions.assertEquals("", ConfigBase.dump().get("fe_meta_auth_token"));
Assertions.assertEquals("", configInfoValue("fe_meta_auth_token"));
} finally {
Config.fe_meta_auth_token = old;
}
Expand All @@ -97,7 +97,7 @@ private static String configInfoValue(String key) {
public void testSetEmptyArray() throws ConfigException {
ConfigBase.setMutableConfig("mysql_compat_var_whitelist", "a,b,c");
ConfigBase.setMutableConfig("mysql_compat_var_whitelist", "");
Assert.assertEquals("array length should be 0", 0, Config.mysql_compat_var_whitelist.length);
Assertions.assertEquals(0, Config.mysql_compat_var_whitelist.length, "array length should be 0");
}

@Test
Expand All @@ -107,8 +107,7 @@ public void testConfFieldDescriptionsAreEnglishStrings() throws Exception {
if (confField == null) {
continue;
}
Assert.assertFalse("Chinese description found in config: " + field.getName(),
confField.description().matches(".*[\\u4e00-\\u9fff].*"));
Assertions.assertFalse(confField.description().matches(".*[\\u4e00-\\u9fff].*"), "Chinese description found in config: " + field.getName());
}
}

Expand All @@ -126,9 +125,8 @@ public void testSecurityPathConfigsAreNotRuntimeMutable() {
"force_sqlserver_jdbc_encrypt_false",
};
for (String key : opsOnlyConfigs) {
ConfigException e = Assert.assertThrows(key + " should not be runtime-mutable",
ConfigException.class, () -> ConfigBase.setMutableConfig(key, "x"));
Assert.assertTrue(e.getMessage().contains("is not mutable"));
ConfigException e = Assertions.assertThrows(ConfigException.class, () -> ConfigBase.setMutableConfig(key, "x"), key + " should not be runtime-mutable");
Assertions.assertTrue(e.getMessage().contains("is not mutable"));
}
}

Expand All @@ -137,16 +135,16 @@ public void testRejectDeprecatedInvertedIndexV1WithWhitespace() throws Exception
String originFormat = Config.inverted_index_storage_format;
try {
ConfigBase.setMutableConfig("inverted_index_storage_format", "V2");
ConfigException dynamicException = Assert.assertThrows(ConfigException.class,
ConfigException dynamicException = Assertions.assertThrows(ConfigException.class,
() -> ConfigBase.setMutableConfig("inverted_index_storage_format", " V1 "));
Assert.assertTrue(dynamicException.getMessage().contains("Inverted index V1 is deprecated"));
Assert.assertEquals("V2", Config.inverted_index_storage_format);
Assertions.assertTrue(dynamicException.getMessage().contains("Inverted index V1 is deprecated"));
Assertions.assertEquals("V2", Config.inverted_index_storage_format);

Config.inverted_index_storage_format = "V2";
ConfigException startupException = Assert.assertThrows(ConfigException.class,
ConfigException startupException = Assertions.assertThrows(ConfigException.class,
() -> InvertedIndexStorageFormatValidator.rejectStartupV1(" V1 "));
Assert.assertTrue(startupException.getMessage().contains("inverted_index_storage_format=V1"));
Assert.assertEquals("V2", Config.inverted_index_storage_format);
Assertions.assertTrue(startupException.getMessage().contains("inverted_index_storage_format=V1"));
Assertions.assertEquals("V2", Config.inverted_index_storage_format);
} finally {
Config.inverted_index_storage_format = originFormat;
}
Expand All @@ -157,10 +155,10 @@ public void testSetWebSqlMaxResultBytes() throws ConfigException {
long original = Config.web_sql_max_result_bytes;
try {
ConfigBase.setMutableConfig("web_sql_max_result_bytes", "32");
Assert.assertEquals(32, Config.web_sql_max_result_bytes);
Assert.assertThrows(ConfigException.class,
Assertions.assertEquals(32, Config.web_sql_max_result_bytes);
Assertions.assertThrows(ConfigException.class,
() -> ConfigBase.setMutableConfig("web_sql_max_result_bytes", "0"));
Assert.assertThrows(ConfigException.class,
Assertions.assertThrows(ConfigException.class,
() -> ConfigBase.setMutableConfig("web_sql_max_result_bytes", "104857601"));
} finally {
Config.web_sql_max_result_bytes = original;
Expand All @@ -176,15 +174,15 @@ public void testValidateWebSqlStartupConfig() throws ConfigException {
Config.validateWebSqlConfig();

Config.web_sql_session_idle_timeout_seconds = 0;
Assert.assertThrows(ConfigException.class, Config::validateWebSqlConfig);
Assertions.assertThrows(ConfigException.class, Config::validateWebSqlConfig);
Config.web_sql_session_idle_timeout_seconds = originalIdleTimeout;

Config.web_sql_max_sessions = 0;
Assert.assertThrows(ConfigException.class, Config::validateWebSqlConfig);
Assertions.assertThrows(ConfigException.class, Config::validateWebSqlConfig);
Config.web_sql_max_sessions = originalMaxSessions;

Config.web_sql_max_result_bytes = Config.WEB_SQL_MAX_RESULT_BYTES_UPPER_BOUND + 1;
Assert.assertThrows(ConfigException.class, Config::validateWebSqlConfig);
Assertions.assertThrows(ConfigException.class, Config::validateWebSqlConfig);
} finally {
Config.web_sql_session_idle_timeout_seconds = originalIdleTimeout;
Config.web_sql_max_sessions = originalMaxSessions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package org.apache.doris.common;

import com.fasterxml.jackson.core.io.schubfach.DoubleToDecimal;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.math.BigDecimal;
import java.math.MathContext;
Expand All @@ -34,30 +34,30 @@ public class FractionalFormatTest {

@Test
public void testBoundaryValues() {
Assert.assertEquals("0", FractionalFormat.getFormatStringValue(0.0));
Assert.assertEquals("-0", FractionalFormat.getFormatStringValue(-0.0));
Assert.assertEquals("NaN", FractionalFormat.getFormatStringValue(Double.NaN));
Assert.assertEquals("Infinity",
Assertions.assertEquals("0", FractionalFormat.getFormatStringValue(0.0));
Assertions.assertEquals("-0", FractionalFormat.getFormatStringValue(-0.0));
Assertions.assertEquals("NaN", FractionalFormat.getFormatStringValue(Double.NaN));
Assertions.assertEquals("Infinity",
FractionalFormat.getFormatStringValue(Double.POSITIVE_INFINITY));
Assert.assertEquals("-Infinity",
Assertions.assertEquals("-Infinity",
FractionalFormat.getFormatStringValue(Double.NEGATIVE_INFINITY));
Assert.assertEquals("0.0001", FractionalFormat.getFormatStringValue(1e-4));
Assert.assertEquals("1e-05", FractionalFormat.getFormatStringValue(1e-5));
Assert.assertEquals("1000000000000000",
Assertions.assertEquals("0.0001", FractionalFormat.getFormatStringValue(1e-4));
Assertions.assertEquals("1e-05", FractionalFormat.getFormatStringValue(1e-5));
Assertions.assertEquals("1000000000000000",
FractionalFormat.getFormatStringValue(1e15));
Assert.assertEquals("1e+16", FractionalFormat.getFormatStringValue(1e16));
Assert.assertEquals("1e+23", FractionalFormat.getFormatStringValue(1e23));
Assert.assertEquals("5.960464477539063e-08",
Assertions.assertEquals("1e+16", FractionalFormat.getFormatStringValue(1e16));
Assertions.assertEquals("1e+23", FractionalFormat.getFormatStringValue(1e23));
Assertions.assertEquals("5.960464477539063e-08",
FractionalFormat.getFormatStringValue(Math.scalb(1.0, -24)));
Assert.assertEquals("5e-324", FractionalFormat.getFormatStringValue(Double.MIN_VALUE));
Assert.assertEquals("1.7976931348623157e+308",
Assertions.assertEquals("5e-324", FractionalFormat.getFormatStringValue(Double.MIN_VALUE));
Assertions.assertEquals("1.7976931348623157e+308",
FractionalFormat.getFormatStringValue(Double.MAX_VALUE));

Assert.assertEquals("10000000", FractionalFormat.getFormatStringValue(1e7f));
Assert.assertEquals("1.2621775e-29",
Assertions.assertEquals("10000000", FractionalFormat.getFormatStringValue(1e7f));
Assertions.assertEquals("1.2621775e-29",
FractionalFormat.getFormatStringValue(Math.scalb(1.0f, -96)));
Assert.assertEquals("1e-45", FractionalFormat.getFormatStringValue(Float.MIN_VALUE));
Assert.assertEquals("3.4028235e+38",
Assertions.assertEquals("1e-45", FractionalFormat.getFormatStringValue(Float.MIN_VALUE));
Assertions.assertEquals("3.4028235e+38",
FractionalFormat.getFormatStringValue(Float.MAX_VALUE));
}

Expand All @@ -67,13 +67,13 @@ public void testRandomValuesRoundTrip() {
for (int i = 0; i < 10_000; i++) {
double value = nextFiniteDouble(random);
String formatted = FractionalFormat.getFormatStringValue(value);
Assert.assertEquals(Double.doubleToRawLongBits(value),
Assertions.assertEquals(Double.doubleToRawLongBits(value),
Double.doubleToRawLongBits(Double.parseDouble(formatted)));
}
for (int i = 0; i < 10_000; i++) {
float value = nextFiniteFloat(random);
String formatted = FractionalFormat.getFormatStringValue(value);
Assert.assertEquals(Float.floatToRawIntBits(value),
Assertions.assertEquals(Float.floatToRawIntBits(value),
Float.floatToRawIntBits(Float.parseFloat(formatted)));
}
}
Expand Down
20 changes: 10 additions & 10 deletions fe/fe-common/src/test/java/org/apache/doris/common/PairTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,39 @@

package org.apache.doris.common;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class PairTest {

@Test
public void testToString() {
Pair<String, Object> pairFirstNull = Pair.of(null, "world");
Assert.assertEquals(":world", pairFirstNull.toString());
Assertions.assertEquals(":world", pairFirstNull.toString());

Pair<String, Object> pairSecondNull = Pair.of("hello", null);
Assert.assertEquals("hello:", pairSecondNull.toString());
Assertions.assertEquals("hello:", pairSecondNull.toString());
}

@Test
public void testEquals() {
Pair<String, Object> firstPair = Pair.of(null, "world");
Pair<String, Object> secondPair = null;

Assert.assertTrue(firstPair.equals(firstPair));
Assert.assertFalse(firstPair.equals(secondPair));
Assertions.assertTrue(firstPair.equals(firstPair));
Assertions.assertFalse(firstPair.equals(secondPair));

secondPair = Pair.of(null, "world");
Assert.assertTrue(firstPair.equals(secondPair));
Assertions.assertTrue(firstPair.equals(secondPair));

secondPair = Pair.of("hello", null);
Assert.assertFalse(firstPair.equals(secondPair));
Assertions.assertFalse(firstPair.equals(secondPair));

firstPair = Pair.of("hello", "world");
secondPair = Pair.of("hello", "world");
Assert.assertTrue(firstPair.equals(secondPair));
Assertions.assertTrue(firstPair.equals(secondPair));

secondPair = Pair.of("world", "hello");
Assert.assertFalse(firstPair.equals(secondPair));
Assertions.assertFalse(firstPair.equals(secondPair));
}
}
Loading
Loading