diff --git a/.github/workflows/third_party_review.yml b/.github/workflows/third_party_review.yml
index 879ebaa345594a..58172d002ed628 100644
--- a/.github/workflows/third_party_review.yml
+++ b/.github/workflows/third_party_review.yml
@@ -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
diff --git a/fe/check/checkstyle/checkstyle.xml b/fe/check/checkstyle/checkstyle.xml
index c97fbeed110b84..7e45b274463370 100644
--- a/fe/check/checkstyle/checkstyle.xml
+++ b/fe/check/checkstyle/checkstyle.xml
@@ -66,6 +66,26 @@ under the License.
+
+
+
+
+
+
+
+
+
diff --git a/fe/fe-common/src/test/java/org/apache/doris/common/ConfigTest.java b/fe/fe-common/src/test/java/org/apache/doris/common/ConfigTest.java
index 395ff41f620a0b..64778f4109127d 100644
--- a/fe/fe-common/src/test/java/org/apache/doris/common/ConfigTest.java
+++ b/fe/fe-common/src/test/java/org/apache/doris/common/ConfigTest.java
@@ -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;
@@ -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
@@ -46,10 +46,10 @@ public void testSensitiveConfigIsMaskedWhenSet() {
Config.fe_meta_auth_token = "super-secret-token";
Map 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;
}
@@ -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;
}
@@ -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;
}
@@ -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
@@ -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());
}
}
@@ -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"));
}
}
@@ -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;
}
@@ -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;
@@ -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;
diff --git a/fe/fe-common/src/test/java/org/apache/doris/common/FractionalFormatTest.java b/fe/fe-common/src/test/java/org/apache/doris/common/FractionalFormatTest.java
index c53b6e6dff6721..53a49087ee8dde 100644
--- a/fe/fe-common/src/test/java/org/apache/doris/common/FractionalFormatTest.java
+++ b/fe/fe-common/src/test/java/org/apache/doris/common/FractionalFormatTest.java
@@ -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;
@@ -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));
}
@@ -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)));
}
}
diff --git a/fe/fe-common/src/test/java/org/apache/doris/common/PairTest.java b/fe/fe-common/src/test/java/org/apache/doris/common/PairTest.java
index 11daa2075de32c..c98e60f28dbe6b 100644
--- a/fe/fe-common/src/test/java/org/apache/doris/common/PairTest.java
+++ b/fe/fe-common/src/test/java/org/apache/doris/common/PairTest.java
@@ -17,18 +17,18 @@
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 pairFirstNull = Pair.of(null, "world");
- Assert.assertEquals(":world", pairFirstNull.toString());
+ Assertions.assertEquals(":world", pairFirstNull.toString());
Pair pairSecondNull = Pair.of("hello", null);
- Assert.assertEquals("hello:", pairSecondNull.toString());
+ Assertions.assertEquals("hello:", pairSecondNull.toString());
}
@Test
@@ -36,20 +36,20 @@ public void testEquals() {
Pair firstPair = Pair.of(null, "world");
Pair 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));
}
}
diff --git a/fe/fe-common/src/test/java/org/apache/doris/common/io/BitmapValueTest.java b/fe/fe-common/src/test/java/org/apache/doris/common/io/BitmapValueTest.java
index 785574981dbb5c..08d293041a2e31 100644
--- a/fe/fe-common/src/test/java/org/apache/doris/common/io/BitmapValueTest.java
+++ b/fe/fe-common/src/test/java/org/apache/doris/common/io/BitmapValueTest.java
@@ -17,8 +17,8 @@
package org.apache.doris.common.io;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -36,23 +36,23 @@ public void testVarint64IntEncode() throws IOException {
ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream();
DataOutput output = new DataOutputStream(byteArrayOutput);
Codec.encodeVarint64(value, output);
- Assert.assertEquals(value, Codec.decodeVarint64(new DataInputStream(new ByteArrayInputStream(byteArrayOutput.toByteArray()))));
+ Assertions.assertEquals(value, Codec.decodeVarint64(new DataInputStream(new ByteArrayInputStream(byteArrayOutput.toByteArray()))));
}
}
@Test
public void testBitmapTypeTransfer() {
BitmapValue bitmapValue = new BitmapValue();
- Assert.assertTrue(bitmapValue.getBitmapType() == BitmapValue.EMPTY);
+ Assertions.assertTrue(bitmapValue.getBitmapType() == BitmapValue.EMPTY);
bitmapValue.add(1);
- Assert.assertTrue(bitmapValue.getBitmapType() == BitmapValue.SINGLE_VALUE);
+ Assertions.assertTrue(bitmapValue.getBitmapType() == BitmapValue.SINGLE_VALUE);
bitmapValue.add(2);
- Assert.assertTrue(bitmapValue.getBitmapType() == BitmapValue.BITMAP_VALUE);
+ Assertions.assertTrue(bitmapValue.getBitmapType() == BitmapValue.BITMAP_VALUE);
bitmapValue.clear();
- Assert.assertTrue(bitmapValue.getBitmapType() == BitmapValue.EMPTY);
+ Assertions.assertTrue(bitmapValue.getBitmapType() == BitmapValue.EMPTY);
}
@Test
@@ -63,9 +63,9 @@ public void testBitmapValueAdd() {
bitmapValue1.add(i);
}
for (int i = 0; i < 10; i++) {
- Assert.assertTrue(bitmapValue1.contains(i));
+ Assertions.assertTrue(bitmapValue1.contains(i));
}
- Assert.assertFalse(bitmapValue1.contains(11));
+ Assertions.assertFalse(bitmapValue1.contains(11));
// test add long
BitmapValue bitmapValue2 = new BitmapValue();
@@ -73,9 +73,9 @@ public void testBitmapValueAdd() {
bitmapValue2.add(i);
}
for (long i = Long.MAX_VALUE; i > Long.MAX_VALUE - 10; i--) {
- Assert.assertTrue(bitmapValue2.contains(i));
+ Assertions.assertTrue(bitmapValue2.contains(i));
}
- Assert.assertFalse(bitmapValue2.contains(0));
+ Assertions.assertFalse(bitmapValue2.contains(0));
// test add int and long
for (int i = 0; i < 10; i++) {
@@ -83,19 +83,19 @@ public void testBitmapValueAdd() {
}
for (long i = Long.MAX_VALUE; i > Long.MAX_VALUE - 10; i--) {
- Assert.assertTrue(bitmapValue2.contains(i));
+ Assertions.assertTrue(bitmapValue2.contains(i));
}
for (int i = 0; i < 10; i++) {
- Assert.assertTrue(bitmapValue2.contains(i));
+ Assertions.assertTrue(bitmapValue2.contains(i));
}
- Assert.assertFalse(bitmapValue2.contains(100));
+ Assertions.assertFalse(bitmapValue2.contains(100));
// test distinct
BitmapValue bitmapValue = new BitmapValue();
bitmapValue.add(1);
bitmapValue.add(1);
- Assert.assertTrue(bitmapValue.getBitmapType() == BitmapValue.SINGLE_VALUE);
- Assert.assertTrue(bitmapValue.cardinality() == 1);
+ Assertions.assertTrue(bitmapValue.getBitmapType() == BitmapValue.SINGLE_VALUE);
+ Assertions.assertTrue(bitmapValue.cardinality() == 1);
}
@Test
@@ -104,16 +104,16 @@ public void testBitmapValueAnd() {
BitmapValue bitmapValue1 = new BitmapValue();
BitmapValue bitmapValue1Dot1 = new BitmapValue();
bitmapValue1.and(bitmapValue1Dot1);
- Assert.assertTrue(bitmapValue1.getBitmapType() == BitmapValue.EMPTY);
- Assert.assertTrue(bitmapValue1.cardinality() == 0);
+ Assertions.assertTrue(bitmapValue1.getBitmapType() == BitmapValue.EMPTY);
+ Assertions.assertTrue(bitmapValue1.cardinality() == 0);
// empty and single value
BitmapValue bitmapValue2 = new BitmapValue();
BitmapValue bitmapValue2Dot1 = new BitmapValue();
bitmapValue2Dot1.add(1);
bitmapValue2.and(bitmapValue2Dot1);
- Assert.assertTrue(bitmapValue2.getBitmapType() == BitmapValue.EMPTY);
- Assert.assertTrue(bitmapValue2.cardinality() == 0);
+ Assertions.assertTrue(bitmapValue2.getBitmapType() == BitmapValue.EMPTY);
+ Assertions.assertTrue(bitmapValue2.cardinality() == 0);
// empty and bitmap
BitmapValue bitmapValue3 = new BitmapValue();
@@ -121,16 +121,16 @@ public void testBitmapValueAnd() {
bitmapValue3Dot1.add(1);
bitmapValue3Dot1.add(2);
bitmapValue3.and(bitmapValue3Dot1);
- Assert.assertTrue(bitmapValue2.getBitmapType() == BitmapValue.EMPTY);
- Assert.assertTrue(bitmapValue3.cardinality() == 0);
+ Assertions.assertTrue(bitmapValue2.getBitmapType() == BitmapValue.EMPTY);
+ Assertions.assertTrue(bitmapValue3.cardinality() == 0);
// single value and empty
BitmapValue bitmapValue4 = new BitmapValue();
bitmapValue4.add(1);
BitmapValue bitmapValue4Dot1 = new BitmapValue();
bitmapValue4.and(bitmapValue4Dot1);
- Assert.assertTrue(bitmapValue4.getBitmapType() == BitmapValue.EMPTY);
- Assert.assertTrue(bitmapValue4.cardinality() == 0);
+ Assertions.assertTrue(bitmapValue4.getBitmapType() == BitmapValue.EMPTY);
+ Assertions.assertTrue(bitmapValue4.cardinality() == 0);
// single value and single value
BitmapValue bitmapValue5 = new BitmapValue();
@@ -138,15 +138,15 @@ public void testBitmapValueAnd() {
BitmapValue bitmapValue5Dot1 = new BitmapValue();
bitmapValue5Dot1.add(1);
bitmapValue5.and(bitmapValue5Dot1);
- Assert.assertTrue(bitmapValue5.getBitmapType() == BitmapValue.SINGLE_VALUE);
- Assert.assertTrue(bitmapValue5.contains(1));
+ Assertions.assertTrue(bitmapValue5.getBitmapType() == BitmapValue.SINGLE_VALUE);
+ Assertions.assertTrue(bitmapValue5.contains(1));
bitmapValue5.clear();
bitmapValue5Dot1.clear();
bitmapValue5.add(1);
bitmapValue5Dot1.add(2);
bitmapValue5.and(bitmapValue5Dot1);
- Assert.assertTrue(bitmapValue5.getBitmapType() == BitmapValue.EMPTY);
+ Assertions.assertTrue(bitmapValue5.getBitmapType() == BitmapValue.EMPTY);
// single value and bitmap
BitmapValue bitmapValue6 = new BitmapValue();
@@ -155,12 +155,12 @@ public void testBitmapValueAnd() {
bitmapValue6Dot1.add(1);
bitmapValue6Dot1.add(2);
bitmapValue6.and(bitmapValue6Dot1);
- Assert.assertTrue(bitmapValue6.getBitmapType() == BitmapValue.SINGLE_VALUE);
+ Assertions.assertTrue(bitmapValue6.getBitmapType() == BitmapValue.SINGLE_VALUE);
bitmapValue6.clear();
bitmapValue6.add(3);
bitmapValue6.and(bitmapValue6Dot1);
- Assert.assertTrue(bitmapValue6.getBitmapType() == BitmapValue.EMPTY);
+ Assertions.assertTrue(bitmapValue6.getBitmapType() == BitmapValue.EMPTY);
// bitmap and empty
BitmapValue bitmapValue7 = new BitmapValue();
@@ -168,7 +168,7 @@ public void testBitmapValueAnd() {
bitmapValue7.add(2);
BitmapValue bitmapValue7Dot1 = new BitmapValue();
bitmapValue7.and(bitmapValue7Dot1);
- Assert.assertTrue(bitmapValue7.getBitmapType() == BitmapValue.EMPTY);
+ Assertions.assertTrue(bitmapValue7.getBitmapType() == BitmapValue.EMPTY);
// bitmap and single value
BitmapValue bitmapValue8 = new BitmapValue();
@@ -177,13 +177,13 @@ public void testBitmapValueAnd() {
BitmapValue bitmapValue8Dot1 = new BitmapValue();
bitmapValue8Dot1.add(1);
bitmapValue8.and(bitmapValue8Dot1);
- Assert.assertTrue(bitmapValue8.getBitmapType() == BitmapValue.SINGLE_VALUE);
+ Assertions.assertTrue(bitmapValue8.getBitmapType() == BitmapValue.SINGLE_VALUE);
bitmapValue8.clear();
bitmapValue8.add(2);
bitmapValue8.add(3);
bitmapValue8.and(bitmapValue8Dot1);
- Assert.assertTrue(bitmapValue8.getBitmapType() == BitmapValue.EMPTY);
+ Assertions.assertTrue(bitmapValue8.getBitmapType() == BitmapValue.EMPTY);
// bitmap and bitmap
BitmapValue bitmapValue9 = new BitmapValue();
@@ -193,21 +193,21 @@ public void testBitmapValueAnd() {
bitmapValue9Dot1.add(2);
bitmapValue9Dot1.add(3);
bitmapValue9.and(bitmapValue9Dot1);
- Assert.assertTrue(bitmapValue9.getBitmapType() == BitmapValue.SINGLE_VALUE);
+ Assertions.assertTrue(bitmapValue9.getBitmapType() == BitmapValue.SINGLE_VALUE);
bitmapValue9.clear();
bitmapValue9.add(4);
bitmapValue9.add(5);
bitmapValue9.and(bitmapValue9Dot1);
- Assert.assertTrue(bitmapValue9.getBitmapType() == BitmapValue.EMPTY);
+ Assertions.assertTrue(bitmapValue9.getBitmapType() == BitmapValue.EMPTY);
bitmapValue9.clear();
bitmapValue9.add(2);
bitmapValue9.add(3);
bitmapValue9.add(4);
bitmapValue9.and(bitmapValue9Dot1);
- Assert.assertTrue(bitmapValue9.getBitmapType() == BitmapValue.BITMAP_VALUE);
- Assert.assertTrue(bitmapValue9.equals(bitmapValue9Dot1));
+ Assertions.assertTrue(bitmapValue9.getBitmapType() == BitmapValue.BITMAP_VALUE);
+ Assertions.assertTrue(bitmapValue9.equals(bitmapValue9Dot1));
}
@@ -217,14 +217,14 @@ public void testBitmapValueOr() {
BitmapValue bitmapValue1 = new BitmapValue();
BitmapValue bitmapValue1Dot1 = new BitmapValue();
bitmapValue1.or(bitmapValue1Dot1);
- Assert.assertTrue(bitmapValue1.getBitmapType() == BitmapValue.EMPTY);
+ Assertions.assertTrue(bitmapValue1.getBitmapType() == BitmapValue.EMPTY);
// empty or single value
BitmapValue bitmapValue2 = new BitmapValue();
BitmapValue bitmapValue2Dot1 = new BitmapValue();
bitmapValue2Dot1.add(1);
bitmapValue2.or(bitmapValue2Dot1);
- Assert.assertTrue(bitmapValue2.getBitmapType() == BitmapValue.SINGLE_VALUE);
+ Assertions.assertTrue(bitmapValue2.getBitmapType() == BitmapValue.SINGLE_VALUE);
// empty or bitmap
BitmapValue bitmapValue3 = new BitmapValue();
@@ -232,14 +232,14 @@ public void testBitmapValueOr() {
bitmapValue3Dot1.add(1);
bitmapValue3Dot1.add(2);
bitmapValue3.or(bitmapValue3Dot1);
- Assert.assertTrue(bitmapValue3.getBitmapType() == BitmapValue.BITMAP_VALUE);
+ Assertions.assertTrue(bitmapValue3.getBitmapType() == BitmapValue.BITMAP_VALUE);
// single or and empty
BitmapValue bitmapValue4 = new BitmapValue();
BitmapValue bitmapValue4Dot1 = new BitmapValue();
bitmapValue4.add(1);
bitmapValue4.or(bitmapValue4Dot1);
- Assert.assertTrue(bitmapValue4.getBitmapType() == BitmapValue.SINGLE_VALUE);
+ Assertions.assertTrue(bitmapValue4.getBitmapType() == BitmapValue.SINGLE_VALUE);
// single or and single value
BitmapValue bitmapValue5 = new BitmapValue();
@@ -247,12 +247,12 @@ public void testBitmapValueOr() {
bitmapValue5.add(1);
bitmapValue5Dot1.add(1);
bitmapValue5.or(bitmapValue5Dot1);
- Assert.assertTrue(bitmapValue5.getBitmapType() == BitmapValue.SINGLE_VALUE);
+ Assertions.assertTrue(bitmapValue5.getBitmapType() == BitmapValue.SINGLE_VALUE);
bitmapValue5.clear();
bitmapValue5.add(2);
bitmapValue5.or(bitmapValue5Dot1);
- Assert.assertTrue(bitmapValue5.getBitmapType() == BitmapValue.BITMAP_VALUE);
+ Assertions.assertTrue(bitmapValue5.getBitmapType() == BitmapValue.BITMAP_VALUE);
// single or and bitmap
BitmapValue bitmapValue6 = new BitmapValue();
@@ -261,7 +261,7 @@ public void testBitmapValueOr() {
bitmapValue6Dot1.add(1);
bitmapValue6Dot1.add(2);
bitmapValue6.or(bitmapValue6Dot1);
- Assert.assertTrue(bitmapValue6.getBitmapType() == BitmapValue.BITMAP_VALUE);
+ Assertions.assertTrue(bitmapValue6.getBitmapType() == BitmapValue.BITMAP_VALUE);
// bitmap or empty
BitmapValue bitmapValue7 = new BitmapValue();
@@ -269,7 +269,7 @@ public void testBitmapValueOr() {
bitmapValue7.add(2);
BitmapValue bitmapValue7Dot1 = new BitmapValue();
bitmapValue7.or(bitmapValue7Dot1);
- Assert.assertTrue(bitmapValue7.getBitmapType() == BitmapValue.BITMAP_VALUE);
+ Assertions.assertTrue(bitmapValue7.getBitmapType() == BitmapValue.BITMAP_VALUE);
// bitmap or single value
BitmapValue bitmapValue8 = new BitmapValue();
@@ -278,7 +278,7 @@ public void testBitmapValueOr() {
BitmapValue bitmapValue8Dot1 = new BitmapValue();
bitmapValue8Dot1.add(1);
bitmapValue8.or(bitmapValue8Dot1);
- Assert.assertTrue(bitmapValue8.getBitmapType() == BitmapValue.BITMAP_VALUE);
+ Assertions.assertTrue(bitmapValue8.getBitmapType() == BitmapValue.BITMAP_VALUE);
// bitmap or bitmap
BitmapValue bitmapValue9 = new BitmapValue();
@@ -286,7 +286,7 @@ public void testBitmapValueOr() {
bitmapValue9.add(2);
BitmapValue bitmapValue9Dot1 = new BitmapValue();
bitmapValue9.or(bitmapValue9Dot1);
- Assert.assertTrue(bitmapValue9.getBitmapType() == BitmapValue.BITMAP_VALUE);
+ Assertions.assertTrue(bitmapValue9.getBitmapType() == BitmapValue.BITMAP_VALUE);
}
@Test
@@ -301,7 +301,7 @@ public void testBitmapValueSerializeAndDeserialize() throws IOException {
BitmapValue deserializeBitmapValue = new BitmapValue();
deserializeBitmapValue.deserialize(emptyInputStream);
- Assert.assertTrue(serializeBitmapValue.equals(deserializeBitmapValue));
+ Assertions.assertTrue(serializeBitmapValue.equals(deserializeBitmapValue));
// single value
BitmapValue serializeSingleValueBitmapValue = new BitmapValue();
@@ -316,7 +316,7 @@ public void testBitmapValueSerializeAndDeserialize() throws IOException {
BitmapValue deserializeSingleValueBitmapValue = new BitmapValue();
deserializeSingleValueBitmapValue.deserialize(singleValueInputStream);
- Assert.assertTrue(serializeSingleValueBitmapValue.equals(deserializeSingleValueBitmapValue));
+ Assertions.assertTrue(serializeSingleValueBitmapValue.equals(deserializeSingleValueBitmapValue));
// bitmap
// case 1 : 32-bit bitmap
@@ -332,7 +332,7 @@ public void testBitmapValueSerializeAndDeserialize() throws IOException {
BitmapValue deserializeBitmapBitmapValue = new BitmapValue();
deserializeBitmapBitmapValue.deserialize(bitmapInputStream);
- Assert.assertTrue(serializeBitmapBitmapValue.equals(deserializeBitmapBitmapValue));
+ Assertions.assertTrue(serializeBitmapBitmapValue.equals(deserializeBitmapBitmapValue));
// bitmap
@@ -349,7 +349,7 @@ public void testBitmapValueSerializeAndDeserialize() throws IOException {
BitmapValue deserializeBitmapBitmapValue64 = new BitmapValue();
deserializeBitmapBitmapValue64.deserialize(bitmapInputStream64);
- Assert.assertTrue(serializeBitmapBitmapValue64.equals(deserializeBitmapBitmapValue64));
+ Assertions.assertTrue(serializeBitmapBitmapValue64.equals(deserializeBitmapBitmapValue64));
}
@Test
@@ -362,17 +362,17 @@ public void testIs32BitsEnough() {
long unsigned32bit = Integer.MAX_VALUE;
bitmapValue.add(unsigned32bit + 1);
- Assert.assertTrue(bitmapValue.is32BitsEnough());
+ Assertions.assertTrue(bitmapValue.is32BitsEnough());
bitmapValue.add(Long.MAX_VALUE);
- Assert.assertFalse(bitmapValue.is32BitsEnough());
+ Assertions.assertFalse(bitmapValue.is32BitsEnough());
}
@Test
public void testCardinality() {
BitmapValue bitmapValue = new BitmapValue();
- Assert.assertTrue(bitmapValue.cardinality() == 0);
+ Assertions.assertTrue(bitmapValue.cardinality() == 0);
bitmapValue.add(0);
bitmapValue.add(0);
@@ -387,25 +387,25 @@ public void testCardinality() {
bitmapValue.add(-Long.MAX_VALUE);
bitmapValue.add(-Long.MAX_VALUE);
- Assert.assertTrue(bitmapValue.cardinality() == 6);
+ Assertions.assertTrue(bitmapValue.cardinality() == 6);
}
@Test
public void testContains() {
// empty
BitmapValue bitmapValue = new BitmapValue();
- Assert.assertFalse(bitmapValue.contains(1));
+ Assertions.assertFalse(bitmapValue.contains(1));
// single value
bitmapValue.add(1);
- Assert.assertTrue(bitmapValue.contains(1));
- Assert.assertFalse(bitmapValue.contains(2));
+ Assertions.assertTrue(bitmapValue.contains(1));
+ Assertions.assertFalse(bitmapValue.contains(2));
// bitmap
bitmapValue.add(2);
- Assert.assertTrue(bitmapValue.contains(1));
- Assert.assertTrue(bitmapValue.contains(2));
- Assert.assertFalse(bitmapValue.contains(12));
+ Assertions.assertTrue(bitmapValue.contains(1));
+ Assertions.assertTrue(bitmapValue.contains(2));
+ Assertions.assertFalse(bitmapValue.contains(12));
}
@Test
@@ -413,48 +413,48 @@ public void testEqual() {
// empty == empty
BitmapValue emp1 = new BitmapValue();
BitmapValue emp2 = new BitmapValue();
- Assert.assertTrue(emp1.equals(emp2));
+ Assertions.assertTrue(emp1.equals(emp2));
// empty == single value
emp2.add(1);
- Assert.assertFalse(emp1.equals(emp2));
+ Assertions.assertFalse(emp1.equals(emp2));
// empty == bitmap
emp2.add(2);
- Assert.assertFalse(emp1.equals(emp2));
+ Assertions.assertFalse(emp1.equals(emp2));
// single value = empty
BitmapValue sgv = new BitmapValue();
sgv.add(1);
BitmapValue emp3 = new BitmapValue();
- Assert.assertFalse(sgv.equals(emp3));
+ Assertions.assertFalse(sgv.equals(emp3));
// single value = single value
BitmapValue sgv1 = new BitmapValue();
sgv1.add(1);
BitmapValue sgv2 = new BitmapValue();
sgv2.add(2);
- Assert.assertTrue(sgv.equals(sgv1));
- Assert.assertFalse(sgv.equals(sgv2));
+ Assertions.assertTrue(sgv.equals(sgv1));
+ Assertions.assertFalse(sgv.equals(sgv2));
// single value = bitmap
sgv2.add(3);
- Assert.assertFalse(sgv.equals(sgv2));
+ Assertions.assertFalse(sgv.equals(sgv2));
// bitmap == empty
BitmapValue bitmapValue = new BitmapValue();
bitmapValue.add(1);
bitmapValue.add(2);
BitmapValue emp4 = new BitmapValue();
- Assert.assertFalse(bitmapValue.equals(emp4));
+ Assertions.assertFalse(bitmapValue.equals(emp4));
// bitmap == singlevalue
BitmapValue sgv3 = new BitmapValue();
sgv3.add(1);
- Assert.assertFalse(bitmapValue.equals(sgv3));
+ Assertions.assertFalse(bitmapValue.equals(sgv3));
// bitmap == bitmap
BitmapValue bitmapValue1 = new BitmapValue();
bitmapValue1.add(1);
BitmapValue bitmapValue2 = new BitmapValue();
bitmapValue2.add(1);
bitmapValue2.add(2);
- Assert.assertTrue(bitmapValue.equals(bitmapValue2));
- Assert.assertFalse(bitmapValue.equals(bitmapValue1));
+ Assertions.assertTrue(bitmapValue.equals(bitmapValue2));
+ Assertions.assertFalse(bitmapValue.equals(bitmapValue1));
}
@@ -469,16 +469,16 @@ public void testBitmapOrDeepCopy() {
BitmapValue rollup1 = new BitmapValue();
rollup1.add(3L);
rollup1.add(4L);
- Assert.assertTrue(rollup1.getBitmapType() == BitmapValue.BITMAP_VALUE);
+ Assertions.assertTrue(rollup1.getBitmapType() == BitmapValue.BITMAP_VALUE);
BitmapValue bitmapValMerge = new BitmapValue();
// or operator is supposed to deep copy Roaring64Map object
bitmapValMerge.or(baseIndex1);
bitmapValMerge.or(rollup1);
- Assert.assertTrue(bitmapValMerge.getBitmapType() == BitmapValue.BITMAP_VALUE);
+ Assertions.assertTrue(bitmapValMerge.getBitmapType() == BitmapValue.BITMAP_VALUE);
- Assert.assertTrue(baseIndex1.cardinality() == 2L);
- Assert.assertTrue(rollup1.cardinality() == 2L);
- Assert.assertTrue(bitmapValMerge.cardinality() == 4L);
+ Assertions.assertTrue(baseIndex1.cardinality() == 2L);
+ Assertions.assertTrue(rollup1.cardinality() == 2L);
+ Assertions.assertTrue(bitmapValMerge.cardinality() == 4L);
//rollupIndex bitmap type == SINGLE_VALUE
BitmapValue rollup2 = new BitmapValue();
@@ -486,31 +486,31 @@ public void testBitmapOrDeepCopy() {
BitmapValue singleValMerge = new BitmapValue();
singleValMerge.or(rollup2);
- Assert.assertTrue(singleValMerge.getBitmapType() == BitmapValue.SINGLE_VALUE);
+ Assertions.assertTrue(singleValMerge.getBitmapType() == BitmapValue.SINGLE_VALUE);
singleValMerge.or(baseIndex1);
// update merged bitmap and check whether the original bitmap changed
singleValMerge.add(6L);
singleValMerge.add(7L);
- Assert.assertTrue(singleValMerge.cardinality() == 5L);
- Assert.assertTrue(baseIndex1.cardinality() == 2L);
- Assert.assertTrue(rollup2.cardinality() == 1L);
+ Assertions.assertTrue(singleValMerge.cardinality() == 5L);
+ Assertions.assertTrue(baseIndex1.cardinality() == 2L);
+ Assertions.assertTrue(rollup2.cardinality() == 1L);
}
@Test
public void testToString() {
BitmapValue empty = new BitmapValue();
- Assert.assertTrue(empty.toString().equals("{}"));
+ Assertions.assertTrue(empty.toString().equals("{}"));
BitmapValue singleValue = new BitmapValue();
singleValue.add(1);
- Assert.assertTrue(singleValue.toString().equals("{1}"));
+ Assertions.assertTrue(singleValue.toString().equals("{1}"));
BitmapValue bitmap = new BitmapValue();
bitmap.add(1);
bitmap.add(2);
- Assert.assertTrue(bitmap.toString().equals("{1,2}"));
+ Assertions.assertTrue(bitmap.toString().equals("{1,2}"));
}
}
diff --git a/fe/fe-common/src/test/java/org/apache/doris/common/io/ByteBufferNetworkInputStreamTest.java b/fe/fe-common/src/test/java/org/apache/doris/common/io/ByteBufferNetworkInputStreamTest.java
index 1480cc31f562fc..5416d7d9978abd 100644
--- a/fe/fe-common/src/test/java/org/apache/doris/common/io/ByteBufferNetworkInputStreamTest.java
+++ b/fe/fe-common/src/test/java/org/apache/doris/common/io/ByteBufferNetworkInputStreamTest.java
@@ -17,8 +17,8 @@
package org.apache.doris.common.io;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.IOException;
@@ -35,9 +35,9 @@ public void testMultiByteBuffer() throws IOException, InterruptedException {
inputStream.markFinished();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
- Assert.assertEquals(bufferedReader.readLine(), "1\t2");
- Assert.assertEquals(bufferedReader.readLine(), "2\t3");
- Assert.assertNull(bufferedReader.readLine());
+ Assertions.assertEquals(bufferedReader.readLine(), "1\t2");
+ Assertions.assertEquals(bufferedReader.readLine(), "2\t3");
+ Assertions.assertNull(bufferedReader.readLine());
bufferedReader.close();
}
@@ -65,18 +65,18 @@ public void testMultiThreadByteBuffer() throws IOException, InterruptedException
int count = 0;
String line = bufferedReader.readLine();
while (line != null) {
- Assert.assertEquals(line, String.format("%d\t%d", count, count + 1));
+ Assertions.assertEquals(line, String.format("%d\t%d", count, count + 1));
count++;
line = bufferedReader.readLine();
}
- Assert.assertEquals(count, num);
+ Assertions.assertEquals(count, num);
} catch (Exception e) {
e.printStackTrace();
}
});
thread2.start();
thread2.join();
- Assert.assertFalse(thread1.isAlive());
+ Assertions.assertFalse(thread1.isAlive());
inputStream.close();
}
@@ -104,19 +104,19 @@ public void testMultiThreadByteBuffer2() throws IOException, InterruptedExceptio
int count = 0;
String line = bufferedReader.readLine();
while (line != null) {
- Assert.assertEquals(line, String.format("%d\t%d", count, count + 1));
+ Assertions.assertEquals(line, String.format("%d\t%d", count, count + 1));
count++;
Thread.sleep(500);
line = bufferedReader.readLine();
}
- Assert.assertEquals(count, num);
+ Assertions.assertEquals(count, num);
} catch (Exception e) {
e.printStackTrace();
}
});
thread2.start();
thread2.join();
- Assert.assertFalse(thread1.isAlive());
+ Assertions.assertFalse(thread1.isAlive());
inputStream.close();
}
}
diff --git a/fe/fe-common/src/test/java/org/apache/doris/common/io/DiskUtilsTest.java b/fe/fe-common/src/test/java/org/apache/doris/common/io/DiskUtilsTest.java
index d0582efee27c36..984a7eb7e3e6b8 100644
--- a/fe/fe-common/src/test/java/org/apache/doris/common/io/DiskUtilsTest.java
+++ b/fe/fe-common/src/test/java/org/apache/doris/common/io/DiskUtilsTest.java
@@ -17,8 +17,8 @@
package org.apache.doris.common.io;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class DiskUtilsTest {
@Test
@@ -44,13 +44,13 @@ public void testSiseFormat() {
};
for (int i = 0; i < values.length; i++) {
- Assert.assertEquals(values[i], DiskUtils.sizeFormat(keys[i]));
+ Assertions.assertEquals(values[i], DiskUtils.sizeFormat(keys[i]));
}
}
@Test
public void testDf() {
DiskUtils.Df d = DiskUtils.df("/");
- Assert.assertTrue(d.fileSystem.length() != 0);
+ Assertions.assertTrue(d.fileSystem.length() != 0);
}
}
diff --git a/fe/fe-common/src/test/java/org/apache/doris/common/io/HllTest.java b/fe/fe-common/src/test/java/org/apache/doris/common/io/HllTest.java
index 94333f255a657d..ced1b579070cf1 100644
--- a/fe/fe-common/src/test/java/org/apache/doris/common/io/HllTest.java
+++ b/fe/fe-common/src/test/java/org/apache/doris/common/io/HllTest.java
@@ -17,8 +17,8 @@
package org.apache.doris.common.io;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -31,10 +31,10 @@ public class HllTest {
@Test
public void testFindFirstNonZeroBitPosition() {
- Assert.assertTrue(Hll.getLongTailZeroNum(0) == 0);
- Assert.assertTrue(Hll.getLongTailZeroNum(1) == 0);
- Assert.assertTrue(Hll.getLongTailZeroNum(1L << 30) == 30);
- Assert.assertTrue(Hll.getLongTailZeroNum(1L << 62) == 62);
+ Assertions.assertTrue(Hll.getLongTailZeroNum(0) == 0);
+ Assertions.assertTrue(Hll.getLongTailZeroNum(1) == 0);
+ Assertions.assertTrue(Hll.getLongTailZeroNum(1L << 30) == 30);
+ Assertions.assertTrue(Hll.getLongTailZeroNum(1L << 62) == 62);
}
@Test
@@ -42,8 +42,8 @@ public void hllBasicTest() throws IOException {
// test empty
Hll emptyHll = new Hll();
- Assert.assertTrue(emptyHll.getType() == Hll.HLL_DATA_EMPTY);
- Assert.assertTrue(emptyHll.estimateCardinality() == 0);
+ Assertions.assertTrue(emptyHll.getType() == Hll.HLL_DATA_EMPTY);
+ Assertions.assertTrue(emptyHll.estimateCardinality() == 0);
ByteArrayOutputStream emptyOutputStream = new ByteArrayOutputStream();
DataOutput output = new DataOutputStream(emptyOutputStream);
@@ -51,15 +51,15 @@ public void hllBasicTest() throws IOException {
DataInputStream emptyInputStream = new DataInputStream(new ByteArrayInputStream(emptyOutputStream.toByteArray()));
Hll deserializedEmptyHll = new Hll();
deserializedEmptyHll.deserialize(emptyInputStream);
- Assert.assertTrue(deserializedEmptyHll.getType() == Hll.HLL_DATA_EMPTY);
+ Assertions.assertTrue(deserializedEmptyHll.getType() == Hll.HLL_DATA_EMPTY);
// test explicit
Hll explicitHll = new Hll();
for (int i = 0; i < Hll.HLL_EXPLICIT_INT64_NUM; i++) {
explicitHll.updateWithHash(i);
}
- Assert.assertTrue(explicitHll.getType() == Hll.HLL_DATA_EXPLICIT);
- Assert.assertTrue(explicitHll.estimateCardinality() == Hll.HLL_EXPLICIT_INT64_NUM);
+ Assertions.assertTrue(explicitHll.getType() == Hll.HLL_DATA_EXPLICIT);
+ Assertions.assertTrue(explicitHll.estimateCardinality() == Hll.HLL_EXPLICIT_INT64_NUM);
ByteArrayOutputStream explicitOutputStream = new ByteArrayOutputStream();
DataOutput explicitOutput = new DataOutputStream(explicitOutputStream);
@@ -67,16 +67,16 @@ public void hllBasicTest() throws IOException {
DataInputStream explicitInputStream = new DataInputStream(new ByteArrayInputStream(explicitOutputStream.toByteArray()));
Hll deserializedExplicitHll = new Hll();
deserializedExplicitHll.deserialize(explicitInputStream);
- Assert.assertTrue(deserializedExplicitHll.getType() == Hll.HLL_DATA_EXPLICIT);
+ Assertions.assertTrue(deserializedExplicitHll.getType() == Hll.HLL_DATA_EXPLICIT);
// test sparse
Hll sparseHll = new Hll();
for (int i = 0; i < Hll.HLL_SPARSE_THRESHOLD; i++) {
sparseHll.updateWithHash(i);
}
- Assert.assertTrue(sparseHll.getType() == Hll.HLL_DATA_FULL);
+ Assertions.assertTrue(sparseHll.getType() == Hll.HLL_DATA_FULL);
// 2% error rate
- Assert.assertTrue(sparseHll.estimateCardinality() > Hll.HLL_SPARSE_THRESHOLD * (1 - 0.02)
+ Assertions.assertTrue(sparseHll.estimateCardinality() > Hll.HLL_SPARSE_THRESHOLD * (1 - 0.02)
&& sparseHll.estimateCardinality() < Hll.HLL_SPARSE_THRESHOLD * (1 + 0.02));
ByteArrayOutputStream sparseOutputStream = new ByteArrayOutputStream();
@@ -85,8 +85,8 @@ public void hllBasicTest() throws IOException {
DataInputStream sparseInputStream = new DataInputStream(new ByteArrayInputStream(sparseOutputStream.toByteArray()));
Hll deserializedSparseHll = new Hll();
deserializedSparseHll.deserialize(sparseInputStream);
- Assert.assertTrue(deserializedSparseHll.getType() == Hll.HLL_DATA_SPARSE);
- Assert.assertTrue(sparseHll.estimateCardinality() == deserializedSparseHll.estimateCardinality());
+ Assertions.assertTrue(deserializedSparseHll.getType() == Hll.HLL_DATA_SPARSE);
+ Assertions.assertTrue(sparseHll.estimateCardinality() == deserializedSparseHll.estimateCardinality());
// test full
@@ -94,10 +94,10 @@ public void hllBasicTest() throws IOException {
for (int i = 1; i <= Short.MAX_VALUE; i++) {
fullHll.updateWithHash(i);
}
- Assert.assertTrue(fullHll.getType() == Hll.HLL_DATA_FULL);
+ Assertions.assertTrue(fullHll.getType() == Hll.HLL_DATA_FULL);
// the result 32748 is consistent with C++ 's implementation
- Assert.assertTrue(fullHll.estimateCardinality() == 32748);
- Assert.assertTrue(fullHll.estimateCardinality() > Short.MAX_VALUE * (1 - 0.02)
+ Assertions.assertTrue(fullHll.estimateCardinality() == 32748);
+ Assertions.assertTrue(fullHll.estimateCardinality() > Short.MAX_VALUE * (1 - 0.02)
&& fullHll.estimateCardinality() < Short.MAX_VALUE * (1 + 0.02));
ByteArrayOutputStream fullHllOutputStream = new ByteArrayOutputStream();
@@ -106,8 +106,8 @@ public void hllBasicTest() throws IOException {
DataInputStream fullHllInputStream = new DataInputStream(new ByteArrayInputStream(fullHllOutputStream.toByteArray()));
Hll deserializedFullHll = new Hll();
deserializedFullHll.deserialize(fullHllInputStream);
- Assert.assertTrue(deserializedFullHll.getType() == Hll.HLL_DATA_FULL);
- Assert.assertTrue(deserializedFullHll.estimateCardinality() == fullHll.estimateCardinality());
+ Assertions.assertTrue(deserializedFullHll.getType() == Hll.HLL_DATA_FULL);
+ Assertions.assertTrue(deserializedFullHll.estimateCardinality() == fullHll.estimateCardinality());
}
@@ -122,7 +122,7 @@ public void testCompareEstimateValueWithBe() throws IOException {
byte[] serializedByte = serializeHll(hll);
hll = deserializeHll(serializedByte);
- Assert.assertTrue(estimateValue == hll.estimateCardinality());
+ Assertions.assertTrue(estimateValue == hll.estimateCardinality());
} // CHECKSTYLE IGNORE THIS LINE
// explicit [0. 100)
@@ -131,11 +131,11 @@ public void testCompareEstimateValueWithBe() throws IOException {
for (int i = 0; i < 100; i++) {
explicitHll.updateWithHash(i);
}
- Assert.assertTrue(explicitHll.estimateCardinality() == 100);
+ Assertions.assertTrue(explicitHll.estimateCardinality() == 100);
// check serialize
byte[] serializeHll = serializeHll(explicitHll);
explicitHll = deserializeHll(serializeHll);
- Assert.assertTrue(explicitHll.estimateCardinality() == 100);
+ Assertions.assertTrue(explicitHll.estimateCardinality() == 100);
Hll otherHll = new Hll();
for (int i = 0; i < 100; i++) {
@@ -143,7 +143,7 @@ public void testCompareEstimateValueWithBe() throws IOException {
}
explicitHll.merge(otherHll);
// compare with C++ version result
- Assert.assertTrue(explicitHll.estimateCardinality() == 100);
+ Assertions.assertTrue(explicitHll.estimateCardinality() == 100);
} // CHECKSTYLE IGNORE THIS LINE
// sparse [1024, 2048)
@@ -156,11 +156,11 @@ public void testCompareEstimateValueWithBe() throws IOException {
long preValue = sparseHll.estimateCardinality();
// check serialize
byte[] serializedHll = serializeHll(sparseHll);
- Assert.assertTrue(serializedHll.length < Hll.HLL_REGISTERS_COUNT + 1);
+ Assertions.assertTrue(serializedHll.length < Hll.HLL_REGISTERS_COUNT + 1);
sparseHll = deserializeHll(serializedHll);
- Assert.assertTrue(sparseHll.estimateCardinality() == preValue);
- Assert.assertTrue(sparseHll.getType() == Hll.HLL_DATA_SPARSE);
+ Assertions.assertTrue(sparseHll.estimateCardinality() == preValue);
+ Assertions.assertTrue(sparseHll.getType() == Hll.HLL_DATA_SPARSE);
Hll otherHll = new Hll();
for (int i = 0; i < 1024; i++) {
@@ -169,11 +169,11 @@ public void testCompareEstimateValueWithBe() throws IOException {
sparseHll.updateWithHash(1024);
sparseHll.merge(otherHll);
long cardinality = sparseHll.estimateCardinality();
- Assert.assertTrue(preValue == cardinality);
+ Assertions.assertTrue(preValue == cardinality);
// 2% error rate
- Assert.assertTrue(cardinality > 1000 && cardinality < 1045);
+ Assertions.assertTrue(cardinality > 1000 && cardinality < 1045);
// compare with C++ version result
- Assert.assertTrue(cardinality == 1023);
+ Assertions.assertTrue(cardinality == 1023);
} // CHECKSTYLE IGNORE THIS LINE
// full [64 * 1024, 128 * 1024)
@@ -187,21 +187,21 @@ public void testCompareEstimateValueWithBe() throws IOException {
// check serialize
byte[] serializedHll = serializeHll(fullHll);
fullHll = deserializeHll(serializedHll);
- Assert.assertTrue(fullHll.estimateCardinality() == preValue);
- Assert.assertTrue(serializedHll.length == Hll.HLL_REGISTERS_COUNT + 1);
+ Assertions.assertTrue(fullHll.estimateCardinality() == preValue);
+ Assertions.assertTrue(serializedHll.length == Hll.HLL_REGISTERS_COUNT + 1);
// 2% error rate
- Assert.assertTrue(preValue > 62 * 1024 && preValue < 66 * 1024);
+ Assertions.assertTrue(preValue > 62 * 1024 && preValue < 66 * 1024);
// compare with C++ version result
- Assert.assertTrue(preValue == 66112);
+ Assertions.assertTrue(preValue == 66112);
} // CHECKSTYLE IGNORE THIS LINE
// merge explicit to empty_hll
{ // CHECKSTYLE IGNORE THIS LINE
Hll newExplicit = new Hll();
newExplicit.merge(explicitHll);
- Assert.assertTrue(newExplicit.estimateCardinality() == 100);
+ Assertions.assertTrue(newExplicit.estimateCardinality() == 100);
// merge another explicit
{ // CHECKSTYLE IGNORE THIS LINE
@@ -211,16 +211,16 @@ public void testCompareEstimateValueWithBe() throws IOException {
}
// this is converted to full
otherHll.merge(newExplicit);
- Assert.assertTrue(otherHll.estimateCardinality() > 190);
+ Assertions.assertTrue(otherHll.estimateCardinality() > 190);
// compare with C++ version result
- Assert.assertTrue(otherHll.estimateCardinality() == 201);
+ Assertions.assertTrue(otherHll.estimateCardinality() == 201);
} // CHECKSTYLE IGNORE THIS LINE
// merge full
{ // CHECKSTYLE IGNORE THIS LINE
newExplicit.merge(fullHll);
- Assert.assertTrue(newExplicit.estimateCardinality() > fullHll.estimateCardinality());
+ Assertions.assertTrue(newExplicit.estimateCardinality() > fullHll.estimateCardinality());
// compare with C++ version result
- Assert.assertTrue(newExplicit.estimateCardinality() == 66250);
+ Assertions.assertTrue(newExplicit.estimateCardinality() == 66250);
} // CHECKSTYLE IGNORE THIS LINE
} // CHECKSTYLE IGNORE THIS LINE
@@ -228,21 +228,21 @@ public void testCompareEstimateValueWithBe() throws IOException {
{ // CHECKSTYLE IGNORE THIS LINE
Hll newSparseHll = new Hll();
newSparseHll.merge(sparseHll);
- Assert.assertTrue(sparseHll.estimateCardinality() == newSparseHll.estimateCardinality());
+ Assertions.assertTrue(sparseHll.estimateCardinality() == newSparseHll.estimateCardinality());
// compare with C++ version result
- Assert.assertTrue(newSparseHll.estimateCardinality() == 1023);
+ Assertions.assertTrue(newSparseHll.estimateCardinality() == 1023);
// merge explicit
newSparseHll.merge(explicitHll);
- Assert.assertTrue(newSparseHll.estimateCardinality() > sparseHll.estimateCardinality());
+ Assertions.assertTrue(newSparseHll.estimateCardinality() > sparseHll.estimateCardinality());
// compare with C++ version result
- Assert.assertTrue(newSparseHll.estimateCardinality() == 1123);
+ Assertions.assertTrue(newSparseHll.estimateCardinality() == 1123);
// merge full
newSparseHll.merge(fullHll);
- Assert.assertTrue(newSparseHll.estimateCardinality() > fullHll.estimateCardinality());
+ Assertions.assertTrue(newSparseHll.estimateCardinality() > fullHll.estimateCardinality());
// compare with C++ version result
- Assert.assertTrue(newSparseHll.estimateCardinality() == 67316);
+ Assertions.assertTrue(newSparseHll.estimateCardinality() == 67316);
} // CHECKSTYLE IGNORE THIS LINE
}
diff --git a/fe/fe-core/kafka_datasource_properties b/fe/fe-core/kafka_datasource_properties
new file mode 100644
index 00000000000000..2d32fb8bf39c02
Binary files /dev/null and b/fe/fe-core/kafka_datasource_properties differ
diff --git a/fe/fe-core/src/test/java/org/apache/doris/alter/AlterJobV2RetryTest.java b/fe/fe-core/src/test/java/org/apache/doris/alter/AlterJobV2RetryTest.java
index b4263adaecc83e..caf04eddb495d6 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/alter/AlterJobV2RetryTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/alter/AlterJobV2RetryTest.java
@@ -21,9 +21,9 @@
import org.apache.doris.task.AgentTask;
import org.apache.doris.thrift.TStatusCode;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
/**
@@ -34,7 +34,7 @@ public class AlterJobV2RetryTest {
private SchemaChangeJobV2 job;
- @Before
+ @BeforeEach
public void setUp() {
Config.enable_schema_change_retry = true;
Config.schema_change_max_retry_time = 3;
@@ -51,38 +51,38 @@ private AgentTask makeTask(TStatusCode errorCode) {
@Test
public void testScCompactionConflictIsRetryable() {
AgentTask task = makeTask(TStatusCode.SC_COMPACTION_CONFLICT);
- Assert.assertEquals(Config.schema_change_max_retry_time, job.getRetryTimes(task));
+ Assertions.assertEquals(Config.schema_change_max_retry_time, job.getRetryTimes(task));
}
@Test
public void testDeleteBitmapLockErrorIsRetryable() {
AgentTask task = makeTask(TStatusCode.DELETE_BITMAP_LOCK_ERROR);
- Assert.assertEquals(Config.schema_change_max_retry_time, job.getRetryTimes(task));
+ Assertions.assertEquals(Config.schema_change_max_retry_time, job.getRetryTimes(task));
}
@Test
public void testNetworkErrorIsRetryable() {
AgentTask task = makeTask(TStatusCode.NETWORK_ERROR);
- Assert.assertEquals(Config.schema_change_max_retry_time, job.getRetryTimes(task));
+ Assertions.assertEquals(Config.schema_change_max_retry_time, job.getRetryTimes(task));
}
@Test
public void testInternalErrorIsNotRetryable() {
AgentTask task = makeTask(TStatusCode.INTERNAL_ERROR);
- Assert.assertEquals(0, job.getRetryTimes(task));
+ Assertions.assertEquals(0, job.getRetryTimes(task));
}
@Test
public void testAnalysisErrorIsNotRetryable() {
AgentTask task = makeTask(TStatusCode.ANALYSIS_ERROR);
- Assert.assertEquals(0, job.getRetryTimes(task));
+ Assertions.assertEquals(0, job.getRetryTimes(task));
}
@Test
public void testNullErrorCodeIsNotRetryable() {
AgentTask task = Mockito.mock(AgentTask.class);
Mockito.when(task.getErrorCode()).thenReturn(null);
- Assert.assertEquals(0, job.getRetryTimes(task));
+ Assertions.assertEquals(0, job.getRetryTimes(task));
}
@Test
@@ -90,10 +90,10 @@ public void testRetryDisabledReturnsZero() {
Config.enable_schema_change_retry = false;
try {
AgentTask task = makeTask(TStatusCode.SC_COMPACTION_CONFLICT);
- Assert.assertEquals(0, job.getRetryTimes(task));
+ Assertions.assertEquals(0, job.getRetryTimes(task));
task = makeTask(TStatusCode.DELETE_BITMAP_LOCK_ERROR);
- Assert.assertEquals(0, job.getRetryTimes(task));
+ Assertions.assertEquals(0, job.getRetryTimes(task));
} finally {
Config.enable_schema_change_retry = true;
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/alter/CloudIndexTest.java b/fe/fe-core/src/test/java/org/apache/doris/alter/CloudIndexTest.java
index a8576b3e652cfb..029b3c1f1162dc 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/alter/CloudIndexTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/alter/CloudIndexTest.java
@@ -73,10 +73,10 @@
import com.google.common.collect.Maps;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
@@ -113,7 +113,7 @@ private static void setField(Object target, Class> clazz, String fieldName, Ob
field.set(target, value);
}
- @After
+ @AfterEach
public void tearDown() {
if (mockedMetaServiceProxy != null) {
mockedMetaServiceProxy.close();
@@ -126,7 +126,7 @@ public void tearDown() {
}
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
FeConstants.runningUnitTest = true;
// Setup for MetaServiceProxy mock
@@ -253,8 +253,8 @@ public void setUp() throws Exception {
ctx.setCurrentUserIdentity(rootUser);
ctx.setThreadLocalInfo();
ctx.setCloudCluster("test_group");
- Assert.assertTrue(envFactory instanceof CloudEnvFactory);
- Assert.assertTrue(masterEnv instanceof CloudEnv);
+ Assertions.assertTrue(envFactory instanceof CloudEnvFactory);
+ Assertions.assertTrue(masterEnv instanceof CloudEnv);
// Replace MockUp with direct field injection on masterEnv
setField(masterEnv, Env.class, "selfNode",
@@ -292,7 +292,7 @@ public boolean checkCloudPriv(UserIdentity user, String cluster, PrivPredicate w
// MockUp removed: checkCloudClusterPriv not called in test paths
// MockUp removed: ctx already has correct values via setters
- Assert.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
+ Assertions.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
// Replace MockUp with spy
CloudSystemInfoService sysInfo = (CloudSystemInfoService) Env.getCurrentSystemInfo();
CloudSystemInfoService sysInfoSpy = Mockito.spy(sysInfo);
@@ -324,8 +324,8 @@ public boolean checkCloudPriv(UserIdentity user, String cluster, PrivPredicate w
sysInfoSpy.addCloudCluster("test_group", "");
List backends =
((CloudSystemInfoService) Env.getCurrentSystemInfo()).getBackendsByClusterName("test_group");
- Assert.assertEquals(1, backends.size());
- Assert.assertEquals("host1", backends.get(0).getHost());
+ Assertions.assertEquals(1, backends.size());
+ Assertions.assertEquals("host1", backends.get(0).getHost());
backends.get(0).setAlive(true);
ctx.setComputeGroup(masterEnv.getComputeGroupMgr().getAllBackendComputeGroup());
@@ -338,7 +338,7 @@ public boolean checkCloudPriv(UserIdentity user, String cluster, PrivPredicate w
@Test
public void testCreateNgramBfIndex() throws Exception {
- Assert.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
+ Assertions.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
SystemInfoService cloudSystemInfo = Env.getCurrentSystemInfo();
if (fakeEnv != null) {
@@ -353,8 +353,8 @@ public void testCreateNgramBfIndex() throws Exception {
FakeEnv.setSystemInfo(cloudSystemInfo);
schemaChangeHandler = (SchemaChangeHandler) new Alter().getSchemaChangeHandler();
- Assert.assertTrue(Env.getCurrentInternalCatalog() instanceof CloudInternalCatalog);
- Assert.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
+ Assertions.assertTrue(Env.getCurrentInternalCatalog() instanceof CloudInternalCatalog);
+ Assertions.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
CatalogTestUtil.createDupTable(db);
OlapTable table = (OlapTable) db.getTableOrDdlException(CatalogTestUtil.testTableId2);
DataSortInfo dataSortInfo = new DataSortInfo();
@@ -379,21 +379,21 @@ public void testCreateNgramBfIndex() throws Exception {
ctx.getSessionVariable().setEnableAddIndexForNewData(true);
schemaChangeHandler.process(alterOps, db, table);
Map indexChangeJobMap = schemaChangeHandler.getAlterJobsV2();
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(1, table.getIndexes().size());
- Assert.assertEquals("ngram_bf_index", table.getIndexes().get(0).getIndexName());
- Assert.assertEquals(OlapTableState.NORMAL, table.getState());
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(1, table.getIndexes().size());
+ Assertions.assertEquals("ngram_bf_index", table.getIndexes().get(0).getIndexName());
+ Assertions.assertEquals(OlapTableState.NORMAL, table.getState());
long createJobId = indexChangeJobMap.values().stream().findAny().get().jobId;
// Finish the create index job first
SchemaChangeJobV2 createJobV2 = (SchemaChangeJobV2) indexChangeJobMap.get(createJobId);
- Assert.assertEquals(AlterJobV2.JobState.FINISHED, createJobV2.getJobState());
+ Assertions.assertEquals(AlterJobV2.JobState.FINISHED, createJobV2.getJobState());
}
@Test
public void testAlterBfIndexWithLightweightMode() throws Exception {
- Assert.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
+ Assertions.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
SystemInfoService cloudSystemInfo = Env.getCurrentSystemInfo();
if (fakeEnv != null) {
@@ -424,12 +424,12 @@ public void testAlterBfIndexWithLightweightMode() throws Exception {
addIndexOps.add(createIndexOp);
schemaChangeHandler.process(addIndexOps, db, table);
- Assert.assertEquals(OlapTableState.NORMAL, table.getState());
- Assert.assertEquals(1, schemaChangeHandler.getAlterJobsV2().size());
- Assert.assertEquals(0, schemaChangeHandler.getIndexChangeJobs().size());
- Assert.assertEquals(1, table.getIndexes().size());
- Assert.assertEquals(IndexType.BLOOMFILTER, table.getIndexes().get(0).getIndexType());
- Assert.assertEquals(AlterJobV2.JobState.FINISHED,
+ Assertions.assertEquals(OlapTableState.NORMAL, table.getState());
+ Assertions.assertEquals(1, schemaChangeHandler.getAlterJobsV2().size());
+ Assertions.assertEquals(0, schemaChangeHandler.getIndexChangeJobs().size());
+ Assertions.assertEquals(1, table.getIndexes().size());
+ Assertions.assertEquals(IndexType.BLOOMFILTER, table.getIndexes().get(0).getIndexType());
+ Assertions.assertEquals(AlterJobV2.JobState.FINISHED,
schemaChangeHandler.getAlterJobsV2().values().iterator().next().getJobState());
DropIndexOp dropIndexOp = new DropIndexOp(indexName, false, tableName, false);
@@ -437,10 +437,10 @@ public void testAlterBfIndexWithLightweightMode() throws Exception {
dropIndexOps.add(dropIndexOp);
schemaChangeHandler.process(dropIndexOps, db, table);
- Assert.assertEquals(OlapTableState.NORMAL, table.getState());
- Assert.assertEquals(2, schemaChangeHandler.getAlterJobsV2().size());
- Assert.assertEquals(1, schemaChangeHandler.getIndexChangeJobs().size());
- Assert.assertTrue(table.getIndexes().isEmpty());
+ Assertions.assertEquals(OlapTableState.NORMAL, table.getState());
+ Assertions.assertEquals(2, schemaChangeHandler.getAlterJobsV2().size());
+ Assertions.assertEquals(1, schemaChangeHandler.getIndexChangeJobs().size());
+ Assertions.assertTrue(table.getIndexes().isEmpty());
}
@Test
@@ -460,13 +460,13 @@ public void testBuildBfIndexRejectedInCloud() throws Exception {
schemaChangeHandler.process(Lists.newArrayList(createIndexOp), db, table);
BuildIndexOp buildIndexOp = new BuildIndexOp(tableName, null, null, false);
- AnalysisException exception = Assert.assertThrows(AnalysisException.class, () -> buildIndexOp.validate(ctx));
- Assert.assertTrue(exception.getMessage().contains("BLOOMFILTER index is not needed to build"));
+ AnalysisException exception = Assertions.assertThrows(AnalysisException.class, () -> buildIndexOp.validate(ctx));
+ Assertions.assertTrue(exception.getMessage().contains("BLOOMFILTER index is not needed to build"));
}
@Test
public void testNormalCreateNgramBfIndex() throws Exception {
- Assert.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
+ Assertions.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
SystemInfoService cloudSystemInfo = Env.getCurrentSystemInfo();
if (fakeEnv != null) {
@@ -481,8 +481,8 @@ public void testNormalCreateNgramBfIndex() throws Exception {
FakeEnv.setSystemInfo(cloudSystemInfo);
schemaChangeHandler = (SchemaChangeHandler) new Alter().getSchemaChangeHandler();
- Assert.assertTrue(Env.getCurrentInternalCatalog() instanceof CloudInternalCatalog);
- Assert.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
+ Assertions.assertTrue(Env.getCurrentInternalCatalog() instanceof CloudInternalCatalog);
+ Assertions.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
CatalogTestUtil.createDupTable(db);
OlapTable table = (OlapTable) db.getTableOrDdlException(CatalogTestUtil.testTableId2);
DataSortInfo dataSortInfo = new DataSortInfo();
@@ -509,35 +509,35 @@ public void testNormalCreateNgramBfIndex() throws Exception {
ctx.getSessionVariable().setEnableAddIndexForNewData(false);
schemaChangeHandler.process(alterOps, db, table);
Map indexChangeJobMap = schemaChangeHandler.getAlterJobsV2();
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(OlapTableState.SCHEMA_CHANGE, table.getState());
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(OlapTableState.SCHEMA_CHANGE, table.getState());
long createJobId = indexChangeJobMap.values().stream().findAny().get().jobId;
// Finish the create index job first
SchemaChangeJobV2 createJobV2 = (SchemaChangeJobV2) indexChangeJobMap.get(createJobId);
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.WAITING_TXN, createJobV2.getJobState());
+ Assertions.assertEquals(AlterJobV2.JobState.WAITING_TXN, createJobV2.getJobState());
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.RUNNING, createJobV2.getJobState());
- Assert.assertEquals(1, createJobV2.schemaChangeBatchTask.getTaskNum());
+ Assertions.assertEquals(AlterJobV2.JobState.RUNNING, createJobV2.getJobState());
+ Assertions.assertEquals(1, createJobV2.schemaChangeBatchTask.getTaskNum());
List tasks = AgentTaskQueue.getTask(TTaskType.ALTER);
- Assert.assertEquals(1, tasks.size());
+ Assertions.assertEquals(1, tasks.size());
for (AgentTask agentTask : tasks) {
agentTask.setFinished(true);
}
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.FINISHED, createJobV2.getJobState());
- Assert.assertEquals(OlapTableState.NORMAL, table.getState());
- Assert.assertEquals(1, table.getIndexes().size());
- Assert.assertEquals("ngram_bf_index", table.getIndexes().get(0).getIndexName());
+ Assertions.assertEquals(AlterJobV2.JobState.FINISHED, createJobV2.getJobState());
+ Assertions.assertEquals(OlapTableState.NORMAL, table.getState());
+ Assertions.assertEquals(1, table.getIndexes().size());
+ Assertions.assertEquals("ngram_bf_index", table.getIndexes().get(0).getIndexName());
}
@Test
public void testCreateInvertedIndex() throws Exception {
- Assert.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
+ Assertions.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
SystemInfoService cloudSystemInfo = Env.getCurrentSystemInfo();
if (fakeEnv != null) {
@@ -552,8 +552,8 @@ public void testCreateInvertedIndex() throws Exception {
FakeEnv.setSystemInfo(cloudSystemInfo);
schemaChangeHandler = (SchemaChangeHandler) new Alter().getSchemaChangeHandler();
- Assert.assertTrue(Env.getCurrentInternalCatalog() instanceof CloudInternalCatalog);
- Assert.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
+ Assertions.assertTrue(Env.getCurrentInternalCatalog() instanceof CloudInternalCatalog);
+ Assertions.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
CatalogTestUtil.createDupTable(db);
OlapTable table = (OlapTable) db.getTableOrDdlException(CatalogTestUtil.testTableId2);
DataSortInfo dataSortInfo = new DataSortInfo();
@@ -576,36 +576,36 @@ public void testCreateInvertedIndex() throws Exception {
ctx.getSessionVariable().setEnableAddIndexForNewData(false);
schemaChangeHandler.process(alterOps, db, table);
Map indexChangeJobMap = schemaChangeHandler.getAlterJobsV2();
- Assert.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(1, indexChangeJobMap.size());
long createJobId = indexChangeJobMap.values().stream().findAny().get().jobId;
- Assert.assertEquals(OlapTableState.SCHEMA_CHANGE, table.getState());
+ Assertions.assertEquals(OlapTableState.SCHEMA_CHANGE, table.getState());
// Finish the create index job first
SchemaChangeJobV2 createJobV2 = (SchemaChangeJobV2) indexChangeJobMap.get(createJobId);
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.WAITING_TXN, createJobV2.getJobState());
+ Assertions.assertEquals(AlterJobV2.JobState.WAITING_TXN, createJobV2.getJobState());
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.RUNNING, createJobV2.getJobState());
- Assert.assertEquals(1, createJobV2.schemaChangeBatchTask.getTaskNum());
+ Assertions.assertEquals(AlterJobV2.JobState.RUNNING, createJobV2.getJobState());
+ Assertions.assertEquals(1, createJobV2.schemaChangeBatchTask.getTaskNum());
List tasks = AgentTaskQueue.getTask(TTaskType.ALTER);
- Assert.assertEquals(1, tasks.size());
+ Assertions.assertEquals(1, tasks.size());
for (AgentTask agentTask : tasks) {
agentTask.setFinished(true);
}
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.FINISHED, createJobV2.getJobState());
- Assert.assertEquals(OlapTableState.NORMAL, table.getState());
- Assert.assertEquals(1, table.getIndexes().size());
- Assert.assertEquals("raw_inverted_index", table.getIndexes().get(0).getIndexName());
+ Assertions.assertEquals(AlterJobV2.JobState.FINISHED, createJobV2.getJobState());
+ Assertions.assertEquals(OlapTableState.NORMAL, table.getState());
+ Assertions.assertEquals(1, table.getIndexes().size());
+ Assertions.assertEquals("raw_inverted_index", table.getIndexes().get(0).getIndexName());
}
@Test
public void testCreateInvertedIndexWithLightweightMode() throws Exception {
- Assert.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
+ Assertions.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
SystemInfoService cloudSystemInfo = Env.getCurrentSystemInfo();
if (fakeEnv != null) {
@@ -620,8 +620,8 @@ public void testCreateInvertedIndexWithLightweightMode() throws Exception {
FakeEnv.setSystemInfo(cloudSystemInfo);
schemaChangeHandler = (SchemaChangeHandler) new Alter().getSchemaChangeHandler();
- Assert.assertTrue(Env.getCurrentInternalCatalog() instanceof CloudInternalCatalog);
- Assert.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
+ Assertions.assertTrue(Env.getCurrentInternalCatalog() instanceof CloudInternalCatalog);
+ Assertions.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
CatalogTestUtil.createDupTable(db);
OlapTable table = (OlapTable) db.getTableOrDdlException(CatalogTestUtil.testTableId2);
DataSortInfo dataSortInfo = new DataSortInfo();
@@ -646,17 +646,17 @@ public void testCreateInvertedIndexWithLightweightMode() throws Exception {
schemaChangeHandler.process(alterOps, db, table);
Map indexChangeJobMap = schemaChangeHandler.getAlterJobsV2();
// Lightweight mode should not create any schema change jobs
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(1, table.getIndexes().size());
- Assert.assertEquals("lightweight_raw_inverted_index", table.getIndexes().get(0).getIndexName());
- Assert.assertEquals(OlapTableState.NORMAL, table.getState());
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(1, table.getIndexes().size());
+ Assertions.assertEquals("lightweight_raw_inverted_index", table.getIndexes().get(0).getIndexName());
+ Assertions.assertEquals(OlapTableState.NORMAL, table.getState());
// Verify the index properties
- Assert.assertEquals("none", table.getIndexes().get(0).getProperties().get("parser"));
+ Assertions.assertEquals("none", table.getIndexes().get(0).getProperties().get("parser"));
}
@Test
public void testCreateTokenizedInvertedIndex() throws Exception {
- Assert.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
+ Assertions.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
SystemInfoService cloudSystemInfo = Env.getCurrentSystemInfo();
if (fakeEnv != null) {
@@ -671,8 +671,8 @@ public void testCreateTokenizedInvertedIndex() throws Exception {
FakeEnv.setSystemInfo(cloudSystemInfo);
schemaChangeHandler = (SchemaChangeHandler) new Alter().getSchemaChangeHandler();
- Assert.assertTrue(Env.getCurrentInternalCatalog() instanceof CloudInternalCatalog);
- Assert.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
+ Assertions.assertTrue(Env.getCurrentInternalCatalog() instanceof CloudInternalCatalog);
+ Assertions.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
CatalogTestUtil.createDupTable(db);
OlapTable table = (OlapTable) db.getTableOrDdlException(CatalogTestUtil.testTableId2);
DataSortInfo dataSortInfo = new DataSortInfo();
@@ -701,44 +701,44 @@ public void testCreateTokenizedInvertedIndex() throws Exception {
alterOps.add(createIndexOp);
schemaChangeHandler.process(alterOps, db, table);
Map indexChangeJobMap = schemaChangeHandler.getAlterJobsV2();
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(OlapTableState.SCHEMA_CHANGE, table.getState());
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(OlapTableState.SCHEMA_CHANGE, table.getState());
SchemaChangeJobV2 jobV2 = (SchemaChangeJobV2) indexChangeJobMap.values().stream()
.findFirst()
.orElse(null);
- Assert.assertEquals(0, jobV2.schemaChangeBatchTask.getTaskNum());
+ Assertions.assertEquals(0, jobV2.schemaChangeBatchTask.getTaskNum());
// This should be a heavyweight schema change for tokenized index
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.WAITING_TXN, jobV2.getJobState());
- Assert.assertEquals(0, jobV2.schemaChangeBatchTask.getTaskNum());
+ Assertions.assertEquals(AlterJobV2.JobState.WAITING_TXN, jobV2.getJobState());
+ Assertions.assertEquals(0, jobV2.schemaChangeBatchTask.getTaskNum());
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.RUNNING, jobV2.getJobState());
- Assert.assertEquals(1, jobV2.schemaChangeBatchTask.getTaskNum());
+ Assertions.assertEquals(AlterJobV2.JobState.RUNNING, jobV2.getJobState());
+ Assertions.assertEquals(1, jobV2.schemaChangeBatchTask.getTaskNum());
List tasks = AgentTaskQueue.getTask(TTaskType.ALTER);
- Assert.assertEquals(1, tasks.size());
+ Assertions.assertEquals(1, tasks.size());
for (AgentTask agentTask : tasks) {
agentTask.setFinished(true);
}
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.FINISHED, jobV2.getJobState());
+ Assertions.assertEquals(AlterJobV2.JobState.FINISHED, jobV2.getJobState());
- Assert.assertEquals(1, table.getIndexes().size());
- Assert.assertEquals("tokenized_inverted_index", table.getIndexes().get(0).getIndexName());
+ Assertions.assertEquals(1, table.getIndexes().size());
+ Assertions.assertEquals("tokenized_inverted_index", table.getIndexes().get(0).getIndexName());
// Verify that the index has the correct properties
- Assert.assertEquals("english", table.getIndexes().get(0).getProperties().get("parser"));
- Assert.assertEquals("true", table.getIndexes().get(0).getProperties().get("support_phrase"));
- Assert.assertEquals("true", table.getIndexes().get(0).getProperties().get("lower_case"));
+ Assertions.assertEquals("english", table.getIndexes().get(0).getProperties().get("parser"));
+ Assertions.assertEquals("true", table.getIndexes().get(0).getProperties().get("support_phrase"));
+ Assertions.assertEquals("true", table.getIndexes().get(0).getProperties().get("lower_case"));
}
@Test
public void testSchemaChangeWaitsWhenConflictTxnAbortFails() throws Exception {
- Assert.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
+ Assertions.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
SystemInfoService cloudSystemInfo = Env.getCurrentSystemInfo();
if (fakeEnv != null) {
@@ -753,8 +753,8 @@ public void testSchemaChangeWaitsWhenConflictTxnAbortFails() throws Exception {
FakeEnv.setSystemInfo(cloudSystemInfo);
schemaChangeHandler = (SchemaChangeHandler) new Alter().getSchemaChangeHandler();
- Assert.assertTrue(Env.getCurrentInternalCatalog() instanceof CloudInternalCatalog);
- Assert.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
+ Assertions.assertTrue(Env.getCurrentInternalCatalog() instanceof CloudInternalCatalog);
+ Assertions.assertTrue(Env.getCurrentSystemInfo() instanceof CloudSystemInfoService);
CatalogTestUtil.createDupTable(db);
OlapTable table = (OlapTable) db.getTableOrDdlException(CatalogTestUtil.testTableId2);
DataSortInfo dataSortInfo = new DataSortInfo();
@@ -778,13 +778,13 @@ public void testSchemaChangeWaitsWhenConflictTxnAbortFails() throws Exception {
alterOps.add(createIndexOp);
schemaChangeHandler.process(alterOps, db, table);
Map indexChangeJobMap = schemaChangeHandler.getAlterJobsV2();
- Assert.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(1, indexChangeJobMap.size());
SchemaChangeJobV2 jobV2 = (SchemaChangeJobV2) indexChangeJobMap.values().stream()
.findFirst()
.orElse(null);
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.WAITING_TXN, jobV2.getJobState());
+ Assertions.assertEquals(AlterJobV2.JobState.WAITING_TXN, jobV2.getJobState());
Mockito.doAnswer(invocation -> {
Cloud.TxnCoordinatorPB coordinator = Cloud.TxnCoordinatorPB.newBuilder()
@@ -814,8 +814,8 @@ public void testSchemaChangeWaitsWhenConflictTxnAbortFails() throws Exception {
.build()).when(mockProxy).getTxn(Mockito.any());
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.WAITING_TXN, jobV2.getJobState());
- Assert.assertEquals(OlapTableState.SCHEMA_CHANGE, table.getState());
+ Assertions.assertEquals(AlterJobV2.JobState.WAITING_TXN, jobV2.getJobState());
+ Assertions.assertEquals(OlapTableState.SCHEMA_CHANGE, table.getState());
}
@Test
@@ -887,7 +887,7 @@ public void testCreateShadowIndexReplicaForPartitionCopiesBfIndexesOnlyForBaseSh
// the original schema-change behavior and does not receive BfIndex metadata or folded
// BfColumns flags from indexes. bfColumns is null so table-level bfFpp is not set;
// BfIndexes carry their own per-index FPP.
- Assert.assertEquals(2, capturedRequests.size());
+ Assertions.assertEquals(2, capturedRequests.size());
Cloud.CreateTabletsRequest baseRequest = capturedRequests.stream()
.filter(request -> request.getTabletMetas(0).getIndexId() == shadowBaseIndexId)
.findFirst()
@@ -897,20 +897,20 @@ public void testCreateShadowIndexReplicaForPartitionCopiesBfIndexesOnlyForBaseSh
.findFirst()
.orElseThrow(() -> new AssertionError("rollup shadow request not found"));
- Assert.assertEquals(1, baseRequest.getTabletMetas(0).getSchema().getIndexCount());
- Assert.assertEquals(0, rollupRequest.getTabletMetas(0).getSchema().getIndexCount());
- Assert.assertFalse(baseRequest.getTabletMetas(0).getSchema().hasBfFpp());
- Assert.assertFalse(rollupRequest.getTabletMetas(0).getSchema().hasBfFpp());
- Assert.assertEquals("k1", baseRequest.getTabletMetas(0).getSchema().getColumn(0).getName());
- Assert.assertEquals("k2", baseRequest.getTabletMetas(0).getSchema().getColumn(1).getName());
- Assert.assertEquals("v1", baseRequest.getTabletMetas(0).getSchema().getColumn(2).getName());
- Assert.assertFalse(baseRequest.getTabletMetas(0).getSchema().getColumn(0).getIsBfColumn());
- Assert.assertFalse(baseRequest.getTabletMetas(0).getSchema().getColumn(1).getIsBfColumn());
- Assert.assertTrue(baseRequest.getTabletMetas(0).getSchema().getColumn(2).getIsBfColumn());
- Assert.assertEquals("k1", rollupRequest.getTabletMetas(0).getSchema().getColumn(0).getName());
- Assert.assertEquals("v1", rollupRequest.getTabletMetas(0).getSchema().getColumn(1).getName());
- Assert.assertFalse(rollupRequest.getTabletMetas(0).getSchema().getColumn(0).getIsBfColumn());
- Assert.assertFalse(rollupRequest.getTabletMetas(0).getSchema().getColumn(1).getIsBfColumn());
+ Assertions.assertEquals(1, baseRequest.getTabletMetas(0).getSchema().getIndexCount());
+ Assertions.assertEquals(0, rollupRequest.getTabletMetas(0).getSchema().getIndexCount());
+ Assertions.assertFalse(baseRequest.getTabletMetas(0).getSchema().hasBfFpp());
+ Assertions.assertFalse(rollupRequest.getTabletMetas(0).getSchema().hasBfFpp());
+ Assertions.assertEquals("k1", baseRequest.getTabletMetas(0).getSchema().getColumn(0).getName());
+ Assertions.assertEquals("k2", baseRequest.getTabletMetas(0).getSchema().getColumn(1).getName());
+ Assertions.assertEquals("v1", baseRequest.getTabletMetas(0).getSchema().getColumn(2).getName());
+ Assertions.assertFalse(baseRequest.getTabletMetas(0).getSchema().getColumn(0).getIsBfColumn());
+ Assertions.assertFalse(baseRequest.getTabletMetas(0).getSchema().getColumn(1).getIsBfColumn());
+ Assertions.assertTrue(baseRequest.getTabletMetas(0).getSchema().getColumn(2).getIsBfColumn());
+ Assertions.assertEquals("k1", rollupRequest.getTabletMetas(0).getSchema().getColumn(0).getName());
+ Assertions.assertEquals("v1", rollupRequest.getTabletMetas(0).getSchema().getColumn(1).getName());
+ Assertions.assertFalse(rollupRequest.getTabletMetas(0).getSchema().getColumn(0).getIsBfColumn());
+ Assertions.assertFalse(rollupRequest.getTabletMetas(0).getSchema().getColumn(1).getIsBfColumn());
}
private MaterializedIndex createCloudIndex(long indexId, long tabletId, long replicaId, long backendId,
diff --git a/fe/fe-core/src/test/java/org/apache/doris/alter/CloudSchemaChangeJobV2Test.java b/fe/fe-core/src/test/java/org/apache/doris/alter/CloudSchemaChangeJobV2Test.java
index 64ebf383bf628c..a37ceb27b40deb 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/alter/CloudSchemaChangeJobV2Test.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/alter/CloudSchemaChangeJobV2Test.java
@@ -17,8 +17,8 @@
package org.apache.doris.alter;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -38,7 +38,7 @@ public void testSchemaChangeJobDoesNotPersistFormatSpecificSchemaVersions() thro
try (DataInputStream input = new DataInputStream(new ByteArrayInputStream(bytes.toByteArray()))) {
CloudSchemaChangeJobV2 restored = (CloudSchemaChangeJobV2) AlterJobV2.read(input);
- Assert.assertEquals(Long.valueOf(100L), restored.getIndexIdMap().get(101L));
+ Assertions.assertEquals(Long.valueOf(100L), restored.getIndexIdMap().get(101L));
}
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/alter/IndexChangeJobTest.java b/fe/fe-core/src/test/java/org/apache/doris/alter/IndexChangeJobTest.java
index 4ad2ff59e8d08c..22b3f16e2e3a2d 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/alter/IndexChangeJobTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/alter/IndexChangeJobTest.java
@@ -55,12 +55,10 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
@@ -84,10 +82,7 @@ public class IndexChangeJobTest {
private static ConnectContext ctx;
private MockedStatic mockedConnectContext;
- @Rule
- public ExpectedException expectedEx = ExpectedException.none();
-
- @Before
+ @BeforeEach
public void setUp()
throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException,
NoSuchMethodException, SecurityException, UserException {
@@ -109,7 +104,7 @@ public void setUp()
AgentTaskQueue.clearAllTasks();
}
- @After
+ @AfterEach
public void tearDown() {
if (mockedConnectContext != null) {
mockedConnectContext.close();
@@ -152,10 +147,10 @@ public void testCreateIndexIndexChange() throws UserException {
alterOps.add(createIndexOp);
schemaChangeHandler.process(alterOps, db, olapTable);
Map indexChangeJobMap = schemaChangeHandler.getIndexChangeJobs();
- Assert.assertEquals(0, indexChangeJobMap.size());
- Assert.assertEquals(OlapTableState.NORMAL, olapTable.getState());
- Assert.assertEquals(olapTable.getIndexes().size(), 1);
- Assert.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
+ Assertions.assertEquals(0, indexChangeJobMap.size());
+ Assertions.assertEquals(OlapTableState.NORMAL, olapTable.getState());
+ Assertions.assertEquals(olapTable.getIndexes().size(), 1);
+ Assertions.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
}
@Test
@@ -185,16 +180,16 @@ public void testBuildIndexIndexChange() throws UserException {
createIndexClause.validate(connectContext);
alterOps.add(createIndexClause);
schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.assertEquals(olapTable.getIndexes().size(), 1);
- Assert.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
+ Assertions.assertEquals(olapTable.getIndexes().size(), 1);
+ Assertions.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
alterOps.clear();
BuildIndexOp buildIndexClause = new BuildIndexOp(tableNameInfo, indexName, null, false);
buildIndexClause.validate(connectContext);
alterOps.add(buildIndexClause);
schemaChangeHandler.process(alterOps, db, olapTable);
Map indexChangeJobMap = schemaChangeHandler.getIndexChangeJobs();
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(OlapTableState.NORMAL, olapTable.getState());
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(OlapTableState.NORMAL, olapTable.getState());
}
// Creates a fresh db holding the dup table (which owns VARCHAR columns) and puts one
@@ -228,7 +223,7 @@ private OlapTable createDupTableWithInvertedIndex(String indexName, String parse
ArrayList alterOps = new ArrayList<>();
alterOps.add(createIndexOp);
Env.getCurrentEnv().getSchemaChangeHandler().process(alterOps, db, olapTable);
- Assert.assertEquals(1, olapTable.getIndexes().size());
+ Assertions.assertEquals(1, olapTable.getIndexes().size());
return olapTable;
}
@@ -245,11 +240,11 @@ public void testBuildIndexAdmittedForSniiNamedIndex() throws UserException {
olapTable.setInvertedIndexFileStorageFormat(TInvertedIndexFileStorageFormat.SNII);
BuildIndexOp buildIndexOp = new BuildIndexOp(tableNameInfo, indexName, null, false);
buildIndexOp.validate(new ConnectContext());
- Assert.assertEquals(indexName, buildIndexOp.getIndex().getIndexName());
+ Assertions.assertEquals(indexName, buildIndexOp.getIndex().getIndexName());
ArrayList alterOps = new ArrayList<>();
alterOps.add(buildIndexOp);
schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.assertEquals(1, schemaChangeHandler.getIndexChangeJobs().size());
+ Assertions.assertEquals(1, schemaChangeHandler.getIndexChangeJobs().size());
} finally {
olapTable.setInvertedIndexFileStorageFormat(originalFormat);
}
@@ -270,7 +265,7 @@ public void testBuildIndexAdmittedForSniiParsedIndexInCloudMode() throws UserExc
// Cloud mode takes no index name: it builds every index of the table.
BuildIndexOp buildIndexOp = new BuildIndexOp(tableNameInfo, null, null, false);
buildIndexOp.validate(new ConnectContext());
- Assert.assertEquals(indexName, buildIndexOp.getIndex().getIndexName());
+ Assertions.assertEquals(indexName, buildIndexOp.getIndex().getIndexName());
} finally {
Config.cloud_unique_id = originalCloudUniqueId;
olapTable.setInvertedIndexFileStorageFormat(originalFormat);
@@ -291,9 +286,9 @@ public void testBuildIndexStillRejectedForParsedIndexInCloudModeWithoutSnii() th
Config.cloud_unique_id = "test_cloud_v3_build_index";
BuildIndexOp buildIndexOp = new BuildIndexOp(tableNameInfo, null, null, false);
buildIndexOp.validate(new ConnectContext());
- Assert.fail("a parsed non-SNII inverted index still needs no explicit build in cloud mode");
+ Assertions.fail("a parsed non-SNII inverted index still needs no explicit build in cloud mode");
} catch (AnalysisException e) {
- Assert.assertTrue(e.getMessage().contains("index is not needed to build"));
+ Assertions.assertTrue(e.getMessage().contains("index is not needed to build"));
} finally {
Config.cloud_unique_id = originalCloudUniqueId;
olapTable.setInvertedIndexFileStorageFormat(originalFormat);
@@ -314,9 +309,9 @@ public void testBuildIndexForSniiReachesGenericPartitionValidation() throws User
Lists.newArrayList(CatalogTestUtil.testPartition2));
BuildIndexOp buildIndexOp = new BuildIndexOp(tableNameInfo, indexName, partitionNamesInfo, false);
buildIndexOp.validate(new ConnectContext());
- Assert.fail("partitions on a non-partitioned table must be rejected");
+ Assertions.fail("partitions on a non-partitioned table must be rejected");
} catch (AnalysisException e) {
- Assert.assertTrue(e.getMessage().contains("is not partitioned, cannot build index with partitions"));
+ Assertions.assertTrue(e.getMessage().contains("is not partitioned, cannot build index with partitions"));
} finally {
olapTable.setInvertedIndexFileStorageFormat(originalFormat);
}
@@ -349,17 +344,17 @@ public void testDropIndexIndexChange() throws UserException {
createIndexOp.validate(connectContext);
alterOps.add(createIndexOp);
schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.assertEquals(olapTable.getIndexes().size(), 1);
- Assert.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
+ Assertions.assertEquals(olapTable.getIndexes().size(), 1);
+ Assertions.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
alterOps.clear();
DropIndexOp dropIndexOp = new DropIndexOp(indexName, false, tableName, false);
dropIndexOp.validate(connectContext);
alterOps.add(dropIndexOp);
schemaChangeHandler.process(alterOps, db, olapTable);
Map indexChangeJobMap = schemaChangeHandler.getIndexChangeJobs();
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(OlapTableState.NORMAL, olapTable.getState());
- Assert.assertEquals(olapTable.getIndexes().size(), 0);
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(OlapTableState.NORMAL, olapTable.getState());
+ Assertions.assertEquals(olapTable.getIndexes().size(), 0);
}
@Test
@@ -390,41 +385,41 @@ public void testBuildIndexIndexChangeNormal() throws UserException {
createIndexOp.validate(connectContext);
alterOps.add(createIndexOp);
schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.assertEquals(olapTable.getIndexes().size(), 1);
- Assert.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
+ Assertions.assertEquals(olapTable.getIndexes().size(), 1);
+ Assertions.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
alterOps.clear();
BuildIndexOp buildIndexOp = new BuildIndexOp(tableNameInfo, indexName, null, false);
buildIndexOp.validate(new ConnectContext());
alterOps.add(buildIndexOp);
schemaChangeHandler.process(alterOps, db, olapTable);
Map indexChangeJobMap = schemaChangeHandler.getIndexChangeJobs();
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(OlapTableState.NORMAL, olapTable.getState());
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(OlapTableState.NORMAL, olapTable.getState());
IndexChangeJob indexChangejob = indexChangeJobMap.values().stream().findAny().get();
- Assert.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 0);
+ Assertions.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 0);
- Assert.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
// run waiting txn job
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
- Assert.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 3);
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 3);
// run running job
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
// finish alter tasks
List tasks = AgentTaskQueue.getTask(TTaskType.ALTER_INVERTED_INDEX);
- Assert.assertEquals(3, tasks.size());
+ Assertions.assertEquals(3, tasks.size());
for (AgentTask agentTask : tasks) {
agentTask.setFinished(true);
}
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.FINISHED, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.FINISHED, indexChangejob.getJobState());
}
@Test
@@ -455,41 +450,41 @@ public void testDropIndexIndexChangeNormal() throws UserException {
createIndexOp.validate(connectContext);
alterOps.add(createIndexOp);
schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.assertEquals(olapTable.getIndexes().size(), 1);
- Assert.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
+ Assertions.assertEquals(olapTable.getIndexes().size(), 1);
+ Assertions.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
alterOps.clear();
DropIndexOp dropIndexOp = new DropIndexOp(indexName, false, tableName, false);
dropIndexOp.validate(connectContext);
alterOps.add(dropIndexOp);
schemaChangeHandler.process(alterOps, db, olapTable);
Map indexChangeJobMap = schemaChangeHandler.getIndexChangeJobs();
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(OlapTableState.NORMAL, olapTable.getState());
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(OlapTableState.NORMAL, olapTable.getState());
IndexChangeJob indexChangejob = indexChangeJobMap.values().stream().findAny().get();
- Assert.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 0);
+ Assertions.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 0);
- Assert.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
// run waiting txn job
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
- Assert.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 3);
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 3);
// run running job
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
// finish alter tasks
List tasks = AgentTaskQueue.getTask(TTaskType.ALTER_INVERTED_INDEX);
- Assert.assertEquals(3, tasks.size());
+ Assertions.assertEquals(3, tasks.size());
for (AgentTask agentTask : tasks) {
agentTask.setFinished(true);
}
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.FINISHED, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.FINISHED, indexChangejob.getJobState());
}
@Test
@@ -519,31 +514,31 @@ public void testCancelBuildIndexIndexChangeNormal() throws UserException {
createIndexOp.validate(connectContext);
alterOps.add(createIndexOp);
schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.assertEquals(olapTable.getIndexes().size(), 1);
- Assert.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
+ Assertions.assertEquals(olapTable.getIndexes().size(), 1);
+ Assertions.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
alterOps.clear();
BuildIndexOp buildIndexOp = new BuildIndexOp(tableName, indexName, null, false);
buildIndexOp.validate(connectContext);
alterOps.add(buildIndexOp);
schemaChangeHandler.process(alterOps, db, olapTable);
Map indexChangeJobMap = schemaChangeHandler.getIndexChangeJobs();
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(OlapTableState.NORMAL, olapTable.getState());
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(OlapTableState.NORMAL, olapTable.getState());
IndexChangeJob indexChangejob = indexChangeJobMap.values().stream().findAny().get();
- Assert.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 0);
+ Assertions.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 0);
- Assert.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
// run waiting txn job
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
- Assert.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 3);
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 3);
// run running job
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
}
@Test
@@ -573,64 +568,66 @@ public void testBuildIndexIndexChangeWhileTableNotStable() throws Exception {
createIndexOp.validate(connectContext);
alterOps.add(createIndexOp);
olapTable.setState(OlapTableState.SCHEMA_CHANGE);
- expectedEx.expect(DdlException.class);
- expectedEx.expectMessage("errCode = 2, detailMessage = Table[testTable1]'s state(SCHEMA_CHANGE) is not NORMAL. Do not allow doing ALTER ops");
- schemaChangeHandler.process(alterOps, db, olapTable);
-
- olapTable.setState(OlapTableState.NORMAL);
- schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.assertEquals(olapTable.getIndexes().size(), 1);
- Assert.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
- alterOps.clear();
- BuildIndexOp buildIndexOp = new BuildIndexOp(tableName, indexName, null, false);
- buildIndexOp.validate(connectContext);
- alterOps.add(buildIndexOp);
- schemaChangeHandler.process(alterOps, db, olapTable);
- Map indexChangeJobMap = schemaChangeHandler.getIndexChangeJobs();
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(OlapTableState.NORMAL, olapTable.getState());
-
- IndexChangeJob indexChangejob = indexChangeJobMap.values().stream().findAny().get();
- Assert.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 0);
-
- Partition testPartition = olapTable.getPartition(CatalogTestUtil.testPartitionId1);
- MaterializedIndex baseIndex = testPartition.getBaseIndex();
- Assert.assertEquals(IndexState.NORMAL, baseIndex.getState());
- Assert.assertEquals(PartitionState.NORMAL, testPartition.getState());
- Assert.assertEquals(OlapTableState.NORMAL, olapTable.getState());
-
- Tablet baseTablet = baseIndex.getTablets().get(0);
- List replicas = baseTablet.getReplicas();
- Replica replica2 = replicas.get(1);
+ DdlException e = Assertions.assertThrows(DdlException.class, () -> {
+ schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
- // run waiting txn job, set replica2 to clone
- replica2.setState(Replica.ReplicaState.CLONE);
- schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
+ olapTable.setState(OlapTableState.NORMAL);
+ schemaChangeHandler.process(alterOps, db, olapTable);
+ Assertions.assertEquals(olapTable.getIndexes().size(), 1);
+ Assertions.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
+ alterOps.clear();
+ BuildIndexOp buildIndexOp = new BuildIndexOp(tableName, indexName, null, false);
+ buildIndexOp.validate(connectContext);
+ alterOps.add(buildIndexOp);
+ schemaChangeHandler.process(alterOps, db, olapTable);
+ Map indexChangeJobMap = schemaChangeHandler.getIndexChangeJobs();
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(OlapTableState.NORMAL, olapTable.getState());
+
+ IndexChangeJob indexChangejob = indexChangeJobMap.values().stream().findAny().get();
+ Assertions.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 0);
+
+ Partition testPartition = olapTable.getPartition(CatalogTestUtil.testPartitionId1);
+ MaterializedIndex baseIndex = testPartition.getBaseIndex();
+ Assertions.assertEquals(IndexState.NORMAL, baseIndex.getState());
+ Assertions.assertEquals(PartitionState.NORMAL, testPartition.getState());
+ Assertions.assertEquals(OlapTableState.NORMAL, olapTable.getState());
+
+ Tablet baseTablet = baseIndex.getTablets().get(0);
+ List replicas = baseTablet.getReplicas();
+ Replica replica2 = replicas.get(1);
+
+ Assertions.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
+ // run waiting txn job, set replica2 to clone
+ replica2.setState(Replica.ReplicaState.CLONE);
+ schemaChangeHandler.runAfterCatalogReady();
+ Assertions.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
- // rerun waiting txn job, set replica2 to normal
- replica2.setState(Replica.ReplicaState.NORMAL);
- schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
- Assert.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 3);
+ // rerun waiting txn job, set replica2 to normal
+ replica2.setState(Replica.ReplicaState.NORMAL);
+ schemaChangeHandler.runAfterCatalogReady();
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 3);
- // run running job
- schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ // run running job
+ schemaChangeHandler.runAfterCatalogReady();
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
- schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ schemaChangeHandler.runAfterCatalogReady();
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
- // finish alter tasks
- List tasks = AgentTaskQueue.getTask(TTaskType.ALTER_INVERTED_INDEX);
- Assert.assertEquals(3, tasks.size());
- for (AgentTask agentTask : tasks) {
- agentTask.setFinished(true);
- }
+ // finish alter tasks
+ List tasks = AgentTaskQueue.getTask(TTaskType.ALTER_INVERTED_INDEX);
+ Assertions.assertEquals(3, tasks.size());
+ for (AgentTask agentTask : tasks) {
+ agentTask.setFinished(true);
+ }
- schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.FINISHED, indexChangejob.getJobState());
+ schemaChangeHandler.runAfterCatalogReady();
+ Assertions.assertEquals(IndexChangeJob.JobState.FINISHED, indexChangejob.getJobState());
+ });
+ Assertions.assertTrue(e.getMessage().contains("errCode = 2, detailMessage = Table[testTable1]'s state(SCHEMA_CHANGE) is not NORMAL. Do not allow doing ALTER ops"),
+ "unexpected message: " + e.getMessage());
}
@Test
@@ -660,64 +657,66 @@ public void testDropIndexIndexChangeWhileTableNotStable() throws Exception {
createIndexOp.validate(connectContext);
alterOps.add(createIndexOp);
olapTable.setState(OlapTableState.SCHEMA_CHANGE);
- expectedEx.expect(DdlException.class);
- expectedEx.expectMessage("errCode = 2, detailMessage = Table[testTable1]'s state(SCHEMA_CHANGE) is not NORMAL. Do not allow doing ALTER ops");
- schemaChangeHandler.process(alterOps, db, olapTable);
-
- olapTable.setState(OlapTableState.NORMAL);
- schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.assertEquals(olapTable.getIndexes().size(), 1);
- Assert.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
- alterOps.clear();
- DropIndexOp dropIndexOp = new DropIndexOp(indexName, false, tableName, false);
- dropIndexOp.validate(connectContext);
- alterOps.add(dropIndexOp);
- schemaChangeHandler.process(alterOps, db, olapTable);
- Map indexChangeJobMap = schemaChangeHandler.getIndexChangeJobs();
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(OlapTableState.NORMAL, olapTable.getState());
-
- IndexChangeJob indexChangejob = indexChangeJobMap.values().stream().findAny().get();
- Assert.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 0);
-
- Partition testPartition = olapTable.getPartition(CatalogTestUtil.testPartitionId1);
- MaterializedIndex baseIndex = testPartition.getBaseIndex();
- Assert.assertEquals(IndexState.NORMAL, baseIndex.getState());
- Assert.assertEquals(PartitionState.NORMAL, testPartition.getState());
- Assert.assertEquals(OlapTableState.NORMAL, olapTable.getState());
-
- Tablet baseTablet = baseIndex.getTablets().get(0);
- List replicas = baseTablet.getReplicas();
- Replica replica2 = replicas.get(1);
+ DdlException e = Assertions.assertThrows(DdlException.class, () -> {
+ schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
- // run waiting txn job, set replica2 to clone
- replica2.setState(Replica.ReplicaState.CLONE);
- schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
+ olapTable.setState(OlapTableState.NORMAL);
+ schemaChangeHandler.process(alterOps, db, olapTable);
+ Assertions.assertEquals(olapTable.getIndexes().size(), 1);
+ Assertions.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
+ alterOps.clear();
+ DropIndexOp dropIndexOp = new DropIndexOp(indexName, false, tableName, false);
+ dropIndexOp.validate(connectContext);
+ alterOps.add(dropIndexOp);
+ schemaChangeHandler.process(alterOps, db, olapTable);
+ Map indexChangeJobMap = schemaChangeHandler.getIndexChangeJobs();
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(OlapTableState.NORMAL, olapTable.getState());
+
+ IndexChangeJob indexChangejob = indexChangeJobMap.values().stream().findAny().get();
+ Assertions.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 0);
+
+ Partition testPartition = olapTable.getPartition(CatalogTestUtil.testPartitionId1);
+ MaterializedIndex baseIndex = testPartition.getBaseIndex();
+ Assertions.assertEquals(IndexState.NORMAL, baseIndex.getState());
+ Assertions.assertEquals(PartitionState.NORMAL, testPartition.getState());
+ Assertions.assertEquals(OlapTableState.NORMAL, olapTable.getState());
+
+ Tablet baseTablet = baseIndex.getTablets().get(0);
+ List replicas = baseTablet.getReplicas();
+ Replica replica2 = replicas.get(1);
+
+ Assertions.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
+ // run waiting txn job, set replica2 to clone
+ replica2.setState(Replica.ReplicaState.CLONE);
+ schemaChangeHandler.runAfterCatalogReady();
+ Assertions.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
- // rerun waiting txn job, set replica2 to normal
- replica2.setState(Replica.ReplicaState.NORMAL);
- schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
- Assert.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 3);
+ // rerun waiting txn job, set replica2 to normal
+ replica2.setState(Replica.ReplicaState.NORMAL);
+ schemaChangeHandler.runAfterCatalogReady();
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 3);
- // run running job
- schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ // run running job
+ schemaChangeHandler.runAfterCatalogReady();
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
- schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ schemaChangeHandler.runAfterCatalogReady();
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
- // finish alter tasks
- List tasks = AgentTaskQueue.getTask(TTaskType.ALTER_INVERTED_INDEX);
- Assert.assertEquals(3, tasks.size());
- for (AgentTask agentTask : tasks) {
- agentTask.setFinished(true);
- }
+ // finish alter tasks
+ List tasks = AgentTaskQueue.getTask(TTaskType.ALTER_INVERTED_INDEX);
+ Assertions.assertEquals(3, tasks.size());
+ for (AgentTask agentTask : tasks) {
+ agentTask.setFinished(true);
+ }
- schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.FINISHED, indexChangejob.getJobState());
+ schemaChangeHandler.runAfterCatalogReady();
+ Assertions.assertEquals(IndexChangeJob.JobState.FINISHED, indexChangejob.getJobState());
+ });
+ Assertions.assertTrue(e.getMessage().contains("errCode = 2, detailMessage = Table[testTable1]'s state(SCHEMA_CHANGE) is not NORMAL. Do not allow doing ALTER ops"),
+ "unexpected message: " + e.getMessage());
}
@Test
@@ -747,49 +746,49 @@ public void testBuildIndexFailedWithMinFailedNum() throws Exception {
createIndexOp.validate(connectContext);
alterOps.add(createIndexOp);
schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.assertEquals(olapTable.getIndexes().size(), 1);
- Assert.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
+ Assertions.assertEquals(olapTable.getIndexes().size(), 1);
+ Assertions.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
alterOps.clear();
BuildIndexOp buildIndexOp = new BuildIndexOp(tableName, indexName, null, false);
buildIndexOp.validate(connectContext);
alterOps.add(buildIndexOp);
schemaChangeHandler.process(alterOps, db, olapTable);
Map indexChangeJobMap = schemaChangeHandler.getIndexChangeJobs();
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(OlapTableState.NORMAL, olapTable.getState());
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(OlapTableState.NORMAL, olapTable.getState());
IndexChangeJob indexChangejob = indexChangeJobMap.values().stream().findAny().get();
- Assert.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 0);
+ Assertions.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 0);
- Assert.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
// run waiting txn job
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
- Assert.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 3);
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(indexChangejob.invertedIndexBatchTask.getTaskNum(), 3);
// run running job
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
List tasks = AgentTaskQueue.getTask(TTaskType.ALTER_INVERTED_INDEX);
- Assert.assertEquals(3, tasks.size());
+ Assertions.assertEquals(3, tasks.size());
// if one task failed, the job should be failed
// if task error is not OBTAIN_LOCK_FAILED, the job should be failed after
// MIN_FAILED_NUM = 3 times
AgentTask agentTask = tasks.get(0);
agentTask.setErrorCode(TStatusCode.IO_ERROR);
- Assert.assertEquals(agentTask.getFailedTimes(), 0);
+ Assertions.assertEquals(agentTask.getFailedTimes(), 0);
for (int i = 0; i < IndexChangeJob.MIN_FAILED_NUM; i++) {
agentTask.failed();
schemaChangeHandler.runAfterCatalogReady();
if (i < IndexChangeJob.MIN_FAILED_NUM - 1) {
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
}
}
- Assert.assertEquals(IndexChangeJob.JobState.CANCELLED, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.CANCELLED, indexChangejob.getJobState());
}
@Test
@@ -819,49 +818,49 @@ public void testBuildIndexFailedWithMaxFailedNum() throws Exception {
createIndexOp.validate(connectContext);
alterOps.add(createIndexOp);
schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.assertEquals(olapTable.getIndexes().size(), 1);
- Assert.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
+ Assertions.assertEquals(olapTable.getIndexes().size(), 1);
+ Assertions.assertEquals(olapTable.getIndexes().get(0).getIndexName(), "index1");
alterOps.clear();
BuildIndexOp buildIndexOp = new BuildIndexOp(tableName, indexName, null, false);
buildIndexOp.validate(connectContext);
alterOps.add(buildIndexOp);
schemaChangeHandler.process(alterOps, db, olapTable);
Map indexChangeJobMap = schemaChangeHandler.getIndexChangeJobs();
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(OlapTableState.NORMAL, olapTable.getState());
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(OlapTableState.NORMAL, olapTable.getState());
IndexChangeJob indexChangejob = indexChangeJobMap.values().stream().findAny().get();
- Assert.assertEquals(0, indexChangejob.invertedIndexBatchTask.getTaskNum());
+ Assertions.assertEquals(0, indexChangejob.invertedIndexBatchTask.getTaskNum());
- Assert.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.WAITING_TXN, indexChangejob.getJobState());
// run waiting txn job
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
- Assert.assertEquals(3, indexChangejob.invertedIndexBatchTask.getTaskNum());
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(3, indexChangejob.invertedIndexBatchTask.getTaskNum());
// run running job
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
List tasks = AgentTaskQueue.getTask(TTaskType.ALTER_INVERTED_INDEX);
- Assert.assertEquals(3, tasks.size());
+ Assertions.assertEquals(3, tasks.size());
// if one task failed, the job should be failed
// if task error is OBTAIN_LOCK_FAILED, the job should be failed after
// MAX_FAILED_NUM = 10 times
AgentTask agentTask = tasks.get(0);
agentTask.setErrorCode(TStatusCode.OBTAIN_LOCK_FAILED);
- Assert.assertEquals(agentTask.getFailedTimes(), 0);
+ Assertions.assertEquals(agentTask.getFailedTimes(), 0);
for (int i = 0; i < IndexChangeJob.MAX_FAILED_NUM; i++) {
agentTask.failed();
schemaChangeHandler.runAfterCatalogReady();
if (i < IndexChangeJob.MAX_FAILED_NUM - 1) {
- Assert.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.RUNNING, indexChangejob.getJobState());
}
}
- Assert.assertEquals(IndexChangeJob.JobState.CANCELLED, indexChangejob.getJobState());
+ Assertions.assertEquals(IndexChangeJob.JobState.CANCELLED, indexChangejob.getJobState());
}
@Test
@@ -898,15 +897,15 @@ public void testNgramBfBuildIndex() throws UserException {
context.getSessionVariable().setEnableAddIndexForNewData(true);
schemaChangeHandler.process(alterOps, db, table);
Map indexChangeJobMap = schemaChangeHandler.getAlterJobsV2();
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(1, table.getIndexes().size());
- Assert.assertEquals("ngram_bf_index", table.getIndexes().get(0).getIndexName());
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(1, table.getIndexes().size());
+ Assertions.assertEquals("ngram_bf_index", table.getIndexes().get(0).getIndexName());
SchemaChangeJobV2 jobV2 = (SchemaChangeJobV2) indexChangeJobMap.values().stream()
.findFirst()
.orElse(null);
- Assert.assertEquals(0, jobV2.schemaChangeBatchTask.getTaskNum());
- Assert.assertEquals(AlterJobV2.JobState.FINISHED, jobV2.getJobState());
+ Assertions.assertEquals(0, jobV2.schemaChangeBatchTask.getTaskNum());
+ Assertions.assertEquals(AlterJobV2.JobState.FINISHED, jobV2.getJobState());
// Clean up for next test
table.setIndexes(Lists.newArrayList());
@@ -926,36 +925,36 @@ public void testNgramBfBuildIndex() throws UserException {
alterOps2.add(createIndexOp);
schemaChangeHandler.process(alterOps2, db, table);
indexChangeJobMap = schemaChangeHandler.getAlterJobsV2();
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(OlapTableState.SCHEMA_CHANGE, table.getState());
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(OlapTableState.SCHEMA_CHANGE, table.getState());
jobV2 = (SchemaChangeJobV2) indexChangeJobMap.values().stream()
.findFirst()
.orElse(null);
- Assert.assertEquals(0, jobV2.schemaChangeBatchTask.getTaskNum());
+ Assertions.assertEquals(0, jobV2.schemaChangeBatchTask.getTaskNum());
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.WAITING_TXN, jobV2.getJobState());
- Assert.assertEquals(0, jobV2.schemaChangeBatchTask.getTaskNum());
+ Assertions.assertEquals(AlterJobV2.JobState.WAITING_TXN, jobV2.getJobState());
+ Assertions.assertEquals(0, jobV2.schemaChangeBatchTask.getTaskNum());
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.RUNNING, jobV2.getJobState());
- Assert.assertEquals(1, jobV2.schemaChangeBatchTask.getTaskNum());
+ Assertions.assertEquals(AlterJobV2.JobState.RUNNING, jobV2.getJobState());
+ Assertions.assertEquals(1, jobV2.schemaChangeBatchTask.getTaskNum());
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.RUNNING, jobV2.getJobState());
- Assert.assertEquals(1, jobV2.schemaChangeBatchTask.getTaskNum());
+ Assertions.assertEquals(AlterJobV2.JobState.RUNNING, jobV2.getJobState());
+ Assertions.assertEquals(1, jobV2.schemaChangeBatchTask.getTaskNum());
List tasks = AgentTaskQueue.getTask(TTaskType.ALTER);
- Assert.assertEquals(1, tasks.size());
+ Assertions.assertEquals(1, tasks.size());
for (AgentTask agentTask : tasks) {
agentTask.setFinished(true);
}
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.FINISHED, jobV2.getJobState());
- Assert.assertEquals(1, table.getIndexes().size());
- Assert.assertEquals("ngram_bf_index2", table.getIndexes().get(0).getIndexName());
+ Assertions.assertEquals(AlterJobV2.JobState.FINISHED, jobV2.getJobState());
+ Assertions.assertEquals(1, table.getIndexes().size());
+ Assertions.assertEquals("ngram_bf_index2", table.getIndexes().get(0).getIndexName());
}
@Test
@@ -991,25 +990,25 @@ public void testCancelNgramBfBuildIndex() throws UserException {
ctx.getSessionVariable().setEnableAddIndexForNewData(false);
schemaChangeHandler.process(alterOps, db, table);
Map indexChangeJobMap = schemaChangeHandler.getAlterJobsV2();
- Assert.assertEquals(1, indexChangeJobMap.size());
- Assert.assertEquals(OlapTableState.SCHEMA_CHANGE, table.getState());
+ Assertions.assertEquals(1, indexChangeJobMap.size());
+ Assertions.assertEquals(OlapTableState.SCHEMA_CHANGE, table.getState());
SchemaChangeJobV2 jobV2 = (SchemaChangeJobV2) indexChangeJobMap.values().stream()
.findFirst()
.orElse(null);
- Assert.assertEquals(0, jobV2.schemaChangeBatchTask.getTaskNum());
+ Assertions.assertEquals(0, jobV2.schemaChangeBatchTask.getTaskNum());
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.WAITING_TXN, jobV2.getJobState());
- Assert.assertEquals(0, jobV2.schemaChangeBatchTask.getTaskNum());
+ Assertions.assertEquals(AlterJobV2.JobState.WAITING_TXN, jobV2.getJobState());
+ Assertions.assertEquals(0, jobV2.schemaChangeBatchTask.getTaskNum());
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.RUNNING, jobV2.getJobState());
- Assert.assertEquals(1, jobV2.schemaChangeBatchTask.getTaskNum());
+ Assertions.assertEquals(AlterJobV2.JobState.RUNNING, jobV2.getJobState());
+ Assertions.assertEquals(1, jobV2.schemaChangeBatchTask.getTaskNum());
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.RUNNING, jobV2.getJobState());
- Assert.assertEquals(1, jobV2.schemaChangeBatchTask.getTaskNum());
+ Assertions.assertEquals(AlterJobV2.JobState.RUNNING, jobV2.getJobState());
+ Assertions.assertEquals(1, jobV2.schemaChangeBatchTask.getTaskNum());
TableNameInfo tableNameInfo = new TableNameInfo(db.getName(), table.getName());
CancelAlterTableCommand cancelAlterTableCommand = new CancelAlterTableCommand(
@@ -1019,7 +1018,7 @@ public void testCancelNgramBfBuildIndex() throws UserException {
schemaChangeHandler.cancel(cancelAlterTableCommand);
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(AlterJobV2.JobState.CANCELLED, jobV2.getJobState());
+ Assertions.assertEquals(AlterJobV2.JobState.CANCELLED, jobV2.getJobState());
}
@Test
@@ -1029,9 +1028,9 @@ public void testDropIndexOnPartitionValidateRejectsStarPartition() throws Except
DropIndexOp dropIndexOp = new DropIndexOp("index1", false, null, true, starPartition);
try {
dropIndexOp.validate(new ConnectContext());
- Assert.fail("Should throw AnalysisException for PARTITIONS (*)");
+ Assertions.fail("Should throw AnalysisException for PARTITIONS (*)");
} catch (AnalysisException e) {
- Assert.assertTrue(e.getMessage().contains("PARTITIONS (*) is not supported"));
+ Assertions.assertTrue(e.getMessage().contains("PARTITIONS (*) is not supported"));
}
}
@@ -1042,9 +1041,9 @@ public void testDropIndexOnPartitionValidateRejectsTempPartition() throws Except
DropIndexOp dropIndexOp = new DropIndexOp("index1", false, null, true, tempPartition);
try {
dropIndexOp.validate(new ConnectContext());
- Assert.fail("Should throw AnalysisException for TEMPORARY PARTITION");
+ Assertions.fail("Should throw AnalysisException for TEMPORARY PARTITION");
} catch (AnalysisException e) {
- Assert.assertTrue(e.getMessage().contains("does not support temporary partitions"));
+ Assertions.assertTrue(e.getMessage().contains("does not support temporary partitions"));
}
}
@@ -1055,8 +1054,8 @@ public void testDropIndexOnPartitionValidateAcceptsNormalPartition() throws Exce
DropIndexOp dropIndexOp = new DropIndexOp("index1", false, null, true, normalPartition);
// Should not throw
dropIndexOp.validate(new ConnectContext());
- Assert.assertTrue(dropIndexOp.hasPartitionSpec());
- Assert.assertEquals(2, dropIndexOp.getPartitionNames().size());
+ Assertions.assertTrue(dropIndexOp.hasPartitionSpec());
+ Assertions.assertEquals(2, dropIndexOp.getPartitionNames().size());
}
@Test
@@ -1088,7 +1087,7 @@ public void testDropIndexOnPartitionRejectsNonPartitionedTable() throws UserExce
createIndexOp.validate(connectContext);
alterOps.add(createIndexOp);
schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.assertEquals(1, olapTable.getIndexes().size());
+ Assertions.assertEquals(1, olapTable.getIndexes().size());
alterOps.clear();
// Now try DROP INDEX ON PARTITION on this non-partitioned table
@@ -1098,12 +1097,12 @@ public void testDropIndexOnPartitionRejectsNonPartitionedTable() throws UserExce
alterOps.add(dropIndexOp);
try {
schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.fail("Should throw DdlException for non-partitioned table");
+ Assertions.fail("Should throw DdlException for non-partitioned table");
} catch (DdlException e) {
- Assert.assertTrue(e.getMessage().contains("is not partitioned"));
+ Assertions.assertTrue(e.getMessage().contains("is not partitioned"));
}
// Index definition should still exist
- Assert.assertEquals(1, olapTable.getIndexes().size());
+ Assertions.assertEquals(1, olapTable.getIndexes().size());
}
@Test
@@ -1130,9 +1129,9 @@ public void testDropIndexOnPartitionRejectsNonExistentIndex() throws UserExcepti
alterOps.add(dropIndexOp);
try {
schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.fail("Should throw DdlException for non-existent index");
+ Assertions.fail("Should throw DdlException for non-existent index");
} catch (DdlException e) {
- Assert.assertTrue(e.getMessage().contains("does not exist"));
+ Assertions.assertTrue(e.getMessage().contains("does not exist"));
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/alter/MaterializedViewHandlerTest.java b/fe/fe-core/src/test/java/org/apache/doris/alter/MaterializedViewHandlerTest.java
index a80da7a2547bec..80c13f683bf792 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/alter/MaterializedViewHandlerTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/alter/MaterializedViewHandlerTest.java
@@ -34,9 +34,9 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.util.HashMap;
@@ -55,7 +55,7 @@ public void testDifferentBaseTable() {
try {
Deencapsulation.invoke(materializedViewHandler, "processCreateMaterializedView", createMaterializedViewCommand,
db, olapTable);
- Assert.fail();
+ Assertions.fail();
} catch (Exception e) {
System.out.print(e.getMessage());
}
@@ -74,7 +74,7 @@ public void testNotNormalTable() {
try {
Deencapsulation.invoke(materializedViewHandler, "processCreateMaterializedView", createMaterializedViewCommand,
db, olapTable);
- Assert.fail();
+ Assertions.fail();
} catch (Exception e) {
System.out.print(e.getMessage());
}
@@ -94,7 +94,7 @@ public void testErrorBaseIndexName() {
try {
Deencapsulation.invoke(materializedViewHandler, "processCreateMaterializedView",
createMaterializedViewCommand, db, olapTable);
- Assert.fail();
+ Assertions.fail();
} catch (Exception e) {
System.out.print(e.getMessage());
}
@@ -120,7 +120,7 @@ public void testRollupReplica() {
try {
Deencapsulation.invoke(materializedViewHandler, "processCreateMaterializedView",
createMaterializedViewCommand, db, olapTable);
- Assert.fail();
+ Assertions.fail();
} catch (Exception e) {
System.out.print(e.getMessage());
}
@@ -137,7 +137,7 @@ public void testDuplicateMVName() {
try {
Deencapsulation.invoke(materializedViewHandler, "checkAndPrepareMaterializedView",
createMaterializedViewCommand, olapTable, new HashMap());
- Assert.fail();
+ Assertions.fail();
} catch (Exception e) {
System.out.print(e.getMessage());
}
@@ -154,7 +154,7 @@ public void testInvalidKeysType() {
try {
Deencapsulation.invoke(materializedViewHandler, "checkAndPrepareMaterializedView",
createMaterializedViewCommand, olapTable, new HashMap());
- Assert.fail();
+ Assertions.fail();
} catch (Exception e) {
System.out.print(e.getMessage());
}
@@ -174,7 +174,7 @@ public void testDuplicateTable() {
try {
mvColumnItem = new MVColumnItem(slot);
} catch (AnalysisException e) {
- Assert.fail(e.getMessage());
+ Assertions.fail(e.getMessage());
}
mvColumnItem.setIsKey(true);
mvColumnItem.setAggregationType(null, false);
@@ -191,16 +191,16 @@ public void testDuplicateTable() {
List mvColumns = Deencapsulation.invoke(materializedViewHandler,
"checkAndPrepareMaterializedView",
createMaterializedViewCommand, olapTable, new HashMap());
- Assert.assertEquals(1, mvColumns.size());
+ Assertions.assertEquals(1, mvColumns.size());
Column newMVColumn = mvColumns.get(0);
- Assert.assertEquals(columnName1, newMVColumn.getName());
- Assert.assertTrue(newMVColumn.isKey());
- Assert.assertEquals(null, newMVColumn.getAggregationType());
- Assert.assertEquals(false, newMVColumn.isAggregationTypeImplicit());
- Assert.assertEquals(Type.VARCHAR.getPrimitiveType(), newMVColumn.getType().getPrimitiveType());
+ Assertions.assertEquals(columnName1, newMVColumn.getName());
+ Assertions.assertTrue(newMVColumn.isKey());
+ Assertions.assertEquals(null, newMVColumn.getAggregationType());
+ Assertions.assertEquals(false, newMVColumn.isAggregationTypeImplicit());
+ Assertions.assertEquals(Type.VARCHAR.getPrimitiveType(), newMVColumn.getType().getPrimitiveType());
} catch (Exception e) {
e.printStackTrace();
- Assert.fail(e.getMessage());
+ Assertions.fail(e.getMessage());
}
}
@@ -219,7 +219,7 @@ public void checkInvalidPartitionKeyMV() throws DdlException {
try {
mvColumnItem = new MVColumnItem(slot);
} catch (AnalysisException e) {
- Assert.fail(e.getMessage());
+ Assertions.fail(e.getMessage());
}
mvColumnItem.setIsKey(false);
@@ -236,7 +236,7 @@ public void checkInvalidPartitionKeyMV() throws DdlException {
try {
Deencapsulation.invoke(materializedViewHandler, "checkAndPrepareMaterializedView",
createMaterializedViewCommand, olapTable);
- Assert.fail();
+ Assertions.fail();
} catch (Exception e) {
System.out.print(e.getMessage());
}
@@ -258,7 +258,7 @@ public void testCheckDropMaterializedView() {
try {
Deencapsulation.invoke(materializedViewHandler, "checkDropMaterializedView", mvName, olapTable);
} catch (Exception e) {
- Assert.fail(e.getMessage());
+ Assertions.fail(e.getMessage());
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/alter/RollupJobV2Test.java b/fe/fe-core/src/test/java/org/apache/doris/alter/RollupJobV2Test.java
index 4265e267b7e244..c525ea2d4a48cd 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/alter/RollupJobV2Test.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/alter/RollupJobV2Test.java
@@ -58,10 +58,10 @@
import org.apache.doris.transaction.GlobalTransactionMgrIface;
import com.google.common.collect.Lists;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
@@ -93,7 +93,7 @@ public class RollupJobV2Test {
private FakeEditLog fakeEditLog;
private MockedStatic agentTaskExecutorMock;
- @Before
+ @BeforeEach
public void setUp() throws InstantiationException, IllegalAccessException, IllegalArgumentException,
InvocationTargetException, NoSuchMethodException, SecurityException, UserException {
fakeEnv = new FakeEnv();
@@ -126,7 +126,7 @@ public void setUp() throws InstantiationException, IllegalAccessException, Illeg
.thenAnswer(invocation -> null);
}
- @After
+ @AfterEach
public void tearDown() {
File file = new File(fileName);
file.delete();
@@ -166,9 +166,9 @@ public void testRunRollupJobConcurrentLimit() throws UserException {
materializedViewHandler.runAfterCatalogReady();
- Assert.assertEquals(Config.max_running_rollup_job_num_per_table, materializedViewHandler.getTableRunningJobMap().get(CatalogTestUtil.testTableId1).size());
- Assert.assertEquals(2, alterJobsV2.size());
- Assert.assertEquals(OlapTableState.ROLLUP, olapTable.getState());
+ Assertions.assertEquals(Config.max_running_rollup_job_num_per_table, materializedViewHandler.getTableRunningJobMap().get(CatalogTestUtil.testTableId1).size());
+ Assertions.assertEquals(2, alterJobsV2.size());
+ Assertions.assertEquals(OlapTableState.ROLLUP, olapTable.getState());
}
@Test
@@ -189,8 +189,8 @@ public void testAddSchemaChange() throws UserException {
OlapTable olapTable = (OlapTable) db.getTableOrDdlException(CatalogTestUtil.testTableId1);
materializedViewHandler.process(alterOps, db, olapTable);
Map alterJobsV2 = materializedViewHandler.getAlterJobsV2();
- Assert.assertEquals(1, alterJobsV2.size());
- Assert.assertEquals(OlapTableState.ROLLUP, olapTable.getState());
+ Assertions.assertEquals(1, alterJobsV2.size());
+ Assertions.assertEquals(OlapTableState.ROLLUP, olapTable.getState());
}
@Test
@@ -212,7 +212,7 @@ public void testCancelRollupWithEmptyJobIdList() throws Exception {
OlapTable olapTable = (OlapTable) db.getTableOrDdlException(CatalogTestUtil.testTableId1);
materializedViewHandler.process(alterOps, db, olapTable);
Map alterJobsV2 = materializedViewHandler.getAlterJobsV2();
- Assert.assertEquals(1, alterJobsV2.size());
+ Assertions.assertEquals(1, alterJobsV2.size());
RollupJobV2 rollupJob = (RollupJobV2) alterJobsV2.values().stream().findAny().get();
CancelAlterTableCommand cancelAlterTableCommand = new CancelAlterTableCommand(
@@ -221,7 +221,7 @@ public void testCancelRollupWithEmptyJobIdList() throws Exception {
Lists.newArrayList());
materializedViewHandler.cancel(cancelAlterTableCommand);
- Assert.assertEquals(JobState.CANCELLED, rollupJob.getJobState());
+ Assertions.assertEquals(JobState.CANCELLED, rollupJob.getJobState());
}
// start a schema change, then finished
@@ -246,27 +246,27 @@ public void testSchemaChange1() throws Exception {
Partition testPartition = olapTable.getPartition(CatalogTestUtil.testPartitionId1);
materializedViewHandler.process(alterOps, db, olapTable);
Map alterJobsV2 = materializedViewHandler.getAlterJobsV2();
- Assert.assertEquals(1, alterJobsV2.size());
+ Assertions.assertEquals(1, alterJobsV2.size());
RollupJobV2 rollupJob = (RollupJobV2) alterJobsV2.values().stream().findAny().get();
// runPendingJob
materializedViewHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.WAITING_TXN, rollupJob.getJobState());
- Assert.assertEquals(2, testPartition.getMaterializedIndices(IndexExtState.ALL).size());
- Assert.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.VISIBLE).size());
- Assert.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.SHADOW).size());
+ Assertions.assertEquals(JobState.WAITING_TXN, rollupJob.getJobState());
+ Assertions.assertEquals(2, testPartition.getMaterializedIndices(IndexExtState.ALL).size());
+ Assertions.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.VISIBLE).size());
+ Assertions.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.SHADOW).size());
// runWaitingTxnJob
materializedViewHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.RUNNING, rollupJob.getJobState());
+ Assertions.assertEquals(JobState.RUNNING, rollupJob.getJobState());
// runWaitingTxnJob, task not finished
materializedViewHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.RUNNING, rollupJob.getJobState());
+ Assertions.assertEquals(JobState.RUNNING, rollupJob.getJobState());
// finish all tasks
List tasks = AgentTaskQueue.getTask(TTaskType.ALTER);
- Assert.assertEquals(3, tasks.size());
+ Assertions.assertEquals(3, tasks.size());
for (AgentTask agentTask : tasks) {
agentTask.setFinished(true);
}
@@ -278,7 +278,7 @@ public void testSchemaChange1() throws Exception {
}
materializedViewHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.FINISHED, rollupJob.getJobState());
+ Assertions.assertEquals(JobState.FINISHED, rollupJob.getJobState());
}
@Test
@@ -300,17 +300,17 @@ public void testSchemaChangeCancelWhenRollupTasksFailed() throws Exception {
OlapTable olapTable = (OlapTable) db.getTableOrDdlException(CatalogTestUtil.testTableId1);
materializedViewHandler.process(alterOps, db, olapTable);
Map alterJobsV2 = materializedViewHandler.getAlterJobsV2();
- Assert.assertEquals(1, alterJobsV2.size());
+ Assertions.assertEquals(1, alterJobsV2.size());
RollupJobV2 rollupJob = (RollupJobV2) alterJobsV2.values().stream().findAny().get();
materializedViewHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.WAITING_TXN, rollupJob.getJobState());
+ Assertions.assertEquals(JobState.WAITING_TXN, rollupJob.getJobState());
materializedViewHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.RUNNING, rollupJob.getJobState());
+ Assertions.assertEquals(JobState.RUNNING, rollupJob.getJobState());
List tasks = AgentTaskQueue.getTask(TTaskType.ALTER);
- Assert.assertEquals(3, tasks.size());
+ Assertions.assertEquals(3, tasks.size());
long failedTabletId = tasks.get(0).getTabletId();
int failedTaskCount = 0;
for (AgentTask agentTask : tasks) {
@@ -322,10 +322,10 @@ public void testSchemaChangeCancelWhenRollupTasksFailed() throws Exception {
break;
}
}
- Assert.assertEquals(2, failedTaskCount);
+ Assertions.assertEquals(2, failedTaskCount);
materializedViewHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.CANCELLED, rollupJob.getJobState());
+ Assertions.assertEquals(JobState.CANCELLED, rollupJob.getJobState());
}
@Test
@@ -349,13 +349,13 @@ public void testSchemaChangeWhileTabletNotStable() throws Exception {
Partition testPartition = olapTable.getPartition(CatalogTestUtil.testPartitionId1);
materializedViewHandler.process(alterOps, db, olapTable);
Map alterJobsV2 = materializedViewHandler.getAlterJobsV2();
- Assert.assertEquals(1, alterJobsV2.size());
+ Assertions.assertEquals(1, alterJobsV2.size());
RollupJobV2 rollupJob = (RollupJobV2) alterJobsV2.values().stream().findAny().get();
MaterializedIndex baseIndex = testPartition.getBaseIndex();
- Assert.assertEquals(MaterializedIndex.IndexState.NORMAL, baseIndex.getState());
- Assert.assertEquals(Partition.PartitionState.NORMAL, testPartition.getState());
- Assert.assertEquals(OlapTableState.ROLLUP, olapTable.getState());
+ Assertions.assertEquals(MaterializedIndex.IndexState.NORMAL, baseIndex.getState());
+ Assertions.assertEquals(Partition.PartitionState.NORMAL, testPartition.getState());
+ Assertions.assertEquals(OlapTableState.ROLLUP, olapTable.getState());
Tablet baseTablet = baseIndex.getTablets().get(0);
List replicas = baseTablet.getReplicas();
@@ -363,40 +363,40 @@ public void testSchemaChangeWhileTabletNotStable() throws Exception {
Replica replica2 = replicas.get(1);
Replica replica3 = replicas.get(2);
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica1.getVersion());
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica2.getVersion());
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica3.getVersion());
- Assert.assertEquals(-1, replica1.getLastFailedVersion());
- Assert.assertEquals(-1, replica2.getLastFailedVersion());
- Assert.assertEquals(-1, replica3.getLastFailedVersion());
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica1.getLastSuccessVersion());
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica2.getLastSuccessVersion());
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica3.getLastSuccessVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica1.getVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica2.getVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica3.getVersion());
+ Assertions.assertEquals(-1, replica1.getLastFailedVersion());
+ Assertions.assertEquals(-1, replica2.getLastFailedVersion());
+ Assertions.assertEquals(-1, replica3.getLastFailedVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica1.getLastSuccessVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica2.getLastSuccessVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica3.getLastSuccessVersion());
// runPendingJob
replica1.setState(Replica.ReplicaState.DECOMMISSION);
materializedViewHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.PENDING, rollupJob.getJobState());
+ Assertions.assertEquals(JobState.PENDING, rollupJob.getJobState());
// table is stable, runPendingJob again
replica1.setState(Replica.ReplicaState.NORMAL);
materializedViewHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.WAITING_TXN, rollupJob.getJobState());
- Assert.assertEquals(2, testPartition.getMaterializedIndices(IndexExtState.ALL).size());
- Assert.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.VISIBLE).size());
- Assert.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.SHADOW).size());
+ Assertions.assertEquals(JobState.WAITING_TXN, rollupJob.getJobState());
+ Assertions.assertEquals(2, testPartition.getMaterializedIndices(IndexExtState.ALL).size());
+ Assertions.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.VISIBLE).size());
+ Assertions.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.SHADOW).size());
// runWaitingTxnJob
materializedViewHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.RUNNING, rollupJob.getJobState());
+ Assertions.assertEquals(JobState.RUNNING, rollupJob.getJobState());
// runWaitingTxnJob, task not finished
materializedViewHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.RUNNING, rollupJob.getJobState());
+ Assertions.assertEquals(JobState.RUNNING, rollupJob.getJobState());
// finish all tasks
List tasks = AgentTaskQueue.getTask(TTaskType.ALTER);
- Assert.assertEquals(3, tasks.size());
+ Assertions.assertEquals(3, tasks.size());
for (AgentTask agentTask : tasks) {
agentTask.setFinished(true);
}
@@ -408,7 +408,7 @@ public void testSchemaChangeWhileTabletNotStable() throws Exception {
}
materializedViewHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.FINISHED, rollupJob.getJobState());
+ Assertions.assertEquals(JobState.FINISHED, rollupJob.getJobState());
}
@@ -445,11 +445,11 @@ public void testSerializeOfRollupJob()
DataInputStream in = new DataInputStream(new FileInputStream(file));
RollupJobV2 result = (RollupJobV2) AlterJobV2.read(in);
- Assert.assertEquals(TStorageFormat.V2, Deencapsulation.getField(result, "storageFormat"));
+ Assertions.assertEquals(TStorageFormat.V2, Deencapsulation.getField(result, "storageFormat"));
List resultColumns = Deencapsulation.getField(result, "rollupSchema");
- Assert.assertEquals(1, resultColumns.size());
+ Assertions.assertEquals(1, resultColumns.size());
Column resultColumn1 = resultColumns.get(0);
- Assert.assertEquals(mvColumnName,
+ Assertions.assertEquals(mvColumnName,
resultColumn1.getName());
}
@@ -486,7 +486,7 @@ public void testDeserializeOldRollupJobWithoutOrigStmt() {
+ "}";
RollupJobV2 result = (RollupJobV2) GsonUtils.GSON.fromJson(oldJson, AlterJobV2.class);
- Assert.assertEquals(JobState.FINISHED, Deencapsulation.getField(result, "showJobState"));
+ Assertions.assertEquals(JobState.FINISHED, Deencapsulation.getField(result, "showJobState"));
}
@Test
@@ -509,7 +509,7 @@ public void testAddRollupForDupTable() throws UserException {
List columns = materializedViewHandler.checkAndPrepareMaterializedView(addRollupOp, olapTable, CatalogTestUtil.testIndexId2, false);
for (Column column : columns) {
if (column.nameEquals("v1", true)) {
- Assert.assertNull(column.getAggregationType());
+ Assertions.assertNull(column.getAggregationType());
break;
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/alter/SchemaChangeHandlerTest.java b/fe/fe-core/src/test/java/org/apache/doris/alter/SchemaChangeHandlerTest.java
index 8839fca5a54e1e..4b3962b91421b4 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/alter/SchemaChangeHandlerTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/alter/SchemaChangeHandlerTest.java
@@ -46,7 +46,6 @@
import com.google.common.collect.Sets;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -131,7 +130,7 @@ private void waitAlterJobDone(Map alterJobs) throws Exception
Thread.sleep(1000);
}
LOG.info("alter job {} is done. state: {}", alterJobV2.getJobId(), alterJobV2.getJobState());
- Assert.assertEquals(AlterJobV2.JobState.FINISHED, alterJobV2.getJobState());
+ Assertions.assertEquals(AlterJobV2.JobState.FINISHED, alterJobV2.getJobState());
Database db = Env.getCurrentInternalCatalog().getDbOrMetaException(alterJobV2.getDbId());
OlapTable tbl = (OlapTable) db.getTableOrMetaException(alterJobV2.getTableId(), Table.TableType.OLAP);
@@ -193,7 +192,7 @@ public void testWithRowBinlogSchemaChangeNoHistoricalValue() throws Exception {
List cols = tbl.getRowBinlogMeta().getSchema(true).stream().map(Column::getName)
.collect(Collectors.toList());
- Assert.assertFalse(cols.contains(Column.generateBeforeColName("v1")));
+ Assertions.assertFalse(cols.contains(Column.generateBeforeColName("v1")));
// single add column
alterTable("ALTER TABLE test." + tableName + " ADD COLUMN v2 INT AFTER v1", connectContext);
@@ -201,10 +200,10 @@ public void testWithRowBinlogSchemaChangeNoHistoricalValue() throws Exception {
waitAlterJobDone(Env.getCurrentEnv().getSchemaChangeHandler().getAlterJobsV2());
cols = tbl.getRowBinlogMeta().getSchema(true).stream().map(Column::getName).collect(Collectors.toList());
- Assert.assertEquals(2, cols.indexOf("v2"));
- Assert.assertEquals(3, cols.indexOf(Column.BINLOG_TSO_COL));
- Assert.assertEquals(4, cols.indexOf(Column.BINLOG_LSN_COL));
- Assert.assertFalse(cols.contains(Column.generateBeforeColName("v2")));
+ Assertions.assertEquals(2, cols.indexOf("v2"));
+ Assertions.assertEquals(3, cols.indexOf(Column.BINLOG_TSO_COL));
+ Assertions.assertEquals(4, cols.indexOf(Column.BINLOG_LSN_COL));
+ Assertions.assertFalse(cols.contains(Column.generateBeforeColName("v2")));
// multiple add column clauses in one ALTER
alterTable("ALTER TABLE test." + tableName
@@ -213,12 +212,12 @@ public void testWithRowBinlogSchemaChangeNoHistoricalValue() throws Exception {
waitAlterJobDone(Env.getCurrentEnv().getSchemaChangeHandler().getAlterJobsV2());
cols = tbl.getRowBinlogMeta().getSchema(true).stream().map(Column::getName).collect(Collectors.toList());
- Assert.assertEquals(3, cols.indexOf("v3"));
- Assert.assertEquals(4, cols.indexOf("v4"));
- Assert.assertEquals(5, cols.indexOf(Column.BINLOG_TSO_COL));
- Assert.assertEquals(6, cols.indexOf(Column.BINLOG_LSN_COL));
- Assert.assertFalse(cols.contains(Column.generateBeforeColName("v3")));
- Assert.assertFalse(cols.contains(Column.generateBeforeColName("v4")));
+ Assertions.assertEquals(3, cols.indexOf("v3"));
+ Assertions.assertEquals(4, cols.indexOf("v4"));
+ Assertions.assertEquals(5, cols.indexOf(Column.BINLOG_TSO_COL));
+ Assertions.assertEquals(6, cols.indexOf(Column.BINLOG_LSN_COL));
+ Assertions.assertFalse(cols.contains(Column.generateBeforeColName("v3")));
+ Assertions.assertFalse(cols.contains(Column.generateBeforeColName("v4")));
// AddColumnsOp: ADD COLUMN (colDef1, colDef2)
alterTable("ALTER TABLE test." + tableName + " ADD COLUMN (v5 INT, v6 INT)", connectContext);
@@ -226,12 +225,12 @@ public void testWithRowBinlogSchemaChangeNoHistoricalValue() throws Exception {
waitAlterJobDone(Env.getCurrentEnv().getSchemaChangeHandler().getAlterJobsV2());
cols = tbl.getRowBinlogMeta().getSchema(true).stream().map(Column::getName).collect(Collectors.toList());
- Assert.assertEquals(5, cols.indexOf("v5"));
- Assert.assertEquals(6, cols.indexOf("v6"));
- Assert.assertEquals(7, cols.indexOf(Column.BINLOG_TSO_COL));
- Assert.assertEquals(8, cols.indexOf(Column.BINLOG_LSN_COL));
- Assert.assertFalse(cols.contains(Column.generateBeforeColName("v5")));
- Assert.assertFalse(cols.contains(Column.generateBeforeColName("v6")));
+ Assertions.assertEquals(5, cols.indexOf("v5"));
+ Assertions.assertEquals(6, cols.indexOf("v6"));
+ Assertions.assertEquals(7, cols.indexOf(Column.BINLOG_TSO_COL));
+ Assertions.assertEquals(8, cols.indexOf(Column.BINLOG_LSN_COL));
+ Assertions.assertFalse(cols.contains(Column.generateBeforeColName("v5")));
+ Assertions.assertFalse(cols.contains(Column.generateBeforeColName("v6")));
// drop column
alterTable("ALTER TABLE test." + tableName + " DROP COLUMN v6", connectContext);
@@ -239,9 +238,9 @@ public void testWithRowBinlogSchemaChangeNoHistoricalValue() throws Exception {
waitAlterJobDone(Env.getCurrentEnv().getSchemaChangeHandler().getAlterJobsV2());
cols = tbl.getRowBinlogMeta().getSchema(true).stream().map(Column::getName).collect(Collectors.toList());
- Assert.assertFalse(cols.contains("v6"));
- Assert.assertEquals(6, cols.indexOf(Column.BINLOG_TSO_COL));
- Assert.assertEquals(7, cols.indexOf(Column.BINLOG_LSN_COL));
+ Assertions.assertFalse(cols.contains("v6"));
+ Assertions.assertEquals(6, cols.indexOf(Column.BINLOG_TSO_COL));
+ Assertions.assertEquals(7, cols.indexOf(Column.BINLOG_LSN_COL));
}
@Test
@@ -263,7 +262,7 @@ public void testWithRowBinlogSchemaChangeWithHistoricalValue() throws Exception
List cols = tbl.getRowBinlogMeta().getSchema(true).stream().map(Column::getName)
.collect(Collectors.toList());
- Assert.assertTrue(cols.contains(Column.generateBeforeColName("v1")));
+ Assertions.assertTrue(cols.contains(Column.generateBeforeColName("v1")));
// single add column
alterTable("ALTER TABLE test." + tableName + " ADD COLUMN v2 INT AFTER v1", connectContext);
@@ -271,9 +270,9 @@ public void testWithRowBinlogSchemaChangeWithHistoricalValue() throws Exception
waitAlterJobDone(Env.getCurrentEnv().getSchemaChangeHandler().getAlterJobsV2());
cols = tbl.getRowBinlogMeta().getSchema(true).stream().map(Column::getName).collect(Collectors.toList());
- Assert.assertEquals(2, cols.indexOf("v2"));
- Assert.assertTrue(cols.contains(Column.generateBeforeColName("v2")));
- Assert.assertEquals(cols.indexOf(Column.generateBeforeColName("v1")) + 1,
+ Assertions.assertEquals(2, cols.indexOf("v2"));
+ Assertions.assertTrue(cols.contains(Column.generateBeforeColName("v2")));
+ Assertions.assertEquals(cols.indexOf(Column.generateBeforeColName("v1")) + 1,
cols.indexOf(Column.generateBeforeColName("v2")));
// multiple add column clauses in one ALTER
@@ -283,13 +282,13 @@ public void testWithRowBinlogSchemaChangeWithHistoricalValue() throws Exception
waitAlterJobDone(Env.getCurrentEnv().getSchemaChangeHandler().getAlterJobsV2());
cols = tbl.getRowBinlogMeta().getSchema(true).stream().map(Column::getName).collect(Collectors.toList());
- Assert.assertEquals(3, cols.indexOf("v3"));
- Assert.assertEquals(4, cols.indexOf("v4"));
- Assert.assertTrue(cols.contains(Column.generateBeforeColName("v3")));
- Assert.assertTrue(cols.contains(Column.generateBeforeColName("v4")));
- Assert.assertEquals(cols.indexOf(Column.generateBeforeColName("v2")) + 1,
+ Assertions.assertEquals(3, cols.indexOf("v3"));
+ Assertions.assertEquals(4, cols.indexOf("v4"));
+ Assertions.assertTrue(cols.contains(Column.generateBeforeColName("v3")));
+ Assertions.assertTrue(cols.contains(Column.generateBeforeColName("v4")));
+ Assertions.assertEquals(cols.indexOf(Column.generateBeforeColName("v2")) + 1,
cols.indexOf(Column.generateBeforeColName("v3")));
- Assert.assertEquals(cols.indexOf(Column.generateBeforeColName("v3")) + 1,
+ Assertions.assertEquals(cols.indexOf(Column.generateBeforeColName("v3")) + 1,
cols.indexOf(Column.generateBeforeColName("v4")));
// AddColumnsOp: ADD COLUMN (colDef1, colDef2)
@@ -298,13 +297,13 @@ public void testWithRowBinlogSchemaChangeWithHistoricalValue() throws Exception
waitAlterJobDone(Env.getCurrentEnv().getSchemaChangeHandler().getAlterJobsV2());
cols = tbl.getRowBinlogMeta().getSchema(true).stream().map(Column::getName).collect(Collectors.toList());
- Assert.assertEquals(5, cols.indexOf("v5"));
- Assert.assertEquals(6, cols.indexOf("v6"));
- Assert.assertTrue(cols.contains(Column.generateBeforeColName("v5")));
- Assert.assertTrue(cols.contains(Column.generateBeforeColName("v6")));
- Assert.assertEquals(cols.indexOf(Column.generateBeforeColName("v4")) + 1,
+ Assertions.assertEquals(5, cols.indexOf("v5"));
+ Assertions.assertEquals(6, cols.indexOf("v6"));
+ Assertions.assertTrue(cols.contains(Column.generateBeforeColName("v5")));
+ Assertions.assertTrue(cols.contains(Column.generateBeforeColName("v6")));
+ Assertions.assertEquals(cols.indexOf(Column.generateBeforeColName("v4")) + 1,
cols.indexOf(Column.generateBeforeColName("v5")));
- Assert.assertEquals(cols.indexOf(Column.generateBeforeColName("v5")) + 1,
+ Assertions.assertEquals(cols.indexOf(Column.generateBeforeColName("v5")) + 1,
cols.indexOf(Column.generateBeforeColName("v6")));
// drop column
@@ -312,8 +311,8 @@ public void testWithRowBinlogSchemaChangeWithHistoricalValue() throws Exception
jobSize++;
waitAlterJobDone(Env.getCurrentEnv().getSchemaChangeHandler().getAlterJobsV2());
cols = tbl.getRowBinlogMeta().getSchema(true).stream().map(Column::getName).collect(Collectors.toList());
- Assert.assertFalse(cols.contains("v6"));
- Assert.assertFalse(cols.contains(Column.generateBeforeColName("v6")));
+ Assertions.assertFalse(cols.contains("v6"));
+ Assertions.assertFalse(cols.contains(Column.generateBeforeColName("v6")));
// enable hidden sequence column should not pollute row binlog schema
alterTable("ALTER TABLE test." + tableName
@@ -322,10 +321,10 @@ public void testWithRowBinlogSchemaChangeWithHistoricalValue() throws Exception
jobSize++;
waitAlterJobDone(Env.getCurrentEnv().getSchemaChangeHandler().getAlterJobsV2());
- Assert.assertTrue(tbl.getBaseSchema(true).stream().anyMatch(Column::isSequenceColumn));
+ Assertions.assertTrue(tbl.getBaseSchema(true).stream().anyMatch(Column::isSequenceColumn));
cols = tbl.getRowBinlogMeta().getSchema(true).stream().map(Column::getName).collect(Collectors.toList());
- Assert.assertFalse(cols.contains(Column.SEQUENCE_COL));
- Assert.assertFalse(cols.contains(Column.generateBeforeColName(Column.SEQUENCE_COL)));
+ Assertions.assertFalse(cols.contains(Column.SEQUENCE_COL));
+ Assertions.assertFalse(cols.contains(Column.generateBeforeColName(Column.SEQUENCE_COL)));
}
@Test
@@ -433,7 +432,7 @@ public void testWithRowBinlogOpNotSupported() throws Exception {
createTable(createVariant);
Assertions.fail("Expected exception for VARIANT column");
} catch (Exception e) {
- Assert.assertTrue(e.getMessage().toLowerCase().contains("variant"));
+ Assertions.assertTrue(e.getMessage().toLowerCase().contains("variant"));
}
String tableName2 = "binlog_add_variant";
@@ -455,7 +454,7 @@ public void testWithRowBinlogOpNotSupported() throws Exception {
createTable(createAutoinc);
Assertions.fail("Expected exception for AUTO_INCREMENT column");
} catch (Exception e) {
- Assert.assertTrue(e.getMessage().toLowerCase().contains("auto"));
+ Assertions.assertTrue(e.getMessage().toLowerCase().contains("auto"));
}
}
@@ -782,7 +781,7 @@ public void testAggAddOrDropColumn() throws Exception {
// process agg drop key column with replace schema change, expect exception.
String dropKeyColStmtStr = "alter table test.sc_agg drop column new_k1";
alterTable(dropKeyColStmtStr, connectContext);
- Assert.fail();
+ Assertions.fail();
} catch (Exception e) {
LOG.info(e.getMessage());
}
@@ -969,7 +968,7 @@ public void testAddValueColumnOnAggMV() {
try {
Deencapsulation.invoke(schemaChangeHandler, "addColumnInternal", olapTable, newColumn, columnPosition,
Long.valueOf(2), Long.valueOf(1), Maps.newHashMap(), Sets.newHashSet(), false, Maps.newHashMap());
- Assert.fail();
+ Assertions.fail();
} catch (Exception e) {
System.out.println(e.getMessage());
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/alter/SchemaChangeJobV2Test.java b/fe/fe-core/src/test/java/org/apache/doris/alter/SchemaChangeJobV2Test.java
index f184c73d62bfeb..ce03ab8663b6e6 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/alter/SchemaChangeJobV2Test.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/alter/SchemaChangeJobV2Test.java
@@ -75,12 +75,10 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
@@ -114,10 +112,7 @@ public class SchemaChangeJobV2Test {
false, AggregateType.MAX, false, Optional.of(new DefaultValue("1")), "");
private static AddColumnOp addColumnOp = new AddColumnOp(newCol, new ColumnPosition("v"), null, null);
- @Rule
- public ExpectedException expectedEx = ExpectedException.none();
-
- @Before
+ @BeforeEach
public void setUp()
throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException,
NoSuchMethodException, SecurityException, UserException {
@@ -138,7 +133,7 @@ public void setUp()
mockedAgentTaskExecutor = Mockito.mockStatic(AgentTaskExecutor.class);
}
- @After
+ @AfterEach
public void tearDown() {
if (mockedAgentTaskExecutor != null) {
mockedAgentTaskExecutor.close();
@@ -173,8 +168,8 @@ public void testAddSchemaChange() throws UserException {
OlapTable olapTable = (OlapTable) db.getTableOrDdlException(CatalogTestUtil.testTableId1);
schemaChangeHandler.process(alterOps, db, olapTable);
Map alterJobsV2 = schemaChangeHandler.getAlterJobsV2();
- Assert.assertEquals(1, alterJobsV2.size());
- Assert.assertEquals(OlapTableState.SCHEMA_CHANGE, olapTable.getState());
+ Assertions.assertEquals(1, alterJobsV2.size());
+ Assertions.assertEquals(OlapTableState.SCHEMA_CHANGE, olapTable.getState());
}
@Test
@@ -197,11 +192,11 @@ public void testDropColumnUpdatesBfColumnsBeforeJobFinalized() throws UserExcept
alterOps.add(new DropColumnOp(bfColumn.getName(), null, Maps.newHashMap()));
schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.assertNull(olapTable.getCopiedBfColumns());
+ Assertions.assertNull(olapTable.getCopiedBfColumns());
SchemaChangeJobV2 schemaChangeJob = (SchemaChangeJobV2) schemaChangeHandler
.getAlterJobsV2().values().stream().findFirst().orElseThrow();
- Assert.assertNull(Deencapsulation.getField(schemaChangeJob, "bfColumns"));
- Assert.assertFalse((Boolean) Deencapsulation.getField(schemaChangeJob, "hasBfChange"));
+ Assertions.assertNull(Deencapsulation.getField(schemaChangeJob, "bfColumns"));
+ Assertions.assertFalse((Boolean) Deencapsulation.getField(schemaChangeJob, "hasBfChange"));
}
// start a schema change, then finished
@@ -226,13 +221,13 @@ public void testSchemaChange1() throws Exception {
Partition testPartition = olapTable.getPartition(CatalogTestUtil.testPartitionId1);
schemaChangeHandler.process(alterOps, db, olapTable);
Map alterJobsV2 = schemaChangeHandler.getAlterJobsV2();
- Assert.assertEquals(1, alterJobsV2.size());
+ Assertions.assertEquals(1, alterJobsV2.size());
SchemaChangeJobV2 schemaChangeJob = (SchemaChangeJobV2) alterJobsV2.values().stream().findAny().get();
MaterializedIndex baseIndex = testPartition.getBaseIndex();
- Assert.assertEquals(IndexState.NORMAL, baseIndex.getState());
- Assert.assertEquals(PartitionState.NORMAL, testPartition.getState());
- Assert.assertEquals(OlapTableState.SCHEMA_CHANGE, olapTable.getState());
+ Assertions.assertEquals(IndexState.NORMAL, baseIndex.getState());
+ Assertions.assertEquals(PartitionState.NORMAL, testPartition.getState());
+ Assertions.assertEquals(OlapTableState.SCHEMA_CHANGE, olapTable.getState());
Tablet baseTablet = baseIndex.getTablets().get(0);
List replicas = baseTablet.getReplicas();
@@ -240,39 +235,39 @@ public void testSchemaChange1() throws Exception {
Replica replica2 = replicas.get(1);
Replica replica3 = replicas.get(2);
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica1.getVersion());
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica2.getVersion());
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica3.getVersion());
- Assert.assertEquals(-1, replica1.getLastFailedVersion());
- Assert.assertEquals(-1, replica2.getLastFailedVersion());
- Assert.assertEquals(-1, replica3.getLastFailedVersion());
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica1.getLastSuccessVersion());
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica2.getLastSuccessVersion());
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica3.getLastSuccessVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica1.getVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica2.getVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica3.getVersion());
+ Assertions.assertEquals(-1, replica1.getLastFailedVersion());
+ Assertions.assertEquals(-1, replica2.getLastFailedVersion());
+ Assertions.assertEquals(-1, replica3.getLastFailedVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica1.getLastSuccessVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica2.getLastSuccessVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica3.getLastSuccessVersion());
// runPendingJob
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.WAITING_TXN, schemaChangeJob.getJobState());
- Assert.assertEquals(2, testPartition.getMaterializedIndices(IndexExtState.ALL).size());
- Assert.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.VISIBLE).size());
- Assert.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.SHADOW).size());
+ Assertions.assertEquals(JobState.WAITING_TXN, schemaChangeJob.getJobState());
+ Assertions.assertEquals(2, testPartition.getMaterializedIndices(IndexExtState.ALL).size());
+ Assertions.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.VISIBLE).size());
+ Assertions.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.SHADOW).size());
// runWaitingTxnJob
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.RUNNING, schemaChangeJob.getJobState());
+ Assertions.assertEquals(JobState.RUNNING, schemaChangeJob.getJobState());
// runRunningJob, task not finished
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.RUNNING, schemaChangeJob.getJobState());
+ Assertions.assertEquals(JobState.RUNNING, schemaChangeJob.getJobState());
// runRunningJob
schemaChangeHandler.runAfterCatalogReady();
// task not finished, still running
- Assert.assertEquals(JobState.RUNNING, schemaChangeJob.getJobState());
+ Assertions.assertEquals(JobState.RUNNING, schemaChangeJob.getJobState());
// finish alter tasks
List tasks = AgentTaskQueue.getTask(TTaskType.ALTER);
- Assert.assertEquals(3, tasks.size());
+ Assertions.assertEquals(3, tasks.size());
for (AgentTask agentTask : tasks) {
agentTask.setFinished(true);
}
@@ -284,7 +279,7 @@ public void testSchemaChange1() throws Exception {
}
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.FINISHED, schemaChangeJob.getJobState());
+ Assertions.assertEquals(JobState.FINISHED, schemaChangeJob.getJobState());
}
@Test
@@ -308,13 +303,13 @@ public void testSchemaChangeWhileTabletNotStable() throws Exception {
Partition testPartition = olapTable.getPartition(CatalogTestUtil.testPartitionId1);
schemaChangeHandler.process(alterOps, db, olapTable);
Map alterJobsV2 = schemaChangeHandler.getAlterJobsV2();
- Assert.assertEquals(1, alterJobsV2.size());
+ Assertions.assertEquals(1, alterJobsV2.size());
SchemaChangeJobV2 schemaChangeJob = (SchemaChangeJobV2) alterJobsV2.values().stream().findAny().get();
MaterializedIndex baseIndex = testPartition.getBaseIndex();
- Assert.assertEquals(IndexState.NORMAL, baseIndex.getState());
- Assert.assertEquals(PartitionState.NORMAL, testPartition.getState());
- Assert.assertEquals(OlapTableState.SCHEMA_CHANGE, olapTable.getState());
+ Assertions.assertEquals(IndexState.NORMAL, baseIndex.getState());
+ Assertions.assertEquals(PartitionState.NORMAL, testPartition.getState());
+ Assertions.assertEquals(OlapTableState.SCHEMA_CHANGE, olapTable.getState());
Tablet baseTablet = baseIndex.getTablets().get(0);
List replicas = baseTablet.getReplicas();
@@ -322,45 +317,45 @@ public void testSchemaChangeWhileTabletNotStable() throws Exception {
Replica replica2 = replicas.get(1);
Replica replica3 = replicas.get(2);
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica1.getVersion());
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica2.getVersion());
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica3.getVersion());
- Assert.assertEquals(-1, replica1.getLastFailedVersion());
- Assert.assertEquals(-1, replica2.getLastFailedVersion());
- Assert.assertEquals(-1, replica3.getLastFailedVersion());
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica1.getLastSuccessVersion());
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica2.getLastSuccessVersion());
- Assert.assertEquals(CatalogTestUtil.testStartVersion, replica3.getLastSuccessVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica1.getVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica2.getVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica3.getVersion());
+ Assertions.assertEquals(-1, replica1.getLastFailedVersion());
+ Assertions.assertEquals(-1, replica2.getLastFailedVersion());
+ Assertions.assertEquals(-1, replica3.getLastFailedVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica1.getLastSuccessVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica2.getLastSuccessVersion());
+ Assertions.assertEquals(CatalogTestUtil.testStartVersion, replica3.getLastSuccessVersion());
// runPendingJob
replica1.setState(Replica.ReplicaState.DECOMMISSION);
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.PENDING, schemaChangeJob.getJobState());
+ Assertions.assertEquals(JobState.PENDING, schemaChangeJob.getJobState());
// table is stable runPendingJob again
replica1.setState(Replica.ReplicaState.NORMAL);
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.WAITING_TXN, schemaChangeJob.getJobState());
- Assert.assertEquals(2, testPartition.getMaterializedIndices(IndexExtState.ALL).size());
- Assert.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.VISIBLE).size());
- Assert.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.SHADOW).size());
+ Assertions.assertEquals(JobState.WAITING_TXN, schemaChangeJob.getJobState());
+ Assertions.assertEquals(2, testPartition.getMaterializedIndices(IndexExtState.ALL).size());
+ Assertions.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.VISIBLE).size());
+ Assertions.assertEquals(1, testPartition.getMaterializedIndices(IndexExtState.SHADOW).size());
// runWaitingTxnJob
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.RUNNING, schemaChangeJob.getJobState());
+ Assertions.assertEquals(JobState.RUNNING, schemaChangeJob.getJobState());
// runWaitingTxnJob, task not finished
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.RUNNING, schemaChangeJob.getJobState());
+ Assertions.assertEquals(JobState.RUNNING, schemaChangeJob.getJobState());
// runRunningJob
schemaChangeHandler.runAfterCatalogReady();
// task not finished, still running
- Assert.assertEquals(JobState.RUNNING, schemaChangeJob.getJobState());
+ Assertions.assertEquals(JobState.RUNNING, schemaChangeJob.getJobState());
// finish alter tasks
List tasks = AgentTaskQueue.getTask(TTaskType.ALTER);
- Assert.assertEquals(3, tasks.size());
+ Assertions.assertEquals(3, tasks.size());
for (AgentTask agentTask : tasks) {
agentTask.setFinished(true);
}
@@ -372,7 +367,7 @@ public void testSchemaChangeWhileTabletNotStable() throws Exception {
}
schemaChangeHandler.runAfterCatalogReady();
- Assert.assertEquals(JobState.FINISHED, schemaChangeJob.getJobState());
+ Assertions.assertEquals(JobState.FINISHED, schemaChangeJob.getJobState());
}
@Test
@@ -398,43 +393,43 @@ public void testModifyDynamicPartitionNormal() throws UserException {
Database db = CatalogMocker.mockDb();
OlapTable olapTable = (OlapTable) db.getTableOrDdlException(CatalogMocker.TEST_TBL2_ID);
schemaChangeHandler.process(alterOps, db, olapTable);
- Assert.assertTrue(olapTable.getTableProperty().getDynamicPartitionProperty().isExist());
- Assert.assertTrue(olapTable.getTableProperty().getDynamicPartitionProperty().getEnable());
- Assert.assertEquals("day", olapTable.getTableProperty().getDynamicPartitionProperty().getTimeUnit());
- Assert.assertEquals(3, olapTable.getTableProperty().getDynamicPartitionProperty().getEnd());
- Assert.assertEquals("p", olapTable.getTableProperty().getDynamicPartitionProperty().getPrefix());
- Assert.assertEquals(30, olapTable.getTableProperty().getDynamicPartitionProperty().getBuckets());
+ Assertions.assertTrue(olapTable.getTableProperty().getDynamicPartitionProperty().isExist());
+ Assertions.assertTrue(olapTable.getTableProperty().getDynamicPartitionProperty().getEnable());
+ Assertions.assertEquals("day", olapTable.getTableProperty().getDynamicPartitionProperty().getTimeUnit());
+ Assertions.assertEquals(3, olapTable.getTableProperty().getDynamicPartitionProperty().getEnd());
+ Assertions.assertEquals("p", olapTable.getTableProperty().getDynamicPartitionProperty().getPrefix());
+ Assertions.assertEquals(30, olapTable.getTableProperty().getDynamicPartitionProperty().getBuckets());
// set dynamic_partition.enable = false
ArrayList tmpAlterOps = new ArrayList<>();
properties.put(DynamicPartitionProperty.ENABLE, "false");
tmpAlterOps.add(new ModifyTablePropertiesOp(properties));
schemaChangeHandler.process(tmpAlterOps, db, olapTable);
- Assert.assertFalse(olapTable.getTableProperty().getDynamicPartitionProperty().getEnable());
+ Assertions.assertFalse(olapTable.getTableProperty().getDynamicPartitionProperty().getEnable());
// set dynamic_partition.time_unit = week
tmpAlterOps = new ArrayList<>();
properties.put(DynamicPartitionProperty.TIME_UNIT, "week");
tmpAlterOps.add(new ModifyTablePropertiesOp(properties));
schemaChangeHandler.process(tmpAlterOps, db, olapTable);
- Assert.assertEquals("week", olapTable.getTableProperty().getDynamicPartitionProperty().getTimeUnit());
+ Assertions.assertEquals("week", olapTable.getTableProperty().getDynamicPartitionProperty().getTimeUnit());
// set dynamic_partition.end = 10
tmpAlterOps = new ArrayList<>();
properties.put(DynamicPartitionProperty.END, "10");
tmpAlterOps.add(new ModifyTablePropertiesOp(properties));
schemaChangeHandler.process(tmpAlterOps, db, olapTable);
- Assert.assertEquals(10, olapTable.getTableProperty().getDynamicPartitionProperty().getEnd());
+ Assertions.assertEquals(10, olapTable.getTableProperty().getDynamicPartitionProperty().getEnd());
// set dynamic_partition.prefix = p1
tmpAlterOps = new ArrayList<>();
properties.put(DynamicPartitionProperty.PREFIX, "p1");
tmpAlterOps.add(new ModifyTablePropertiesOp(properties));
schemaChangeHandler.process(tmpAlterOps, db, olapTable);
- Assert.assertEquals("p1", olapTable.getTableProperty().getDynamicPartitionProperty().getPrefix());
+ Assertions.assertEquals("p1", olapTable.getTableProperty().getDynamicPartitionProperty().getPrefix());
// set dynamic_partition.buckets = 3
tmpAlterOps = new ArrayList<>();
properties.put(DynamicPartitionProperty.BUCKETS, "3");
tmpAlterOps.add(new ModifyTablePropertiesOp(properties));
schemaChangeHandler.process(tmpAlterOps, db, olapTable);
- Assert.assertEquals(3, olapTable.getTableProperty().getDynamicPartitionProperty().getBuckets());
+ Assertions.assertEquals(3, olapTable.getTableProperty().getDynamicPartitionProperty().getBuckets());
}
public void modifyDynamicPartitionWithoutTableProperty(String propertyKey, String propertyValue)
@@ -453,11 +448,13 @@ public void modifyDynamicPartitionWithoutTableProperty(String propertyKey, Strin
Database db = CatalogMocker.mockDb();
OlapTable olapTable = (OlapTable) db.getTableOrDdlException(CatalogMocker.TEST_TBL2_ID);
- expectedEx.expect(DdlException.class);
- expectedEx.expectMessage("errCode = 2,"
+ DdlException e = Assertions.assertThrows(DdlException.class, () -> {
+ schemaChangeHandler.process(alterOps, db, olapTable);
+ });
+ Assertions.assertTrue(e.getMessage().contains("errCode = 2,"
+ " detailMessage = Table test_db.test_tbl2 is not a dynamic partition table. "
- + "Use command `HELP ALTER TABLE` to see how to change a normal table to a dynamic partition table.");
- schemaChangeHandler.process(alterOps, db, olapTable);
+ + "Use command `HELP ALTER TABLE` to see how to change a normal table to a dynamic partition table."),
+ "unexpected message: " + e.getMessage());
}
@Test
@@ -493,10 +490,12 @@ public void testModifyDynamicPartitionWithInvalidProperty() throws UserException
Database db = CatalogMocker.mockDb();
OlapTable olapTable = (OlapTable) db.getTableOrDdlException(CatalogMocker.TEST_TBL2_ID);
- expectedEx.expect(DdlException.class);
- expectedEx.expectMessage("errCode = 2,"
- + " detailMessage = Invalid dynamic partition properties: dynamic_partition.time_uint, dynamic_partition.edn");
- schemaChangeHandler.process(alterOps, db, olapTable);
+ DdlException e = Assertions.assertThrows(DdlException.class, () -> {
+ schemaChangeHandler.process(alterOps, db, olapTable);
+ });
+ Assertions.assertTrue(e.getMessage().contains("errCode = 2,"
+ + " detailMessage = Invalid dynamic partition properties: dynamic_partition.time_uint, dynamic_partition.edn"),
+ "unexpected message: " + e.getMessage());
}
@Test
@@ -527,16 +526,16 @@ public void testSerializeOfSchemaChangeJob() throws IOException {
DataInputStream in = new DataInputStream(new FileInputStream(file));
SchemaChangeJobV2 result = (SchemaChangeJobV2) AlterJobV2.read(in);
- Assert.assertEquals(1, result.getJobId());
- Assert.assertEquals(JobState.FINISHED, result.getJobState());
- Assert.assertEquals(TStorageFormat.V2, Deencapsulation.getField(result, "storageFormat"));
+ Assertions.assertEquals(1, result.getJobId());
+ Assertions.assertEquals(JobState.FINISHED, result.getJobState());
+ Assertions.assertEquals(TStorageFormat.V2, Deencapsulation.getField(result, "storageFormat"));
- Assert.assertNotNull(Deencapsulation.getField(result, "partitionIndexMap"));
- Assert.assertNotNull(Deencapsulation.getField(result, "partitionIndexTabletMap"));
+ Assertions.assertNotNull(Deencapsulation.getField(result, "partitionIndexMap"));
+ Assertions.assertNotNull(Deencapsulation.getField(result, "partitionIndexTabletMap"));
Map map = Deencapsulation.getField(result, "indexSchemaVersionAndHashMap");
- Assert.assertEquals(10, map.get(1000L).schemaVersion);
- Assert.assertEquals(20, map.get(1000L).schemaHash);
+ Assertions.assertEquals(10, map.get(1000L).schemaVersion);
+ Assertions.assertEquals(20, map.get(1000L).schemaHash);
}
@Test
@@ -553,9 +552,9 @@ public void testModifyTableDistributionType() throws DdlException {
Database db = masterEnv.getInternalCatalog().getDb(CatalogTestUtil.testDbId1).get();
OlapTable olapTable = (OlapTable) db.getTable(CatalogTestUtil.testTableId1).get();
Env.getCurrentEnv().convertDistributionType(db, olapTable);
- Assert.assertTrue(olapTable.getDefaultDistributionInfo().getType() == DistributionInfo.DistributionInfoType.RANDOM);
+ Assertions.assertTrue(olapTable.getDefaultDistributionInfo().getType() == DistributionInfo.DistributionInfoType.RANDOM);
Partition partition1 = olapTable.getPartition(CatalogTestUtil.testPartitionId1);
- Assert.assertTrue(partition1.getDistributionInfo().getType() == DistributionInfo.DistributionInfoType.RANDOM);
+ Assertions.assertTrue(partition1.getDistributionInfo().getType() == DistributionInfo.DistributionInfoType.RANDOM);
}
@Test
@@ -572,9 +571,11 @@ public void testAbnormalModifyTableDistributionType1() throws UserException {
FakeEnv.setEnv(masterEnv);
Database db = masterEnv.getInternalCatalog().getDb(CatalogTestUtil.testDbId1).get();
Mockito.when(table.isColocateTable()).thenReturn(true);
- expectedEx.expect(DdlException.class);
- expectedEx.expectMessage("errCode = 2, detailMessage = Cannot change distribution type of colocate table.");
- Env.getCurrentEnv().convertDistributionType(db, table);
+ DdlException e = Assertions.assertThrows(DdlException.class, () -> {
+ Env.getCurrentEnv().convertDistributionType(db, table);
+ });
+ Assertions.assertTrue(e.getMessage().contains("errCode = 2, detailMessage = Cannot change distribution type of colocate table."),
+ "unexpected message: " + e.getMessage());
}
@Test
@@ -592,9 +593,11 @@ public void testAbnormalModifyTableDistributionType2() throws UserException {
Database db = masterEnv.getInternalCatalog().getDb(CatalogTestUtil.testDbId1).get();
Mockito.when(table.isColocateTable()).thenReturn(false);
Mockito.when(table.getKeysType()).thenReturn(KeysType.UNIQUE_KEYS);
- expectedEx.expect(DdlException.class);
- expectedEx.expectMessage("errCode = 2, detailMessage = Cannot change distribution type of unique keys table.");
- Env.getCurrentEnv().convertDistributionType(db, table);
+ DdlException e = Assertions.assertThrows(DdlException.class, () -> {
+ Env.getCurrentEnv().convertDistributionType(db, table);
+ });
+ Assertions.assertTrue(e.getMessage().contains("errCode = 2, detailMessage = Cannot change distribution type of unique keys table."),
+ "unexpected message: " + e.getMessage());
}
@Test
@@ -615,10 +618,12 @@ public void testAbnormalModifyTableDistributionType3() throws UserException {
Mockito.when(table.getBaseSchema()).thenReturn(Lists.newArrayList(
new Column("k1", Type.INT, true, null, "0", ""),
new Column("v1", Type.INT, false, AggregateType.REPLACE, "0", "")));
- expectedEx.expect(DdlException.class);
- expectedEx.expectMessage("errCode = 2, detailMessage = Cannot change "
- + "distribution type of aggregate keys table which has value columns with REPLACE type.");
- Env.getCurrentEnv().convertDistributionType(db, table);
+ DdlException e = Assertions.assertThrows(DdlException.class, () -> {
+ Env.getCurrentEnv().convertDistributionType(db, table);
+ });
+ Assertions.assertTrue(e.getMessage().contains("errCode = 2, detailMessage = Cannot change "
+ + "distribution type of aggregate keys table which has value columns with REPLACE type."),
+ "unexpected message: " + e.getMessage());
}
@Test
@@ -706,7 +711,7 @@ public void testCreateShadowIndexReplicaCopiesBfIndexesOnlyForBaseShadowReplica(
// Only base shadow indexes copy BfIndex metadata. BfColumns are carried separately,
// so BfIndex metadata does not get folded
// into the rollup shadow replica.
- Assert.assertEquals(2, submittedTasks.size());
+ Assertions.assertEquals(2, submittedTasks.size());
CreateReplicaTask baseTask = (CreateReplicaTask) submittedTasks.stream()
.filter(task -> task.getIndexId() == shadowBaseIndexId)
.findFirst()
@@ -725,10 +730,10 @@ public void testCreateShadowIndexReplicaCopiesBfIndexesOnlyForBaseShadowReplica(
@SuppressWarnings("unchecked")
Set rollupTaskBfColumns = Deencapsulation.getField(rollupTask, "bfColumns");
- Assert.assertEquals(bfIndexes, baseTaskIndexes);
- Assert.assertNull(rollupTaskIndexes);
- Assert.assertNull(baseTaskBfColumns);
- Assert.assertNull(rollupTaskBfColumns);
+ Assertions.assertEquals(bfIndexes, baseTaskIndexes);
+ Assertions.assertNull(rollupTaskIndexes);
+ Assertions.assertNull(baseTaskBfColumns);
+ Assertions.assertNull(rollupTaskBfColumns);
}
private MaterializedIndex createLocalIndex(long indexId, long tabletId, long replicaId, long backendId,
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/AlterUserStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/AlterUserStmtTest.java
index d16b9e0638d9ce..1ccedb59b36db5 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/AlterUserStmtTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/AlterUserStmtTest.java
@@ -26,9 +26,9 @@
import org.apache.doris.nereids.trees.plans.commands.info.AlterUserInfo;
import org.apache.doris.qe.ConnectContext;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
@@ -36,7 +36,7 @@
public class AlterUserStmtTest {
- @Before
+ @BeforeEach
public void setUp() {
ConnectContext ctx = new ConnectContext();
ctx.setRemoteIP("192.168.1.1");
@@ -64,8 +64,8 @@ public void testTlsRequireNoneOnly() throws UserException {
PasswordOptions.UNSET_OPTION, null, TlsOptions.requireNone());
info.validate();
- Assert.assertEquals(org.apache.doris.alter.AlterUserOpType.SET_TLS_REQUIRE, info.getOpType());
- Assert.assertFalse(info.getUserIdent().hasTlsRequirements());
+ Assertions.assertEquals(org.apache.doris.alter.AlterUserOpType.SET_TLS_REQUIRE, info.getOpType());
+ Assertions.assertFalse(info.getUserIdent().hasTlsRequirements());
}
}
@@ -79,68 +79,78 @@ public void testTlsRequireSanOnly() throws UserException {
PasswordOptions.UNSET_OPTION, null, tlsOptions);
info.validate();
- Assert.assertEquals(org.apache.doris.alter.AlterUserOpType.SET_TLS_REQUIRE, info.getOpType());
- Assert.assertEquals("DNS:example.com", info.getUserIdent().getSan());
+ Assertions.assertEquals(org.apache.doris.alter.AlterUserOpType.SET_TLS_REQUIRE, info.getOpType());
+ Assertions.assertEquals("DNS:example.com", info.getUserIdent().getSan());
}
}
- @Test(expected = AnalysisException.class)
+ @Test
public void testTlsWithPasswordChangeNotAllowed() throws UserException {
- Env env = Mockito.mock(Env.class);
- AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
- try (MockedStatic ignored = mockValidateEnv(env, accessManager)) {
- TlsOptions tlsOptions = TlsOptions.of(Collections.singletonList(Pair.of("SAN", "DNS:example.com")));
- AlterUserInfo info = new AlterUserInfo(false,
- new UserDesc(new UserIdentity("tls_user", "%"), "passwd", true),
- PasswordOptions.UNSET_OPTION, null, tlsOptions);
- info.validate();
- }
+ Assertions.assertThrows(AnalysisException.class, () -> {
+ Env env = Mockito.mock(Env.class);
+ AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
+ try (MockedStatic ignored = mockValidateEnv(env, accessManager)) {
+ TlsOptions tlsOptions = TlsOptions.of(Collections.singletonList(Pair.of("SAN", "DNS:example.com")));
+ AlterUserInfo info = new AlterUserInfo(false,
+ new UserDesc(new UserIdentity("tls_user", "%"), "passwd", true),
+ PasswordOptions.UNSET_OPTION, null, tlsOptions);
+ info.validate();
+ }
+ });
}
- @Test(expected = AnalysisException.class)
+ @Test
public void testTlsRequireSanEmptyValue() throws UserException {
- Env env = Mockito.mock(Env.class);
- AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
- try (MockedStatic ignored = mockValidateEnv(env, accessManager)) {
- AlterUserInfo info = new AlterUserInfo(false, new UserDesc(new UserIdentity("tls_user", "%")),
- PasswordOptions.UNSET_OPTION, null,
- TlsOptions.of(Collections.singletonList(Pair.of("SAN", ""))));
- info.validate();
- }
+ Assertions.assertThrows(AnalysisException.class, () -> {
+ Env env = Mockito.mock(Env.class);
+ AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
+ try (MockedStatic ignored = mockValidateEnv(env, accessManager)) {
+ AlterUserInfo info = new AlterUserInfo(false, new UserDesc(new UserIdentity("tls_user", "%")),
+ PasswordOptions.UNSET_OPTION, null,
+ TlsOptions.of(Collections.singletonList(Pair.of("SAN", ""))));
+ info.validate();
+ }
+ });
}
- @Test(expected = AnalysisException.class)
+ @Test
public void testTlsUnsupportedOption() throws UserException {
- Env env = Mockito.mock(Env.class);
- AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
- try (MockedStatic ignored = mockValidateEnv(env, accessManager)) {
- AlterUserInfo info = new AlterUserInfo(false, new UserDesc(new UserIdentity("tls_user", "%")),
- PasswordOptions.UNSET_OPTION, null,
- TlsOptions.of(Collections.singletonList(Pair.of("ISSUER", "ca"))));
- info.validate();
- }
+ Assertions.assertThrows(AnalysisException.class, () -> {
+ Env env = Mockito.mock(Env.class);
+ AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
+ try (MockedStatic ignored = mockValidateEnv(env, accessManager)) {
+ AlterUserInfo info = new AlterUserInfo(false, new UserDesc(new UserIdentity("tls_user", "%")),
+ PasswordOptions.UNSET_OPTION, null,
+ TlsOptions.of(Collections.singletonList(Pair.of("ISSUER", "ca"))));
+ info.validate();
+ }
+ });
}
- @Test(expected = AnalysisException.class)
+ @Test
public void testMultipleNonTlsOpsAreRejected() throws UserException {
- Env env = Mockito.mock(Env.class);
- AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
- try (MockedStatic ignored = mockValidateEnv(env, accessManager)) {
- AlterUserInfo info = new AlterUserInfo(false,
- new UserDesc(new UserIdentity("tls_user", "%"), "passwd", true), PasswordOptions.UNSET_OPTION,
- "new comment", TlsOptions.notSpecified());
- info.validate();
- }
+ Assertions.assertThrows(AnalysisException.class, () -> {
+ Env env = Mockito.mock(Env.class);
+ AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
+ try (MockedStatic ignored = mockValidateEnv(env, accessManager)) {
+ AlterUserInfo info = new AlterUserInfo(false,
+ new UserDesc(new UserIdentity("tls_user", "%"), "passwd", true), PasswordOptions.UNSET_OPTION,
+ "new comment", TlsOptions.notSpecified());
+ info.validate();
+ }
+ });
}
- @Test(expected = AnalysisException.class)
+ @Test
public void testNoOpsAreRejected() throws UserException {
- Env env = Mockito.mock(Env.class);
- AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
- try (MockedStatic ignored = mockValidateEnv(env, accessManager)) {
- AlterUserInfo info = new AlterUserInfo(false, new UserDesc(new UserIdentity("tls_user", "%")),
- PasswordOptions.UNSET_OPTION, null, TlsOptions.notSpecified());
- info.validate();
- }
+ Assertions.assertThrows(AnalysisException.class, () -> {
+ Env env = Mockito.mock(Env.class);
+ AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
+ try (MockedStatic ignored = mockValidateEnv(env, accessManager)) {
+ AlterUserInfo info = new AlterUserInfo(false, new UserDesc(new UserIdentity("tls_user", "%")),
+ PasswordOptions.UNSET_OPTION, null, TlsOptions.notSpecified());
+ info.validate();
+ }
+ });
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateUserStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateUserStmtTest.java
index 25c53ef1b5a934..b805bb95018699 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateUserStmtTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateUserStmtTest.java
@@ -26,9 +26,9 @@
import org.apache.doris.nereids.trees.plans.commands.info.CreateUserInfo;
import org.apache.doris.qe.ConnectContext;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
@@ -36,7 +36,7 @@
public class CreateUserStmtTest {
- @Before
+ @BeforeEach
public void setUp() {
ConnectContext ctx = new ConnectContext();
ctx.setRemoteIP("192.168.1.1");
@@ -66,18 +66,18 @@ public void testPasswordNormalize() throws AnalysisException {
try (MockedStatic ignored = mockValidateEnv(env, auth, accessManager)) {
CreateUserInfo info = new CreateUserInfo(new UserDesc(new UserIdentity("user", "%"), "passwd", true));
info.validate();
- Assert.assertEquals("user", info.getUserIdent().getQualifiedUser());
- Assert.assertEquals("*59C70DA2F3E3A5BDF46B68F5C8B8F25762BCCEF0", new String(info.getPassword()));
+ Assertions.assertEquals("user", info.getUserIdent().getQualifiedUser());
+ Assertions.assertEquals("*59C70DA2F3E3A5BDF46B68F5C8B8F25762BCCEF0", new String(info.getPassword()));
info = new CreateUserInfo(
new UserDesc(new UserIdentity("user", "%"),
"*59c70da2f3e3a5bdf46b68f5c8b8f25762bccef0", false));
info.validate();
- Assert.assertEquals("*59C70DA2F3E3A5BDF46B68F5C8B8F25762BCCEF0", new String(info.getPassword()));
+ Assertions.assertEquals("*59C70DA2F3E3A5BDF46B68F5C8B8F25762BCCEF0", new String(info.getPassword()));
info = new CreateUserInfo(new UserDesc(new UserIdentity("user", "%"), "", false));
info.validate();
- Assert.assertEquals("", new String(info.getPassword()));
+ Assertions.assertEquals("", new String(info.getPassword()));
}
}
@@ -93,8 +93,8 @@ public void testTlsRequireNone() throws AnalysisException {
info.validate();
UserIdentity userIdent = info.getUserIdent();
- Assert.assertFalse(userIdent.hasTlsRequirements());
- Assert.assertNull(userIdent.getSan());
+ Assertions.assertFalse(userIdent.hasTlsRequirements());
+ Assertions.assertNull(userIdent.getSan());
}
}
@@ -111,55 +111,63 @@ public void testTlsRequireSan() throws AnalysisException {
info.validate();
UserIdentity userIdent = info.getUserIdent();
- Assert.assertEquals("DNS:example.com", userIdent.getSan());
+ Assertions.assertEquals("DNS:example.com", userIdent.getSan());
}
}
- @Test(expected = AnalysisException.class)
+ @Test
public void testTlsRequireSanEmptyValue() throws AnalysisException {
- Env env = Mockito.mock(Env.class);
- Auth auth = Mockito.mock(Auth.class);
- AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
- try (MockedStatic ignored = mockValidateEnv(env, auth, accessManager)) {
- CreateUserInfo info = new CreateUserInfo(false,
- new UserDesc(new UserIdentity("tls_user", "%"), "passwd", true),
- null, null, null, TlsOptions.of(Collections.singletonList(Pair.of("SAN", ""))));
- info.validate();
- }
+ Assertions.assertThrows(AnalysisException.class, () -> {
+ Env env = Mockito.mock(Env.class);
+ Auth auth = Mockito.mock(Auth.class);
+ AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
+ try (MockedStatic ignored = mockValidateEnv(env, auth, accessManager)) {
+ CreateUserInfo info = new CreateUserInfo(false,
+ new UserDesc(new UserIdentity("tls_user", "%"), "passwd", true),
+ null, null, null, TlsOptions.of(Collections.singletonList(Pair.of("SAN", ""))));
+ info.validate();
+ }
+ });
}
- @Test(expected = AnalysisException.class)
+ @Test
public void testTlsUnsupportedOption() throws AnalysisException {
- Env env = Mockito.mock(Env.class);
- Auth auth = Mockito.mock(Auth.class);
- AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
- try (MockedStatic ignored = mockValidateEnv(env, auth, accessManager)) {
- CreateUserInfo info = new CreateUserInfo(false,
- new UserDesc(new UserIdentity("tls_user", "%"), "passwd", true),
- null, null, null, TlsOptions.of(Collections.singletonList(Pair.of("ISSUER", "ca"))));
- info.validate();
- }
+ Assertions.assertThrows(AnalysisException.class, () -> {
+ Env env = Mockito.mock(Env.class);
+ Auth auth = Mockito.mock(Auth.class);
+ AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
+ try (MockedStatic ignored = mockValidateEnv(env, auth, accessManager)) {
+ CreateUserInfo info = new CreateUserInfo(false,
+ new UserDesc(new UserIdentity("tls_user", "%"), "passwd", true),
+ null, null, null, TlsOptions.of(Collections.singletonList(Pair.of("ISSUER", "ca"))));
+ info.validate();
+ }
+ });
}
- @Test(expected = AnalysisException.class)
+ @Test
public void testEmptyUser() throws AnalysisException {
- Env env = Mockito.mock(Env.class);
- Auth auth = Mockito.mock(Auth.class);
- AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
- try (MockedStatic ignored = mockValidateEnv(env, auth, accessManager)) {
- CreateUserInfo info = new CreateUserInfo(new UserDesc(new UserIdentity("", "%"), "passwd", true));
- info.validate();
- }
+ Assertions.assertThrows(AnalysisException.class, () -> {
+ Env env = Mockito.mock(Env.class);
+ Auth auth = Mockito.mock(Auth.class);
+ AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
+ try (MockedStatic ignored = mockValidateEnv(env, auth, accessManager)) {
+ CreateUserInfo info = new CreateUserInfo(new UserDesc(new UserIdentity("", "%"), "passwd", true));
+ info.validate();
+ }
+ });
}
- @Test(expected = AnalysisException.class)
+ @Test
public void testBadPass() throws AnalysisException {
- Env env = Mockito.mock(Env.class);
- Auth auth = Mockito.mock(Auth.class);
- AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
- try (MockedStatic ignored = mockValidateEnv(env, auth, accessManager)) {
- CreateUserInfo info = new CreateUserInfo(new UserDesc(new UserIdentity("", "%"), "passwd", false));
- info.validate();
- }
+ Assertions.assertThrows(AnalysisException.class, () -> {
+ Env env = Mockito.mock(Env.class);
+ Auth auth = Mockito.mock(Auth.class);
+ AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
+ try (MockedStatic ignored = mockValidateEnv(env, auth, accessManager)) {
+ CreateUserInfo info = new CreateUserInfo(new UserDesc(new UserIdentity("", "%"), "passwd", false));
+ info.validate();
+ }
+ });
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/StorageDescPersistTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/StorageDescPersistTest.java
index f26fc09a915f9f..b029e9695099a5 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/StorageDescPersistTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/StorageDescPersistTest.java
@@ -23,8 +23,8 @@
import org.apache.doris.persist.gson.GsonUtils;
import com.google.common.collect.Maps;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.lang.reflect.Field;
import java.util.Map;
@@ -40,10 +40,10 @@ public void testBrokerDescRestoreStoragePropertiesAfterGsonRoundTrip() {
BrokerDesc restored = GsonUtils.GSON.fromJson(GsonUtils.GSON.toJson(brokerDesc), BrokerDesc.class);
- Assert.assertNotNull(restored.getStorageAdapter());
- Assert.assertEquals("BROKER", restored.getStorageAdapter().getStorageName());
- Assert.assertEquals("test_broker", restored.getStorageAdapter().getBrokerName());
- Assert.assertEquals("user", restored.getStorageAdapter().getBackendConfigProperties()
+ Assertions.assertNotNull(restored.getStorageAdapter());
+ Assertions.assertEquals("BROKER", restored.getStorageAdapter().getStorageName());
+ Assertions.assertEquals("test_broker", restored.getStorageAdapter().getBrokerName());
+ Assertions.assertEquals("user", restored.getStorageAdapter().getBackendConfigProperties()
.get("broker.username"));
}
@@ -64,14 +64,14 @@ public void testBrokerLoadJobRestoreS3StoragePropertiesAfterGsonRoundTrip() thro
(BrokerDesc) getField(BrokerLoadJob.class.getSuperclass(), restored, "brokerDesc");
StorageAdapter restoredStorageProperties = restoredBrokerDesc.getStorageAdapter();
- Assert.assertNotNull(restoredStorageProperties);
- Assert.assertEquals("S3", restoredStorageProperties.getStorageName());
- Assert.assertEquals(EtlJobType.BROKER, restored.getJobType());
- Assert.assertEquals(StorageBackend.StorageType.S3, restoredBrokerDesc.getStorageType());
- Assert.assertEquals("test-bucket", restoredStorageProperties.getOrigProps().get("s3.bucket"));
- Assert.assertNotNull(restoredBrokerDesc.getStorageAdapter());
- Assert.assertEquals("S3", restoredBrokerDesc.getStorageAdapter().getStorageName());
- Assert.assertEquals("test-bucket",
+ Assertions.assertNotNull(restoredStorageProperties);
+ Assertions.assertEquals("S3", restoredStorageProperties.getStorageName());
+ Assertions.assertEquals(EtlJobType.BROKER, restored.getJobType());
+ Assertions.assertEquals(StorageBackend.StorageType.S3, restoredBrokerDesc.getStorageType());
+ Assertions.assertEquals("test-bucket", restoredStorageProperties.getOrigProps().get("s3.bucket"));
+ Assertions.assertNotNull(restoredBrokerDesc.getStorageAdapter());
+ Assertions.assertEquals("S3", restoredBrokerDesc.getStorageAdapter().getStorageName());
+ Assertions.assertEquals("test-bucket",
restoredBrokerDesc.getStorageAdapter().getOrigProps().get("s3.bucket"));
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/TableScanParamsTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/TableScanParamsTest.java
index 6a37a91e1e7f9a..5adfa5f0ea241e 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/TableScanParamsTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/TableScanParamsTest.java
@@ -19,8 +19,8 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Map;
@@ -40,31 +40,31 @@ public void testConstructAcceptsValidParamTypes() {
@Test
public void testConstructRejectsInvalidParamType() {
- IllegalArgumentException e = Assert.assertThrows(IllegalArgumentException.class,
+ IllegalArgumentException e = Assertions.assertThrows(IllegalArgumentException.class,
() -> new TableScanParams("unknown", EMPTY_MAP, EMPTY_LIST));
- Assert.assertTrue(e.getMessage().contains("Invalid param type"));
+ Assertions.assertTrue(e.getMessage().contains("Invalid param type"));
}
@Test
public void testParamTypeLowerCased() {
TableScanParams params = new TableScanParams("BRANCH", EMPTY_MAP, EMPTY_LIST);
- Assert.assertEquals(TableScanParams.BRANCH, params.getParamType());
- Assert.assertTrue(params.isBranch());
+ Assertions.assertEquals(TableScanParams.BRANCH, params.getParamType());
+ Assertions.assertTrue(params.isBranch());
}
@Test
public void testNullMapParamsBecomesEmpty() {
TableScanParams params = new TableScanParams(TableScanParams.TAG, null, EMPTY_LIST);
- Assert.assertTrue(params.getMapParams().isEmpty());
+ Assertions.assertTrue(params.getMapParams().isEmpty());
}
@Test
public void testTypePredicates() {
- Assert.assertTrue(new TableScanParams(TableScanParams.INCREMENTAL_READ, EMPTY_MAP, EMPTY_LIST)
+ Assertions.assertTrue(new TableScanParams(TableScanParams.INCREMENTAL_READ, EMPTY_MAP, EMPTY_LIST)
.incrementalRead());
- Assert.assertTrue(new TableScanParams(TableScanParams.SNAPSHOT, EMPTY_MAP, EMPTY_LIST).isSnapshot());
- Assert.assertTrue(new TableScanParams(TableScanParams.RESET, EMPTY_MAP, EMPTY_LIST).isReset());
- Assert.assertTrue(new TableScanParams(TableScanParams.TAG, EMPTY_MAP, EMPTY_LIST).isTag());
+ Assertions.assertTrue(new TableScanParams(TableScanParams.SNAPSHOT, EMPTY_MAP, EMPTY_LIST).isSnapshot());
+ Assertions.assertTrue(new TableScanParams(TableScanParams.RESET, EMPTY_MAP, EMPTY_LIST).isReset());
+ Assertions.assertTrue(new TableScanParams(TableScanParams.TAG, EMPTY_MAP, EMPTY_LIST).isTag());
}
@Test
@@ -74,9 +74,9 @@ public void testValidateOlapTableAcceptsIncr() {
@Test
public void testValidateOlapTableRejectsOthers() {
- IllegalArgumentException e = Assert.assertThrows(IllegalArgumentException.class,
+ IllegalArgumentException e = Assertions.assertThrows(IllegalArgumentException.class,
() -> new TableScanParams(TableScanParams.BRANCH, EMPTY_MAP, EMPTY_LIST).validateOlapTable());
- Assert.assertTrue(e.getMessage().contains("Invalid param type for olap table"));
+ Assertions.assertTrue(e.getMessage().contains("Invalid param type for olap table"));
}
@Test
@@ -87,9 +87,9 @@ public void testValidateOlapTableStreamAcceptsSnapshotAndReset() {
@Test
public void testValidateOlapTableStreamRejectsOthers() {
- IllegalArgumentException e = Assert.assertThrows(IllegalArgumentException.class,
+ IllegalArgumentException e = Assertions.assertThrows(IllegalArgumentException.class,
() -> new TableScanParams(TableScanParams.INCREMENTAL_READ, EMPTY_MAP, EMPTY_LIST)
.validateOlapTableStream());
- Assert.assertTrue(e.getMessage().contains("Invalid param type for olap table stream"));
+ Assertions.assertTrue(e.getMessage().contains("Invalid param type for olap table stream"));
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/TlsOptionsTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/TlsOptionsTest.java
index da06ec0487eb11..79cf943a765dbd 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/TlsOptionsTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/TlsOptionsTest.java
@@ -20,8 +20,8 @@
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.Pair;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
@@ -31,24 +31,24 @@ public class TlsOptionsTest {
public void testAnalyzeRejectsSanEntryWithoutValue() {
TlsOptions tlsOptions = TlsOptions.of(Collections.singletonList(Pair.of("SAN", "DNS:")));
- AnalysisException e = Assert.assertThrows(AnalysisException.class, tlsOptions::analyze);
- Assert.assertTrue(e.getMessage().contains("Invalid SAN entry format"));
+ AnalysisException e = Assertions.assertThrows(AnalysisException.class, tlsOptions::analyze);
+ Assertions.assertTrue(e.getMessage().contains("Invalid SAN entry format"));
}
@Test
public void testAnalyzeRejectsUnsupportedSanType() {
TlsOptions tlsOptions = TlsOptions.of(Collections.singletonList(Pair.of("SAN", "FOO:bar")));
- AnalysisException e = Assert.assertThrows(AnalysisException.class, tlsOptions::analyze);
- Assert.assertTrue(e.getMessage().contains("Unsupported SAN entry type"));
+ AnalysisException e = Assertions.assertThrows(AnalysisException.class, tlsOptions::analyze);
+ Assertions.assertTrue(e.getMessage().contains("Unsupported SAN entry type"));
}
@Test
public void testAnalyzeRejectsEmptyEntryInList() {
TlsOptions tlsOptions = TlsOptions.of(Collections.singletonList(Pair.of("SAN", "DNS:example.com, ")));
- AnalysisException e = Assert.assertThrows(AnalysisException.class, tlsOptions::analyze);
- Assert.assertTrue(e.getMessage().contains("empty entry"));
+ AnalysisException e = Assertions.assertThrows(AnalysisException.class, tlsOptions::analyze);
+ Assertions.assertTrue(e.getMessage().contains("empty entry"));
}
@Test
@@ -58,7 +58,7 @@ public void testAnalyzeNormalizesValidEntries() throws AnalysisException {
));
tlsOptions.analyze();
- Assert.assertEquals(
+ Assertions.assertEquals(
"email:alice@example.com, DNS:Example.com, URI:spiffe://Example.com/workload, IP Address:192.168.1.1",
tlsOptions.getSan());
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/auth/certificate/SanEntryCodecTest.java b/fe/fe-core/src/test/java/org/apache/doris/auth/certificate/SanEntryCodecTest.java
index e91512478ae55f..f966db38e7fc5c 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/auth/certificate/SanEntryCodecTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/auth/certificate/SanEntryCodecTest.java
@@ -17,8 +17,8 @@
package org.apache.doris.auth.certificate;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
@@ -30,7 +30,7 @@ public void testParseAndNormalizeCanonicalizesEntries() {
List entries = SanEntryCodec.parseAndNormalize(
"email:Alice@Example.com, DNS:Example.com., IP:10.0.0.1");
- Assert.assertEquals(Arrays.asList(
+ Assertions.assertEquals(Arrays.asList(
"email:Alice@Example.com",
"DNS:Example.com",
"IP Address:10.0.0.1"), entries);
@@ -38,14 +38,14 @@ public void testParseAndNormalizeCanonicalizesEntries() {
@Test
public void testContainsAllMatchesNormalizedEntries() {
- Assert.assertTrue(SanEntryCodec.containsAll(
+ Assertions.assertTrue(SanEntryCodec.containsAll(
Arrays.asList("DNS:example.com", "email:Alice@Example.com"),
Arrays.asList("email:Alice@Example.com", "DNS:example.com.", "URI:spiffe://foo")));
}
@Test
public void testContainsAllRejectsMissingEntry() {
- Assert.assertFalse(SanEntryCodec.containsAll(
+ Assertions.assertFalse(SanEntryCodec.containsAll(
Arrays.asList("DNS:example.com", "URI:spiffe://example.com/workload"),
Arrays.asList("DNS:example.com")));
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/backup/BackupHandlerTest.java b/fe/fe-core/src/test/java/org/apache/doris/backup/BackupHandlerTest.java
index 48e65ae6293b3a..e055cdb37f7e72 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/backup/BackupHandlerTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/backup/BackupHandlerTest.java
@@ -51,10 +51,10 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedConstruction;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
@@ -90,7 +90,7 @@ public class BackupHandlerTest {
private TabletInvertedIndex invertedIndex = new LocalTabletInvertedIndex();
- @Before
+ @BeforeEach
public void setUp() throws Exception {
Config.tmp_dir = tmpPath;
rootDir = new File(Config.tmp_dir);
@@ -113,7 +113,7 @@ public void setUp() throws Exception {
Mockito.doReturn(db).when(catalog).getDbOrDdlException(Mockito.anyString());
}
- @After
+ @AfterEach
public void done() {
if (mockedEnvStatic != null) {
mockedEnvStatic.close();
@@ -135,7 +135,7 @@ public void testInit() {
handler.runAfterCatalogReady();
File backupDir = new File(BackupHandler.BACKUP_ROOT_DIR.toString());
- Assert.assertTrue(backupDir.exists());
+ Assertions.assertTrue(backupDir.exists());
}
@Test
diff --git a/fe/fe-core/src/test/java/org/apache/doris/backup/BackupJobInfoTest.java b/fe/fe-core/src/test/java/org/apache/doris/backup/BackupJobInfoTest.java
index 9132f157a395ee..31661bc78bc2ce 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/backup/BackupJobInfoTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/backup/BackupJobInfoTest.java
@@ -17,10 +17,10 @@
package org.apache.doris.backup;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.FileNotFoundException;
@@ -31,7 +31,7 @@ public class BackupJobInfoTest {
private static String fileName = "job_info.txt";
- @BeforeClass
+ @BeforeAll
public static void createFile() {
String json = "{\n"
+ " \"backup_time\": 1522231864000,\n"
@@ -124,11 +124,11 @@ public static void createFile() {
out.print(json);
} catch (FileNotFoundException e) {
e.printStackTrace();
- Assert.fail();
+ Assertions.fail();
}
}
- @AfterClass
+ @AfterAll
public static void deleteFile() {
File file = new File(fileName);
if (file.exists()) {
@@ -143,23 +143,23 @@ public void testReadWrite() {
jobInfo = BackupJobInfo.fromFile(fileName);
} catch (IOException e) {
e.printStackTrace();
- Assert.fail();
+ Assertions.fail();
}
- Assert.assertNotNull(jobInfo);
+ Assertions.assertNotNull(jobInfo);
- Assert.assertEquals(1522231864000L, jobInfo.backupTime);
- Assert.assertEquals("snapshot1", jobInfo.name);
- Assert.assertEquals(2, jobInfo.backupOlapTableObjects.size());
+ Assertions.assertEquals(1522231864000L, jobInfo.backupTime);
+ Assertions.assertEquals("snapshot1", jobInfo.name);
+ Assertions.assertEquals(2, jobInfo.backupOlapTableObjects.size());
- Assert.assertEquals(2, jobInfo.getOlapTableInfo("table1").partitions.size());
- Assert.assertEquals(2, jobInfo.getOlapTableInfo("table1").getPartInfo("partition1").indexes.size());
- Assert.assertEquals(2,
+ Assertions.assertEquals(2, jobInfo.getOlapTableInfo("table1").partitions.size());
+ Assertions.assertEquals(2, jobInfo.getOlapTableInfo("table1").getPartInfo("partition1").indexes.size());
+ Assertions.assertEquals(2,
jobInfo.getOlapTableInfo("table1").getPartInfo("partition1").getIdx("rollup1").tablets.size());
- Assert.assertEquals(2,
+ Assertions.assertEquals(2,
jobInfo.getOlapTableInfo("table1").getPartInfo("partition1")
.getIdx("rollup1").getTabletFiles(10007L).size());
- Assert.assertEquals(1, jobInfo.newBackupObjects.views.size());
- Assert.assertEquals("view1", jobInfo.newBackupObjects.views.get(0).name);
+ Assertions.assertEquals(1, jobInfo.newBackupObjects.views.size());
+ Assertions.assertEquals("view1", jobInfo.newBackupObjects.views.get(0).name);
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/backup/BackupJobTest.java b/fe/fe-core/src/test/java/org/apache/doris/backup/BackupJobTest.java
index e1e79f5bbe0dba..daafadc9d35b12 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/backup/BackupJobTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/backup/BackupJobTest.java
@@ -51,12 +51,12 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
import org.mockito.MockedConstruction;
import org.mockito.MockedStatic;
@@ -117,14 +117,14 @@ public BackupJobTest() throws UserException {
private MockedStatic mockedAgentTaskExecutor;
private MockedConstruction mockedFsDescriptor;
- @BeforeClass
+ @BeforeAll
public static void start() {
Config.tmp_dir = "./";
File backupDir = new File(BackupHandler.BACKUP_ROOT_DIR.toString());
backupDir.mkdirs();
}
- @AfterClass
+ @AfterAll
public static void end() throws IOException {
Config.tmp_dir = "./";
File backupDir = new File(BackupHandler.BACKUP_ROOT_DIR.toString());
@@ -134,7 +134,7 @@ public static void end() throws IOException {
}
}
- @Before
+ @BeforeEach
public void setUp() {
repoMgr = Mockito.mock(RepositoryMgr.class);
backupHandler = Mockito.mock(BackupHandler.class);
@@ -208,7 +208,7 @@ public void setUp() {
env, repo.getId(), 0);
}
- @After
+ @AfterEach
public void tearDown() {
if (mockedEnvStatic != null) {
mockedEnvStatic.close();
@@ -235,27 +235,27 @@ public void tearDown() {
@Test
public void testRunNormal() {
// 1. pending
- Assert.assertEquals(BackupJobState.PENDING, job.getState());
+ Assertions.assertEquals(BackupJobState.PENDING, job.getState());
job.run();
- Assert.assertEquals(Status.OK, job.getStatus());
- Assert.assertEquals(BackupJobState.SNAPSHOTING, job.getState());
+ Assertions.assertEquals(Status.OK, job.getStatus());
+ Assertions.assertEquals(BackupJobState.SNAPSHOTING, job.getState());
BackupMeta backupMeta = job.getBackupMeta();
- Assert.assertEquals(1, backupMeta.getTables().size());
+ Assertions.assertEquals(1, backupMeta.getTables().size());
OlapTable backupTbl = (OlapTable) backupMeta.getTable(UnitTestUtil.TABLE_NAME);
List partNames = Lists.newArrayList(backupTbl.getPartitionNames());
- Assert.assertNotNull(backupTbl);
- Assert.assertEquals(backupTbl.getSignature(BackupHandler.SIGNATURE_VERSION, partNames),
+ Assertions.assertNotNull(backupTbl);
+ Assertions.assertEquals(backupTbl.getSignature(BackupHandler.SIGNATURE_VERSION, partNames),
((OlapTable) db.getTableNullable(tblId)).getSignature(BackupHandler.SIGNATURE_VERSION, partNames));
- Assert.assertEquals(1, AgentTaskQueue.getTaskNum());
+ Assertions.assertEquals(1, AgentTaskQueue.getTaskNum());
AgentTask task = AgentTaskQueue.getTask(backendId, TTaskType.MAKE_SNAPSHOT, id.get() - 1);
- Assert.assertTrue(task instanceof SnapshotTask);
+ Assertions.assertTrue(task instanceof SnapshotTask);
SnapshotTask snapshotTask = (SnapshotTask) task;
// 2. snapshoting
job.run();
- Assert.assertEquals(Status.OK, job.getStatus());
- Assert.assertEquals(BackupJobState.SNAPSHOTING, job.getState());
+ Assertions.assertEquals(Status.OK, job.getStatus());
+ Assertions.assertEquals(BackupJobState.SNAPSHOTING, job.getState());
// 3. snapshot finished
String snapshotPath = "/path/to/snapshot";
@@ -269,90 +269,90 @@ public void testRunNormal() {
snapshotTask.getSignature(), taskStatus);
request.setSnapshotFiles(snapshotFiles);
request.setSnapshotPath(snapshotPath);
- Assert.assertTrue(job.finishTabletSnapshotTask(snapshotTask, request));
+ Assertions.assertTrue(job.finishTabletSnapshotTask(snapshotTask, request));
job.run();
- Assert.assertEquals(Status.OK, job.getStatus());
- Assert.assertEquals(BackupJobState.UPLOAD_SNAPSHOT, job.getState());
+ Assertions.assertEquals(Status.OK, job.getStatus());
+ Assertions.assertEquals(BackupJobState.UPLOAD_SNAPSHOT, job.getState());
// 4. upload snapshots
AgentTaskQueue.clearAllTasks();
job.run();
- Assert.assertEquals(Status.OK, job.getStatus());
- Assert.assertEquals(BackupJobState.UPLOADING, job.getState());
- Assert.assertEquals(1, AgentTaskQueue.getTaskNum());
+ Assertions.assertEquals(Status.OK, job.getStatus());
+ Assertions.assertEquals(BackupJobState.UPLOADING, job.getState());
+ Assertions.assertEquals(1, AgentTaskQueue.getTaskNum());
task = AgentTaskQueue.getTask(backendId, TTaskType.UPLOAD, id.get() - 1);
- Assert.assertTrue(task instanceof UploadTask);
+ Assertions.assertTrue(task instanceof UploadTask);
UploadTask upTask = (UploadTask) task;
- Assert.assertEquals(job.getJobId(), upTask.getJobId());
+ Assertions.assertEquals(job.getJobId(), upTask.getJobId());
Map srcToDest = upTask.getSrcToDestPath();
- Assert.assertEquals(1, srcToDest.size());
+ Assertions.assertEquals(1, srcToDest.size());
String dest = srcToDest.get(snapshotPath + "/" + tabletId + "/" + 0);
- Assert.assertNotNull(dest);
+ Assertions.assertNotNull(dest);
// 5. uploading
job.run();
- Assert.assertEquals(Status.OK, job.getStatus());
- Assert.assertEquals(BackupJobState.UPLOADING, job.getState());
+ Assertions.assertEquals(Status.OK, job.getStatus());
+ Assertions.assertEquals(BackupJobState.UPLOADING, job.getState());
Map> tabletFileMap = Maps.newHashMap();
request = new TFinishTaskRequest(tBackend, TTaskType.UPLOAD,
upTask.getSignature(), taskStatus);
request.setTabletFiles(tabletFileMap);
- Assert.assertFalse(job.finishSnapshotUploadTask(upTask, request));
+ Assertions.assertFalse(job.finishSnapshotUploadTask(upTask, request));
List tabletFiles = Lists.newArrayList();
tabletFileMap.put(tabletId, tabletFiles);
- Assert.assertFalse(job.finishSnapshotUploadTask(upTask, request));
+ Assertions.assertFalse(job.finishSnapshotUploadTask(upTask, request));
tabletFiles.add("1.dat.4f158689243a3d6030352fec3cfd3798");
tabletFiles.add("wrong_files.idx.4f158689243a3d6030352fec3cfd3798");
tabletFiles.add("wrong_files.hdr.4f158689243a3d6030352fec3cfd3798");
- Assert.assertFalse(job.finishSnapshotUploadTask(upTask, request));
+ Assertions.assertFalse(job.finishSnapshotUploadTask(upTask, request));
tabletFiles.clear();
tabletFiles.add("1.dat.4f158689243a3d6030352fec3cfd3798");
tabletFiles.add("1.idx.4f158689243a3d6030352fec3cfd3798");
tabletFiles.add("1.hdr.4f158689243a3d6030352fec3cfd3798");
- Assert.assertTrue(job.finishSnapshotUploadTask(upTask, request));
+ Assertions.assertTrue(job.finishSnapshotUploadTask(upTask, request));
job.run();
- Assert.assertEquals(Status.OK, job.getStatus());
- Assert.assertEquals(BackupJobState.SAVE_META, job.getState());
+ Assertions.assertEquals(Status.OK, job.getStatus());
+ Assertions.assertEquals(BackupJobState.SAVE_META, job.getState());
// 6. save meta
job.run();
- Assert.assertEquals(Status.OK, job.getStatus());
- Assert.assertEquals(BackupJobState.UPLOAD_INFO, job.getState());
+ Assertions.assertEquals(Status.OK, job.getStatus());
+ Assertions.assertEquals(BackupJobState.UPLOAD_INFO, job.getState());
File metaInfo = new File(job.getLocalMetaInfoFilePath());
- Assert.assertTrue(metaInfo.exists());
+ Assertions.assertTrue(metaInfo.exists());
File jobInfo = new File(job.getLocalJobInfoFilePath());
- Assert.assertTrue(jobInfo.exists());
+ Assertions.assertTrue(jobInfo.exists());
BackupMeta restoreMetaInfo = null;
BackupJobInfo restoreJobInfo = null;
try {
restoreMetaInfo = BackupMeta.fromFile(job.getLocalMetaInfoFilePath(), FeConstants.meta_version);
- Assert.assertEquals(1, restoreMetaInfo.getTables().size());
+ Assertions.assertEquals(1, restoreMetaInfo.getTables().size());
OlapTable olapTable = (OlapTable) restoreMetaInfo.getTable(tblId);
- Assert.assertNotNull(olapTable);
- Assert.assertNotNull(restoreMetaInfo.getTable(UnitTestUtil.TABLE_NAME));
+ Assertions.assertNotNull(olapTable);
+ Assertions.assertNotNull(restoreMetaInfo.getTable(UnitTestUtil.TABLE_NAME));
List names = Lists.newArrayList(olapTable.getPartitionNames());
- Assert.assertEquals(((OlapTable) db.getTableNullable(tblId)).getSignature(BackupHandler.SIGNATURE_VERSION, names),
+ Assertions.assertEquals(((OlapTable) db.getTableNullable(tblId)).getSignature(BackupHandler.SIGNATURE_VERSION, names),
olapTable.getSignature(BackupHandler.SIGNATURE_VERSION, names));
restoreJobInfo = BackupJobInfo.fromFile(job.getLocalJobInfoFilePath());
- Assert.assertEquals(UnitTestUtil.DB_NAME, restoreJobInfo.dbName);
- Assert.assertEquals(job.getLabel(), restoreJobInfo.name);
- Assert.assertEquals(1, restoreJobInfo.backupOlapTableObjects.values().size());
+ Assertions.assertEquals(UnitTestUtil.DB_NAME, restoreJobInfo.dbName);
+ Assertions.assertEquals(job.getLabel(), restoreJobInfo.name);
+ Assertions.assertEquals(1, restoreJobInfo.backupOlapTableObjects.values().size());
} catch (IOException e) {
e.printStackTrace();
- Assert.fail();
+ Assertions.fail();
}
- Assert.assertNull(job.getBackupMeta());
- Assert.assertNull(job.getJobInfo());
+ Assertions.assertNull(job.getBackupMeta());
+ Assertions.assertNull(job.getJobInfo());
// 7. upload_info
job.run();
- Assert.assertEquals(Status.OK, job.getStatus());
- Assert.assertEquals(BackupJobState.FINISHED, job.getState());
+ Assertions.assertEquals(Status.OK, job.getStatus());
+ Assertions.assertEquals(BackupJobState.FINISHED, job.getState());
}
@Test
@@ -361,11 +361,11 @@ public void testBackupCopyTableWithDirtyDynamicPartitionStorageMedium() {
dirtyProperties.put(DynamicPartitionProperty.STORAGE_MEDIUM, "hdd");
table2.setTableProperty(new TableProperty(dirtyProperties));
- Assert.assertFalse(table2.dynamicPartitionExists());
+ Assertions.assertFalse(table2.dynamicPartitionExists());
OlapTable copied = table2.selectiveCopy(null, IndexExtState.VISIBLE, true);
- Assert.assertNotNull(copied);
- Assert.assertFalse(copied.dynamicPartitionExists());
- Assert.assertTrue(copied.getTableProperty().hasInvalidDynamicPartition());
+ Assertions.assertNotNull(copied);
+ Assertions.assertFalse(copied.dynamicPartitionExists());
+ Assertions.assertTrue(copied.getTableProperty().hasInvalidDynamicPartition());
}
@Test
@@ -374,11 +374,11 @@ public void testBackupCopyTableWithDirtyDynamicPartitionStoragePolicy() {
dirtyProperties.put(DynamicPartitionProperty.STORAGE_POLICY, "test_policy");
table2.setTableProperty(new TableProperty(dirtyProperties));
- Assert.assertFalse(table2.dynamicPartitionExists());
+ Assertions.assertFalse(table2.dynamicPartitionExists());
OlapTable copied = table2.selectiveCopy(null, IndexExtState.VISIBLE, true);
- Assert.assertNotNull(copied);
- Assert.assertFalse(copied.dynamicPartitionExists());
- Assert.assertTrue(copied.getTableProperty().hasInvalidDynamicPartition());
+ Assertions.assertNotNull(copied);
+ Assertions.assertFalse(copied.dynamicPartitionExists());
+ Assertions.assertTrue(copied.getTableProperty().hasInvalidDynamicPartition());
}
/**
@@ -408,8 +408,8 @@ public void testRunAbnormal() {
job = new BackupJob("label", dbId, UnitTestUtil.DB_NAME, tableRefs, 13600 * 1000, BackupCommand.BackupContent.ALL,
env, repo.getId(), 0);
job.run();
- Assert.assertEquals(Status.ErrCode.NOT_FOUND, job.getStatus().getErrCode());
- Assert.assertEquals(BackupJobState.CANCELLED, job.getState());
+ Assertions.assertEquals(Status.ErrCode.NOT_FOUND, job.getStatus().getErrCode());
+ Assertions.assertEquals(BackupJobState.CANCELLED, job.getState());
}
/**
@@ -454,28 +454,28 @@ public void testRunAbnormalWithMixedTables() {
env, repo.getId(), 0);
// 1. pending
- Assert.assertEquals(BackupJobState.PENDING, job.getState());
+ Assertions.assertEquals(BackupJobState.PENDING, job.getState());
job.run();
- Assert.assertEquals(Status.OK, job.getStatus());
- Assert.assertEquals(BackupJobState.SNAPSHOTING, job.getState());
+ Assertions.assertEquals(Status.OK, job.getStatus());
+ Assertions.assertEquals(BackupJobState.SNAPSHOTING, job.getState());
// Verify backup meta only contains the normal table
BackupMeta backupMeta = job.getBackupMeta();
- Assert.assertEquals(1, backupMeta.getTables().size());
+ Assertions.assertEquals(1, backupMeta.getTables().size());
OlapTable backupTbl = (OlapTable) backupMeta.getTable(UnitTestUtil.TABLE_NAME);
- Assert.assertNotNull(backupTbl);
- Assert.assertNull(backupMeta.getTable("unknown_tbl"));
+ Assertions.assertNotNull(backupTbl);
+ Assertions.assertNull(backupMeta.getTable("unknown_tbl"));
// Verify only snapshot tasks for the normal table are created
- Assert.assertEquals(1, AgentTaskQueue.getTaskNum());
+ Assertions.assertEquals(1, AgentTaskQueue.getTaskNum());
AgentTask task = AgentTaskQueue.getTask(backendId, TTaskType.MAKE_SNAPSHOT, id.get() - 1);
- Assert.assertTrue(task instanceof SnapshotTask);
+ Assertions.assertTrue(task instanceof SnapshotTask);
SnapshotTask snapshotTask = (SnapshotTask) task;
- Assert.assertEquals(tblId, snapshotTask.getTableId());
- Assert.assertEquals(dbId, snapshotTask.getDbId());
- Assert.assertEquals(partId, snapshotTask.getPartitionId());
- Assert.assertEquals(idxId, snapshotTask.getIndexId());
- Assert.assertEquals(tabletId, snapshotTask.getTabletId());
+ Assertions.assertEquals(tblId, snapshotTask.getTableId());
+ Assertions.assertEquals(dbId, snapshotTask.getDbId());
+ Assertions.assertEquals(partId, snapshotTask.getPartitionId());
+ Assertions.assertEquals(idxId, snapshotTask.getIndexId());
+ Assertions.assertEquals(tabletId, snapshotTask.getTabletId());
}
/**
@@ -518,19 +518,19 @@ public void testRunWithTableDroppedDuringSnapshoting() {
env, repo.getId(), 0);
// 1. pending - should create snapshot tasks for both tables
- Assert.assertEquals(BackupJobState.PENDING, job.getState());
+ Assertions.assertEquals(BackupJobState.PENDING, job.getState());
job.run();
- Assert.assertEquals(Status.OK, job.getStatus());
- Assert.assertEquals(BackupJobState.SNAPSHOTING, job.getState());
+ Assertions.assertEquals(Status.OK, job.getStatus());
+ Assertions.assertEquals(BackupJobState.SNAPSHOTING, job.getState());
// Verify backup meta contains both tables initially
BackupMeta backupMeta = job.getBackupMeta();
- Assert.assertEquals(2, backupMeta.getTables().size());
- Assert.assertNotNull(backupMeta.getTable(UnitTestUtil.TABLE_NAME));
- Assert.assertNotNull(backupMeta.getTable(table2Name));
+ Assertions.assertEquals(2, backupMeta.getTables().size());
+ Assertions.assertNotNull(backupMeta.getTable(UnitTestUtil.TABLE_NAME));
+ Assertions.assertNotNull(backupMeta.getTable(table2Name));
// Verify snapshot tasks are created for both tables
- Assert.assertEquals(2, AgentTaskQueue.getTaskNum());
+ Assertions.assertEquals(2, AgentTaskQueue.getTaskNum());
// 2. Simulate dropping the second table during SNAPSHOTING phase
db.unregisterTable(table2Name);
@@ -554,7 +554,7 @@ public void testRunWithTableDroppedDuringSnapshoting() {
taskStatusMissing.setErrorMsgs(Lists.newArrayList("Tablet missing"));
TFinishTaskRequest requestMissing = new TFinishTaskRequest(tBackend, TTaskType.MAKE_SNAPSHOT,
taskForDroppedTable.getSignature(), taskStatusMissing);
- Assert.assertTrue(job.finishTabletSnapshotTask(taskForDroppedTable, requestMissing));
+ Assertions.assertTrue(job.finishTabletSnapshotTask(taskForDroppedTable, requestMissing));
// Finish task for existing table
String snapshotPath = "/path/to/snapshot";
@@ -564,16 +564,16 @@ public void testRunWithTableDroppedDuringSnapshoting() {
taskForExistingTable.getSignature(), taskStatusOK);
requestOK.setSnapshotFiles(snapshotFiles);
requestOK.setSnapshotPath(snapshotPath);
- Assert.assertTrue(job.finishTabletSnapshotTask(taskForExistingTable, requestOK));
+ Assertions.assertTrue(job.finishTabletSnapshotTask(taskForExistingTable, requestOK));
// 4. Continue the backup process
job.run();
- Assert.assertEquals(Status.OK, job.getStatus());
- Assert.assertEquals(BackupJobState.UPLOAD_SNAPSHOT, job.getState());
+ Assertions.assertEquals(Status.OK, job.getStatus());
+ Assertions.assertEquals(BackupJobState.UPLOAD_SNAPSHOT, job.getState());
AgentTaskQueue.clearAllTasks();
job.run(); // UPLOAD_SNAPSHOT -> UPLOADING
- Assert.assertEquals(1, AgentTaskQueue.getTaskNum());
+ Assertions.assertEquals(1, AgentTaskQueue.getTaskNum());
UploadTask upTask = (UploadTask) AgentTaskQueue.getTask(backendId, TTaskType.UPLOAD, id.get() - 1);
// Finish upload task
@@ -586,20 +586,20 @@ public void testRunWithTableDroppedDuringSnapshoting() {
TFinishTaskRequest requestUpload = new TFinishTaskRequest(tBackend, TTaskType.UPLOAD,
upTask.getSignature(), taskStatusOK);
requestUpload.setTabletFiles(tabletFileMap);
- Assert.assertTrue(job.finishSnapshotUploadTask(upTask, requestUpload));
+ Assertions.assertTrue(job.finishSnapshotUploadTask(upTask, requestUpload));
job.run(); // UPLOADING -> SAVE_META
- Assert.assertEquals(BackupJobState.SAVE_META, job.getState());
+ Assertions.assertEquals(BackupJobState.SAVE_META, job.getState());
job.run(); // SAVE_META -> UPLOAD_INFO
- Assert.assertEquals(BackupJobState.UPLOAD_INFO, job.getState());
+ Assertions.assertEquals(BackupJobState.UPLOAD_INFO, job.getState());
job.run(); // UPLOAD_INFO -> FINISHED
- Assert.assertEquals(BackupJobState.FINISHED, job.getState());
+ Assertions.assertEquals(BackupJobState.FINISHED, job.getState());
} catch (Throwable e) {
e.printStackTrace();
- Assert.fail(e.getMessage());
+ Assertions.fail(e.getMessage());
} finally {
// Clean up: re-register the second table if it was removed
if (db.getTableNullable(table2Name) == null && table2 != null) {
@@ -647,11 +647,11 @@ public void testSerialization() throws IOException, AnalysisException {
BackupJob job2 = BackupJob.read(in);
- Assert.assertEquals(job.getJobId(), job2.getJobId());
- Assert.assertEquals(job.getDbId(), job2.getDbId());
- Assert.assertEquals(job.getCreateTime(), job2.getCreateTime());
- Assert.assertEquals(job.getType(), job2.getType());
- Assert.assertEquals(job.getCommitSeq(), job2.getCommitSeq());
+ Assertions.assertEquals(job.getJobId(), job2.getJobId());
+ Assertions.assertEquals(job.getDbId(), job2.getDbId());
+ Assertions.assertEquals(job.getCreateTime(), job2.getCreateTime());
+ Assertions.assertEquals(job.getType(), job2.getType());
+ Assertions.assertEquals(job.getCommitSeq(), job2.getCommitSeq());
// 3. delete files
in.close();
diff --git a/fe/fe-core/src/test/java/org/apache/doris/backup/PathMakerTest.java b/fe/fe-core/src/test/java/org/apache/doris/backup/PathMakerTest.java
index de9ff4f0b3f26a..07f0e51fe5e69d 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/backup/PathMakerTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/backup/PathMakerTest.java
@@ -17,7 +17,7 @@
package org.apache.doris.backup;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class PathMakerTest {
diff --git a/fe/fe-core/src/test/java/org/apache/doris/backup/RepositoryTest.java b/fe/fe-core/src/test/java/org/apache/doris/backup/RepositoryTest.java
index 109c9816b981a4..83c24ff34f9e47 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/backup/RepositoryTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/backup/RepositoryTest.java
@@ -38,11 +38,11 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
@@ -83,7 +83,7 @@ public class RepositoryTest {
private final StorageAdapter testProps = StorageAdapter.ofBroker("broker", Maps.newHashMap());
- @Before
+ @BeforeEach
public void setUp() throws Exception {
List files = Lists.newArrayList();
files.add("1.dat");
@@ -112,7 +112,7 @@ public void setUp() throws Exception {
FeConstants.runningUnitTest = true;
}
- @After
+ @AfterEach
public void tearDown() {
if (mockedEnvStatic != null) {
mockedEnvStatic.close();
@@ -129,12 +129,12 @@ public void tearDown() {
public void testGet() {
repo = new Repository(10000, "repo", false, location, testProps);
- Assert.assertEquals(repoId, repo.getId());
- Assert.assertEquals(name, repo.getName());
- Assert.assertEquals(false, repo.isReadOnly());
- Assert.assertEquals(location, repo.getLocation());
- Assert.assertEquals(null, repo.getErrorMsg());
- Assert.assertTrue(System.currentTimeMillis() - repo.getCreateTime() < 1000);
+ Assertions.assertEquals(repoId, repo.getId());
+ Assertions.assertEquals(name, repo.getName());
+ Assertions.assertEquals(false, repo.isReadOnly());
+ Assertions.assertEquals(location, repo.getLocation());
+ Assertions.assertEquals(null, repo.getErrorMsg());
+ Assertions.assertTrue(System.currentTimeMillis() - repo.getCreateTime() < 1000);
}
@Test
@@ -144,7 +144,7 @@ public void testInit() throws UserException {
// initRepository() short-circuits with OK when FeConstants.runningUnitTest == true
Status st = repo.initRepository();
System.out.println(st);
- Assert.assertTrue(st.ok());
+ Assertions.assertTrue(st.ok());
}
@Test
@@ -161,22 +161,22 @@ public void testassemnblePath() throws MalformedURLException, URISyntaxException
// "location/__palo_repository_repo_name/__ss_my_sp1/__info_2018-01-01-08-00-00"
String expected = location + "/" + Repository.PREFIX_REPO + name + "/" + Repository.PREFIX_SNAPSHOT_DIR
+ label + "/" + Repository.PREFIX_JOB_INFO + createTime2;
- Assert.assertEquals(expected, repo.assembleJobInfoFilePath(label, creastTs));
+ Assertions.assertEquals(expected, repo.assembleJobInfoFilePath(label, creastTs));
// meta info
expected = location + "/" + Repository.PREFIX_REPO + name + "/" + Repository.PREFIX_SNAPSHOT_DIR
+ label + "/" + Repository.FILE_META_INFO;
- Assert.assertEquals(expected, repo.assembleMetaInfoFilePath(label));
+ Assertions.assertEquals(expected, repo.assembleMetaInfoFilePath(label));
// snapshot path
// /location/__palo_repository_repo_name/__ss_my_ss1/__ss_content/__db_10001/__tbl_10020/__part_10031/__idx_10032/__10023/__3481721
expected = location + "/" + Repository.PREFIX_REPO + name + "/" + Repository.PREFIX_SNAPSHOT_DIR
+ label + "/" + "__ss_content/__db_1/__tbl_2/__part_3/__idx_4/__5/__7";
- Assert.assertEquals(expected, repo.assembleRemoteSnapshotPath(label, info));
+ Assertions.assertEquals(expected, repo.assembleRemoteSnapshotPath(label, info));
String rootTabletPath = "/__db_10000/__tbl_10001/__part_10002/_idx_10001/__10003";
String path = repo.getRepoPath(label, rootTabletPath);
- Assert.assertEquals("bos://backup-cmy/__palo_repository_repo/__ss_label/__ss_content/__db_10000/__tbl_10001/__part_10002/_idx_10001/__10003",
+ Assertions.assertEquals("bos://backup-cmy/__palo_repository_repo/__ss_label/__ss_content/__db_10000/__tbl_10001/__part_10002/_idx_10001/__10003",
path);
}
@@ -184,8 +184,8 @@ public void testassemnblePath() throws MalformedURLException, URISyntaxException
public void testPing() {
repo = new Repository(10000, "repo", false, location, testProps);
// ping() short-circuits with true when FeConstants.runningUnitTest == true
- Assert.assertTrue(repo.ping());
- Assert.assertTrue(repo.getErrorMsg() == null);
+ Assertions.assertTrue(repo.ping());
+ Assertions.assertTrue(repo.getErrorMsg() == null);
}
@Test
@@ -223,9 +223,9 @@ public void close() {
repo = new Repository(10000, "repo", false, location, testProps);
List snapshotNames = Lists.newArrayList();
Status st = repo.listSnapshots(snapshotNames);
- Assert.assertTrue(st.ok());
- Assert.assertEquals(1, snapshotNames.size());
- Assert.assertEquals("a", snapshotNames.get(0));
+ Assertions.assertTrue(st.ok());
+ Assertions.assertEquals(1, snapshotNames.size());
+ Assertions.assertEquals("a", snapshotNames.get(0));
}
/**
@@ -278,12 +278,12 @@ public void close() {
repo = new Repository(10000, "repo", false, location, testProps);
List snapshotNames = Lists.newArrayList();
Status st = repo.listSnapshots(snapshotNames);
- Assert.assertTrue(st.ok());
- Assert.assertEquals(2, snapshotNames.size());
- Assert.assertTrue(snapshotNames.contains("snap1"));
- Assert.assertTrue(snapshotNames.contains("snap2"));
+ Assertions.assertTrue(st.ok());
+ Assertions.assertEquals(2, snapshotNames.size());
+ Assertions.assertTrue(snapshotNames.contains("snap1"));
+ Assertions.assertTrue(snapshotNames.contains("snap2"));
// "content" must NOT appear — it is a nested directory, not a snapshot
- Assert.assertFalse(snapshotNames.contains("content"));
+ Assertions.assertFalse(snapshotNames.contains("content"));
}
@Test
@@ -300,12 +300,12 @@ public void testUpload() throws IOException {
out.print("a");
} catch (FileNotFoundException e) {
e.printStackTrace();
- Assert.fail();
+ Assertions.fail();
}
try {
String remoteFilePath = location + "/remote_file";
Status st = repo.upload(localFilePath, remoteFilePath);
- Assert.assertTrue(st.ok());
+ Assertions.assertTrue(st.ok());
} finally {
File file = new File(localFilePath);
file.delete();
@@ -321,7 +321,7 @@ public void testDownload() throws Exception {
out.print("a");
} catch (FileNotFoundException e) {
e.printStackTrace();
- Assert.fail();
+ Assertions.fail();
}
// The remote file has an md5 checksum suffix matching content "a"
@@ -367,7 +367,7 @@ public void seek(long newPos) throws IOException {
repo = new Repository(10000, "repo", false, location, testProps);
String remoteFilePath = location + "/remote_file";
Status st = repo.download(remoteFilePath, localFilePath);
- Assert.assertTrue(st.ok());
+ Assertions.assertTrue(st.ok());
} finally {
localFile.delete();
}
@@ -419,15 +419,15 @@ public void close() {
String timestamp = "";
try {
List> infos = repo.getSnapshotInfos(snapshotName, timestamp);
- Assert.assertEquals(2, infos.size());
+ Assertions.assertEquals(2, infos.size());
} catch (AnalysisException e) {
e.printStackTrace();
- Assert.fail();
+ Assertions.fail();
}
}
- @Ignore("wait support")
+ @Disabled("wait support")
@Test
public void testPersist() throws UserException {
Map properties = Maps.newHashMap();
@@ -447,14 +447,14 @@ public void testPersist() throws UserException {
Repository newRepo = Repository.read(in);
in.close();
- Assert.assertEquals(repo.getName(), newRepo.getName());
- Assert.assertEquals(repo.getId(), newRepo.getId());
- Assert.assertEquals(repo.getLocation(), newRepo.getLocation());
+ Assertions.assertEquals(repo.getName(), newRepo.getName());
+ Assertions.assertEquals(repo.getId(), newRepo.getId());
+ Assertions.assertEquals(repo.getLocation(), newRepo.getLocation());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- Assert.fail();
+ Assertions.fail();
} finally {
file.delete();
}
@@ -466,16 +466,16 @@ public void testPathNormalize() {
String newLoc = "bos://cmy_bucket/bos_repo/";
repo = new Repository(10000, "repo", false, newLoc, testProps);
String path = repo.getRepoPath("label1", "/_ss_my_ss/_ss_content/__db_10000/");
- Assert.assertEquals("bos://cmy_bucket/bos_repo/__palo_repository_repo/__ss_label1/__ss_content/_ss_my_ss/_ss_content/__db_10000/", path);
+ Assertions.assertEquals("bos://cmy_bucket/bos_repo/__palo_repository_repo/__ss_label1/__ss_content/_ss_my_ss/_ss_content/__db_10000/", path);
path = repo.getRepoPath("label1", "/_ss_my_ss/_ss_content///__db_10000");
- Assert.assertEquals("bos://cmy_bucket/bos_repo/__palo_repository_repo/__ss_label1/__ss_content/_ss_my_ss/_ss_content/__db_10000", path);
+ Assertions.assertEquals("bos://cmy_bucket/bos_repo/__palo_repository_repo/__ss_label1/__ss_content/_ss_my_ss/_ss_content/__db_10000", path);
newLoc = "hdfs://path/to/repo";
repo = new Repository(10000, "repo", false, newLoc, testProps);
SnapshotInfo snapshotInfo = new SnapshotInfo(1, 2, 3, 4, 5, 6, 7, "/path", Lists.newArrayList());
path = repo.getRepoTabletPathBySnapshotInfo("label1", snapshotInfo);
- Assert.assertEquals("hdfs://path/to/repo/__palo_repository_repo/__ss_label1/__ss_content/__db_1/__tbl_2/__part_3/__idx_4/__5", path);
+ Assertions.assertEquals("hdfs://path/to/repo/__palo_repository_repo/__ss_label1/__ss_content/__db_1/__tbl_2/__part_3/__idx_4/__5", path);
}
/**
@@ -505,10 +505,10 @@ public void testGsonPostProcessLegacyBrokerFormat() {
// The migration must produce a non-null FileSystemDescriptor.
FileSystemDescriptor fd = deserialized.getFileSystemDescriptor();
- Assert.assertNotNull("fileSystemDescriptor must be migrated from legacy 'fs' field", fd);
+ Assertions.assertNotNull(fd, "fileSystemDescriptor must be migrated from legacy 'fs' field");
// Broker fallback is expected: props are empty so no primary storage type matches.
- Assert.assertEquals(FsStorageType.BROKER, fd.getStorageType());
- Assert.assertEquals("broker", fd.getName());
+ Assertions.assertEquals(FsStorageType.BROKER, fd.getStorageType());
+ Assertions.assertEquals("broker", fd.getName());
}
/**
@@ -531,8 +531,8 @@ public void testGsonPostProcessLegacyHdfsFormat() {
Repository deserialized = GsonUtils.GSON.fromJson(legacyJson, Repository.class);
FileSystemDescriptor fd = deserialized.getFileSystemDescriptor();
- Assert.assertNotNull("fileSystemDescriptor must be migrated from legacy HDFS 'fs' field", fd);
- Assert.assertEquals(FsStorageType.HDFS, fd.getStorageType());
+ Assertions.assertNotNull(fd, "fileSystemDescriptor must be migrated from legacy HDFS 'fs' field");
+ Assertions.assertEquals(FsStorageType.HDFS, fd.getStorageType());
}
/**
@@ -581,11 +581,8 @@ public void close() {
List snapshotNames = Lists.newArrayList();
repo.listSnapshots(snapshotNames); // triggers acquireSpiFs() → getBroker(name, host)
- Assert.assertNotNull(
- "getBroker() must have been called during listSnapshots()", capturedHost.get());
- Assert.assertEquals(
- "acquireSpiFs() must pass FrontendOptions.getLocalHostAddress() to getBroker()",
- "127.0.0.1", capturedHost.get());
+ Assertions.assertNotNull(capturedHost.get(), "getBroker() must have been called during listSnapshots()");
+ Assertions.assertEquals("127.0.0.1", capturedHost.get(), "acquireSpiFs() must pass FrontendOptions.getLocalHostAddress() to getBroker()");
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/backup/RestoreFileMappingTest.java b/fe/fe-core/src/test/java/org/apache/doris/backup/RestoreFileMappingTest.java
index 85de627fa447b4..c27385b25e608e 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/backup/RestoreFileMappingTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/backup/RestoreFileMappingTest.java
@@ -19,9 +19,9 @@
import org.apache.doris.backup.RestoreFileMapping.IdChain;
-import junit.framework.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class RestoreFileMappingTest {
@@ -29,7 +29,7 @@ public class RestoreFileMappingTest {
private IdChain src;
private IdChain dest;
- @Before
+ @BeforeEach
public void setUp() {
src = new IdChain(10005L, 10006L, 10005L, 10007L, 10008L, -1L);
dest = new IdChain(10004L, 10003L, 10004L, 10007L, -1L, -1L);
@@ -39,21 +39,21 @@ public void setUp() {
@Test
public void test() {
IdChain key = new IdChain(10005L, 10006L, 10005L, 10007L, 10008L, -1L);
- Assert.assertEquals(key, src);
- Assert.assertEquals(src, key);
+ Assertions.assertEquals(key, src);
+ Assertions.assertEquals(src, key);
IdChain val = fileMapping.get(key);
- Assert.assertNotNull(val);
- Assert.assertEquals(dest, val);
+ Assertions.assertNotNull(val);
+ Assertions.assertEquals(dest, val);
Long l1 = new Long(10005L);
Long l2 = new Long(10005L);
- Assert.assertFalse(l1 == l2);
- Assert.assertEquals(l1, l2);
+ Assertions.assertFalse(l1 == l2);
+ Assertions.assertEquals(l1, l2);
Long l3 = new Long(1L);
Long l4 = new Long(1L);
- Assert.assertFalse(l3 == l4);
- Assert.assertEquals(l3, l4);
+ Assertions.assertFalse(l3 == l4);
+ Assertions.assertEquals(l3, l4);
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/backup/RestoreJobTest.java b/fe/fe-core/src/test/java/org/apache/doris/backup/RestoreJobTest.java
index 40a6f72b2db2c2..00d49f6489b464 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/backup/RestoreJobTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/backup/RestoreJobTest.java
@@ -47,10 +47,10 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedConstruction;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
@@ -124,7 +124,7 @@ public Repository getRepo(long repoId) {
@SuppressWarnings("rawtypes")
private MockedConstruction mockedMarkedCountDownLatch;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
db = CatalogMocker.mockDb();
backupHandler = new MockBackupHandler(env);
@@ -219,7 +219,7 @@ public void setUp() throws Exception {
backupMeta = new BackupMeta(tbls, resources);
}
- @After
+ @AfterEach
public void tearDown() {
if (mockedEnvStatic != null) {
mockedEnvStatic.close();
@@ -265,10 +265,10 @@ public void testSerialization() throws IOException, AnalysisException {
RestoreJob job2 = RestoreJob.read(in);
- Assert.assertEquals(job.getJobId(), job2.getJobId());
- Assert.assertEquals(job.getDbId(), job2.getDbId());
- Assert.assertEquals(job.getCreateTime(), job2.getCreateTime());
- Assert.assertEquals(job.getType(), job2.getType());
+ Assertions.assertEquals(job.getJobId(), job2.getJobId());
+ Assertions.assertEquals(job.getDbId(), job2.getDbId());
+ Assertions.assertEquals(job.getCreateTime(), job2.getCreateTime());
+ Assertions.assertEquals(job.getType(), job2.getType());
// 3. delete files
in.close();
@@ -295,7 +295,7 @@ public void testResetPartitionVisibleAndNextVersionForRestore() throws Exception
job.resetPartitionForRestore(localTbl, remoteTbl, partName, alloc);
Partition localPart = remoteTbl.getPartition(partName);
- Assert.assertEquals(localPart.getVisibleVersion(), visibleVersion);
- Assert.assertEquals(localPart.getNextVersion(), visibleVersion + 1);
+ Assertions.assertEquals(localPart.getVisibleVersion(), visibleVersion);
+ Assertions.assertEquals(localPart.getNextVersion(), visibleVersion + 1);
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/binlog/BinlogManagerTest.java b/fe/fe-core/src/test/java/org/apache/doris/binlog/BinlogManagerTest.java
index 0e0b0d0ce231a4..8a357aa20596f9 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/binlog/BinlogManagerTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/binlog/BinlogManagerTest.java
@@ -33,11 +33,11 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedConstruction;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
@@ -73,14 +73,14 @@ public class BinlogManagerTest {
private MockedConstruction mockedInternalCatalogConstruction;
private MockedConstruction mockedDatabaseConstruction;
- @BeforeClass
+ @BeforeAll
public static void beforeClass() {
Config.enable_feature_binlog = true;
}
- @Before
+ @BeforeEach
public void setUp() {
- Assert.assertTrue(tableNumPerDb < 100);
+ Assertions.assertTrue(tableNumPerDb < 100);
frameWork = Maps.newHashMap();
for (int dbOff = 1; dbOff <= dbNum; ++dbOff) {
long dbId = dbOff * dbBaseId;
@@ -136,7 +136,7 @@ public void setUp() {
.thenAnswer(inv -> EnvFactory.getInstance().createInternalCatalog());
}
- @After
+ @AfterEach
public void tearDown() {
if (mockedBinlogConfigCacheConstruction != null) {
mockedBinlogConfigCacheConstruction.close();
@@ -163,9 +163,9 @@ public void testBinlogConfigEquals() {
BinlogConfig c2 = new BinlogConfig(true, 10L, 20L, 30L, BinlogConfig.BinlogFormat.ROW, true);
BinlogConfig c3 = new BinlogConfig(true, 10L, 20L, 30L, BinlogConfig.BinlogFormat.ROW, false);
- Assert.assertEquals(c1, c2);
- Assert.assertNotEquals(c1, c3);
- Assert.assertNotEquals(c1, "not_binlog");
+ Assertions.assertEquals(c1, c2);
+ Assertions.assertNotEquals(c1, c3);
+ Assertions.assertNotEquals(c1, "not_binlog");
}
@Test
@@ -176,22 +176,22 @@ public void testBinlogConfigShowDDL() {
StringBuilder sb = new StringBuilder();
rowCfg.appendToShowCreateTable(sb);
String out = sb.toString();
- Assert.assertTrue(out.contains("\"" + PropertyAnalyzer.PROPERTIES_BINLOG_ENABLE + "\" = \"true\""));
- Assert.assertTrue(out.contains("\"" + PropertyAnalyzer.PROPERTIES_BINLOG_TTL_SECONDS + "\" = \"11\""));
- Assert.assertTrue(out.contains("\"" + PropertyAnalyzer.PROPERTIES_BINLOG_MAX_BYTES + "\" = \"22\""));
- Assert.assertTrue(out.contains("\"" + PropertyAnalyzer.PROPERTIES_BINLOG_MAX_HISTORY_NUMS
+ Assertions.assertTrue(out.contains("\"" + PropertyAnalyzer.PROPERTIES_BINLOG_ENABLE + "\" = \"true\""));
+ Assertions.assertTrue(out.contains("\"" + PropertyAnalyzer.PROPERTIES_BINLOG_TTL_SECONDS + "\" = \"11\""));
+ Assertions.assertTrue(out.contains("\"" + PropertyAnalyzer.PROPERTIES_BINLOG_MAX_BYTES + "\" = \"22\""));
+ Assertions.assertTrue(out.contains("\"" + PropertyAnalyzer.PROPERTIES_BINLOG_MAX_HISTORY_NUMS
+ "\" = \"33\""));
- Assert.assertTrue(out.contains("\"" + PropertyAnalyzer.PROPERTIES_BINLOG_FORMAT + "\" = \"ROW\""));
- Assert.assertTrue(out.contains(PropertyAnalyzer.PROPERTIES_BINLOG_NEED_HISTORICAL_VALUE));
+ Assertions.assertTrue(out.contains("\"" + PropertyAnalyzer.PROPERTIES_BINLOG_FORMAT + "\" = \"ROW\""));
+ Assertions.assertTrue(out.contains(PropertyAnalyzer.PROPERTIES_BINLOG_NEED_HISTORICAL_VALUE));
BinlogConfig stmtCfg = new BinlogConfig(true, 11L, 22L, 33L,
BinlogConfig.BinlogFormat.STATEMENT_AND_SNAPSHOT, true);
sb = new StringBuilder();
stmtCfg.appendToShowCreateTable(sb);
out = sb.toString();
- Assert.assertTrue(out.contains("\"" + PropertyAnalyzer.PROPERTIES_BINLOG_FORMAT
+ Assertions.assertTrue(out.contains("\"" + PropertyAnalyzer.PROPERTIES_BINLOG_FORMAT
+ "\" = \"STATEMENT_AND_SNAPSHOT\""));
- Assert.assertFalse(out.contains(PropertyAnalyzer.PROPERTIES_BINLOG_NEED_HISTORICAL_VALUE));
+ Assertions.assertFalse(out.contains(PropertyAnalyzer.PROPERTIES_BINLOG_NEED_HISTORICAL_VALUE));
}
@Test
@@ -220,33 +220,33 @@ public void testGetBinlog()
// get too old
pair = manager.getBinlog(dbBaseId, tableBaseId, -99);
- Assert.assertEquals(TStatusCode.BINLOG_TOO_OLD_COMMIT_SEQ, pair.first.getStatusCode());
- Assert.assertEquals(TBinlogType.DUMMY, pair.second.getType());
+ Assertions.assertEquals(TStatusCode.BINLOG_TOO_OLD_COMMIT_SEQ, pair.first.getStatusCode());
+ Assertions.assertEquals(TBinlogType.DUMMY, pair.second.getType());
// get odd commit seq in table level ok
pair = manager.getBinlog(dbBaseId, tableBaseId, 5);
- Assert.assertEquals(TStatusCode.OK, pair.first.getStatusCode());
- Assert.assertEquals(5 + 2, pair.second.getCommitSeq());
+ Assertions.assertEquals(TStatusCode.OK, pair.first.getStatusCode());
+ Assertions.assertEquals(5 + 2, pair.second.getCommitSeq());
// get even commit seq in table level ok
pair = manager.getBinlog(dbBaseId, tableBaseId, 6);
- Assert.assertEquals(TStatusCode.OK, pair.first.getStatusCode());
- Assert.assertEquals(6 + 1, pair.second.getCommitSeq());
+ Assertions.assertEquals(TStatusCode.OK, pair.first.getStatusCode());
+ Assertions.assertEquals(6 + 1, pair.second.getCommitSeq());
// get odd commit seq in db level ok
pair = manager.getBinlog(dbBaseId, -1, 5);
- Assert.assertEquals(TStatusCode.OK, pair.first.getStatusCode());
- Assert.assertEquals(5 + 1, pair.second.getCommitSeq());
+ Assertions.assertEquals(TStatusCode.OK, pair.first.getStatusCode());
+ Assertions.assertEquals(5 + 1, pair.second.getCommitSeq());
// get even commit seq in db level ok
pair = manager.getBinlog(dbBaseId, -1, 6);
- Assert.assertEquals(TStatusCode.OK, pair.first.getStatusCode());
- Assert.assertEquals(6 + 1, pair.second.getCommitSeq());
+ Assertions.assertEquals(TStatusCode.OK, pair.first.getStatusCode());
+ Assertions.assertEquals(6 + 1, pair.second.getCommitSeq());
// get too new
pair = manager.getBinlog(dbBaseId, tableBaseId, 999);
- Assert.assertEquals(TStatusCode.BINLOG_TOO_NEW_COMMIT_SEQ, pair.first.getStatusCode());
- Assert.assertNull(pair.second);
+ Assertions.assertEquals(TStatusCode.BINLOG_TOO_NEW_COMMIT_SEQ, pair.first.getStatusCode());
+ Assertions.assertNull(pair.second);
}
@Test
@@ -291,15 +291,15 @@ public void testPersist() throws NoSuchMethodException, InvocationTargetExceptio
// get origin & new dbbinlog's allbinlogs
Map originDbBinlogMap = (Map) dbBinlogMapField.get(originManager);
Map newDbBinlogMap = (Map) dbBinlogMapField.get(newManager);
- Assert.assertEquals(originDbBinlogMap.size(), newDbBinlogMap.size());
+ Assertions.assertEquals(originDbBinlogMap.size(), newDbBinlogMap.size());
for (long dbId : frameWork.keySet()) {
List originBinlogList = Lists.newArrayList();
List newBinlogList = Lists.newArrayList();
originDbBinlogMap.get(dbId).getAllBinlogs(originBinlogList);
newDbBinlogMap.get(dbId).getAllBinlogs(newBinlogList);
- Assert.assertEquals(originBinlogList.size(), newBinlogList.size());
+ Assertions.assertEquals(originBinlogList.size(), newBinlogList.size());
for (int i = 0; i < originBinlogList.size(); ++i) {
- Assert.assertEquals(originBinlogList.get(i).getCommitSeq(),
+ Assertions.assertEquals(originBinlogList.get(i).getCommitSeq(),
newBinlogList.get(i).getCommitSeq());
}
}
@@ -346,19 +346,19 @@ public void testReplayGcFromTableLevel() throws NoSuchMethodException, Invocatio
// get origin & new dbbinlog's allbinlogs
Map originDbBinlogMap = (Map) dbBinlogMapField.get(originManager);
Map newDbBinlogMap = (Map) dbBinlogMapField.get(newManager);
- Assert.assertEquals(originDbBinlogMap.size(), newDbBinlogMap.size());
+ Assertions.assertEquals(originDbBinlogMap.size(), newDbBinlogMap.size());
for (long dbId : frameWork.keySet()) {
List originBinlogList = Lists.newArrayList();
List newBinlogList = Lists.newArrayList();
originDbBinlogMap.get(dbId).getAllBinlogs(originBinlogList);
newDbBinlogMap.get(dbId).getAllBinlogs(newBinlogList);
- Assert.assertEquals(originBinlogList.size(), newBinlogList.size());
+ Assertions.assertEquals(originBinlogList.size(), newBinlogList.size());
for (int i = 0; i < originBinlogList.size(); ++i) {
TBinlog originBinlog = originBinlogList.get(i);
TBinlog newBinlog = newBinlogList.get(i);
- Assert.assertEquals(originBinlog.getCommitSeq(), newBinlog.getCommitSeq());
+ Assertions.assertEquals(originBinlog.getCommitSeq(), newBinlog.getCommitSeq());
if (newBinlog.getType() != TBinlogType.DUMMY) {
- Assert.assertTrue(newBinlog.getTimestamp() > timeNow - ttl);
+ Assertions.assertTrue(newBinlog.getTimestamp() > timeNow - ttl);
}
}
}
@@ -411,20 +411,20 @@ public void testReplayGcFromDbLevel() throws NoSuchMethodException, InvocationTa
// get origin & new dbbinlog's allbinlogs
Map originDbBinlogMap = (Map) dbBinlogMapField.get(originManager);
Map newDbBinlogMap = (Map) dbBinlogMapField.get(newManager);
- Assert.assertEquals(originDbBinlogMap.size(), newDbBinlogMap.size());
+ Assertions.assertEquals(originDbBinlogMap.size(), newDbBinlogMap.size());
for (Map.Entry> dbEntry : frameWork.entrySet()) {
long dbId = dbEntry.getKey();
List originBinlogList = Lists.newArrayList();
List newBinlogList = Lists.newArrayList();
originDbBinlogMap.get(dbId).getAllBinlogs(originBinlogList);
newDbBinlogMap.get(dbId).getAllBinlogs(newBinlogList);
- Assert.assertEquals(originBinlogList.size(), newBinlogList.size());
+ Assertions.assertEquals(originBinlogList.size(), newBinlogList.size());
for (int i = 0; i < originBinlogList.size(); ++i) {
TBinlog originBinlog = originBinlogList.get(i);
TBinlog newBinlog = newBinlogList.get(i);
- Assert.assertEquals(originBinlog.getCommitSeq(), newBinlog.getCommitSeq());
+ Assertions.assertEquals(originBinlog.getCommitSeq(), newBinlog.getCommitSeq());
if (newBinlog.getType() != TBinlogType.DUMMY) {
- Assert.assertTrue(newBinlog.getCommitSeq() > timeNow - ttl);
+ Assertions.assertTrue(newBinlog.getCommitSeq() > timeNow - ttl);
}
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/binlog/DbBinlogTest.java b/fe/fe-core/src/test/java/org/apache/doris/binlog/DbBinlogTest.java
index 08c831b1e2c34f..ff08b91b2d3c90 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/binlog/DbBinlogTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/binlog/DbBinlogTest.java
@@ -22,10 +22,10 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
@@ -46,12 +46,12 @@ public class DbBinlogTest {
private int expiredBinlogNum = 3;
private long baseNum = 30000L;
- @Before
+ @BeforeEach
public void setUp() {
// check args valid
- Assert.assertTrue(totalBinlogNum > 0);
- Assert.assertTrue(gcTableNum <= tableNum);
- Assert.assertTrue(expiredBinlogNum <= totalBinlogNum);
+ Assertions.assertTrue(totalBinlogNum > 0);
+ Assertions.assertTrue(gcTableNum <= tableNum);
+ Assertions.assertTrue(expiredBinlogNum <= totalBinlogNum);
// gen tableIds
tableIds = Lists.newArrayList();
@@ -64,7 +64,7 @@ public void setUp() {
.thenAnswer(invocation -> (long) invocation.getArgument(0));
}
- @After
+ @AfterEach
public void tearDown() {
if (mockedBinlogUtils != null) {
mockedBinlogUtils.close();
@@ -120,9 +120,9 @@ public void testTableTtlGcCommonCase() {
// check binlog status
for (TBinlog binlog : testBinlogs) {
if (binlog.getTableIds().get(0) <= baseTableId + gcTableNum) {
- Assert.assertEquals(0, binlog.getTableRef());
+ Assertions.assertEquals(0, binlog.getTableRef());
} else {
- Assert.assertEquals(1, binlog.getTableRef());
+ Assertions.assertEquals(1, binlog.getTableRef());
}
}
@@ -135,18 +135,18 @@ public void testTableTtlGcCommonCase() {
}
long belong = binlog.getBelong();
if (belong < 0) {
- Assert.assertEquals(expiredCommitSeq, binlog.getCommitSeq());
+ Assertions.assertEquals(expiredCommitSeq, binlog.getCommitSeq());
} else if (belong <= maxGcTableId) {
int offset = (int) (belong - baseTableId);
- Assert.assertEquals((long) tableLastCommitInfo[offset], binlog.getCommitSeq());
+ Assertions.assertEquals((long) tableLastCommitInfo[offset], binlog.getCommitSeq());
} else {
- Assert.assertEquals(-1, binlog.getCommitSeq());
+ Assertions.assertEquals(-1, binlog.getCommitSeq());
}
}
// check tombstone
- Assert.assertFalse(tombstone.isDbBinlogTomstone());
- Assert.assertEquals(expiredCommitSeq, tombstone.getCommitSeq());
+ Assertions.assertFalse(tombstone.isDbBinlogTomstone());
+ Assertions.assertEquals(expiredCommitSeq, tombstone.getCommitSeq());
}
@Test
@@ -201,9 +201,9 @@ public void testTableTtlGcBinlogMultiRefCase() {
long unGcTableId = baseTableId + tableNum - 1;
for (TBinlog binlog : testBinlogs) {
if (binlog.getTableIds().contains(unGcTableId)) {
- Assert.assertEquals(1, binlog.getTableRef());
+ Assertions.assertEquals(1, binlog.getTableRef());
} else {
- Assert.assertEquals(0, binlog.getTableRef());
+ Assertions.assertEquals(0, binlog.getTableRef());
}
}
}
@@ -251,9 +251,9 @@ public void testTableCommitSeqGc() {
// check binlog status
for (TBinlog binlog : testBinlogs) {
if (binlog.getTimestamp() <= expiredTime) {
- Assert.assertEquals(0, binlog.getTableRef());
+ Assertions.assertEquals(0, binlog.getTableRef());
} else {
- Assert.assertTrue(binlog.getTableRef() != 0);
+ Assertions.assertTrue(binlog.getTableRef() != 0);
}
}
}
@@ -288,15 +288,15 @@ public void testAddBinlog() throws NoSuchFieldException, IllegalAccessException
TreeSet allbinlogs = (TreeSet) allBinlogsField.get(dbBinlog);
Map tableBinlogMap = (Map) tableBinlogMapField.get(dbBinlog);
- Assert.assertTrue(allbinlogs.contains(binlog));
+ Assertions.assertTrue(allbinlogs.contains(binlog));
switch (type) {
case CREATE_TABLE:
case DROP_TABLE: {
- Assert.assertTrue(tableBinlogMap.isEmpty());
+ Assertions.assertTrue(tableBinlogMap.isEmpty());
break;
}
default: {
- Assert.assertTrue(tableBinlogMap.containsKey(baseTableId));
+ Assertions.assertTrue(tableBinlogMap.containsKey(baseTableId));
break;
}
}
@@ -351,20 +351,20 @@ public void testDbAndTableGcWithDisable() {
long tableId = binlog.getTableIds().get(0);
if (tableId <= maxGcTableId) {
// For disabled tables, all binlogs should be cleared
- Assert.assertEquals(0, binlog.getTableRef());
+ Assertions.assertEquals(0, binlog.getTableRef());
} else {
// For enabled tables, only expired binlogs should be cleared
if (binlog.getTimestamp() <= expiredTime) {
- Assert.assertEquals(0, binlog.getTableRef());
+ Assertions.assertEquals(0, binlog.getTableRef());
} else {
- Assert.assertEquals(1, binlog.getTableRef());
+ Assertions.assertEquals(1, binlog.getTableRef());
}
}
}
// check tombstone
- Assert.assertFalse(tombstone.isDbBinlogTomstone());
- Assert.assertEquals(baseNum + totalBinlogNum - 1, tombstone.getCommitSeq());
+ Assertions.assertFalse(tombstone.isDbBinlogTomstone());
+ Assertions.assertEquals(baseNum + totalBinlogNum - 1, tombstone.getCommitSeq());
}
@Test
@@ -410,14 +410,14 @@ public void testDbAndTableGcWithEnable() {
// check binlog status - only expired binlogs should be cleared
for (TBinlog binlog : testBinlogs) {
if (binlog.getTimestamp() <= expiredTime) {
- Assert.assertEquals(0, binlog.getTableRef());
+ Assertions.assertEquals(0, binlog.getTableRef());
} else {
- Assert.assertEquals(1, binlog.getTableRef());
+ Assertions.assertEquals(1, binlog.getTableRef());
}
}
// check tombstone
- Assert.assertTrue(tombstone.isDbBinlogTomstone());
- Assert.assertEquals(expiredTime, tombstone.getCommitSeq());
+ Assertions.assertTrue(tombstone.isDbBinlogTomstone());
+ Assertions.assertEquals(expiredTime, tombstone.getCommitSeq());
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/binlog/TableBinlogTest.java b/fe/fe-core/src/test/java/org/apache/doris/binlog/TableBinlogTest.java
index 7546d6c952dd94..3a8b8e927bed6e 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/binlog/TableBinlogTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/binlog/TableBinlogTest.java
@@ -21,9 +21,9 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
@@ -38,10 +38,10 @@ public class TableBinlogTest {
private int expiredBinlogNum = 3;
private long baseNum = 30000L;
- @Before
+ @BeforeEach
public void setUp() {
// check args valid
- Assert.assertTrue(expiredBinlogNum <= totalBinlogNum);
+ Assertions.assertTrue(expiredBinlogNum <= totalBinlogNum);
}
@Test
@@ -80,19 +80,19 @@ public void testTtlGc() {
// check binlog status
for (TBinlog binlog : testBinlogs) {
if (binlog.getTimestamp() <= expiredTime) {
- Assert.assertEquals(0, binlog.getTableRef());
+ Assertions.assertEquals(0, binlog.getTableRef());
} else {
- Assert.assertEquals(1, binlog.getTableRef());
+ Assertions.assertEquals(1, binlog.getTableRef());
}
}
// check tombstone
- Assert.assertFalse(tombstone.isDbBinlogTomstone());
- Assert.assertEquals(expiredTime, tombstone.getCommitSeq());
+ Assertions.assertFalse(tombstone.isDbBinlogTomstone());
+ Assertions.assertEquals(expiredTime, tombstone.getCommitSeq());
// check dummy
TBinlog dummy = tableBinlog.getDummyBinlog();
- Assert.assertEquals(expiredTime, dummy.getCommitSeq());
+ Assertions.assertEquals(expiredTime, dummy.getCommitSeq());
}
}
@@ -126,19 +126,19 @@ public void testCommitSeqGc() {
// check binlog status
for (TBinlog binlog : testBinlogs) {
if (binlog.getTimestamp() <= expiredCommitSeq) {
- Assert.assertEquals(0, binlog.getTableRef());
+ Assertions.assertEquals(0, binlog.getTableRef());
} else {
- Assert.assertEquals(1, binlog.getTableRef());
+ Assertions.assertEquals(1, binlog.getTableRef());
}
}
// check tombstone
- Assert.assertFalse(tombstone.isDbBinlogTomstone());
- Assert.assertEquals(expiredCommitSeq, tombstone.getCommitSeq());
+ Assertions.assertFalse(tombstone.isDbBinlogTomstone());
+ Assertions.assertEquals(expiredCommitSeq, tombstone.getCommitSeq());
// check dummy
TBinlog dummy = tableBinlog.getDummyBinlog();
- Assert.assertEquals(expiredCommitSeq, dummy.getCommitSeq());
+ Assertions.assertEquals(expiredCommitSeq, dummy.getCommitSeq());
}
@Test
@@ -182,16 +182,16 @@ public void testTableGcBinlogWithDisable() {
// check binlog status - all binlogs should be cleared when table binlog is disabled
for (TBinlog binlog : testBinlogs) {
- Assert.assertEquals(0, binlog.getTableRef());
+ Assertions.assertEquals(0, binlog.getTableRef());
}
// check tombstone
- Assert.assertFalse(tombstone.isDbBinlogTomstone());
- Assert.assertEquals(baseNum + totalBinlogNum - 1, tombstone.getCommitSeq());
+ Assertions.assertFalse(tombstone.isDbBinlogTomstone());
+ Assertions.assertEquals(baseNum + totalBinlogNum - 1, tombstone.getCommitSeq());
// check dummy - should have the last commitSeq
TBinlog dummy = tableBinlog.getDummyBinlog();
- Assert.assertEquals(baseNum + totalBinlogNum - 1, dummy.getCommitSeq());
+ Assertions.assertEquals(baseNum + totalBinlogNum - 1, dummy.getCommitSeq());
}
}
@@ -237,19 +237,19 @@ public void testTableGcBinlogWithEnable() {
// check binlog status - only expired binlogs should be cleared
for (TBinlog binlog : testBinlogs) {
if (binlog.getTimestamp() <= expiredTime) {
- Assert.assertEquals(0, binlog.getTableRef());
+ Assertions.assertEquals(0, binlog.getTableRef());
} else {
- Assert.assertEquals(1, binlog.getTableRef());
+ Assertions.assertEquals(1, binlog.getTableRef());
}
}
// check tombstone
- Assert.assertFalse(tombstone.isDbBinlogTomstone());
- Assert.assertEquals(expiredTime, tombstone.getCommitSeq());
+ Assertions.assertFalse(tombstone.isDbBinlogTomstone());
+ Assertions.assertEquals(expiredTime, tombstone.getCommitSeq());
// check dummy - should have the expiredTime as commitSeq
TBinlog dummy = tableBinlog.getDummyBinlog();
- Assert.assertEquals(expiredTime, dummy.getCommitSeq());
+ Assertions.assertEquals(expiredTime, dummy.getCommitSeq());
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/blockrule/SqlBlockRuleMgrTest.java b/fe/fe-core/src/test/java/org/apache/doris/blockrule/SqlBlockRuleMgrTest.java
index a87fcf1a84bdda..cb66b2a52f33ce 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/blockrule/SqlBlockRuleMgrTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/blockrule/SqlBlockRuleMgrTest.java
@@ -21,16 +21,16 @@
import org.apache.doris.metric.MetricRepo;
import org.apache.doris.persist.gson.GsonUtils;
-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.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class SqlBlockRuleMgrTest {
- @BeforeClass
+ @BeforeAll
public static void setUp() {
MetricRepo.init();
}
@@ -38,14 +38,14 @@ public static void setUp() {
@Test
public void testToInfoString() {
SqlBlockRuleMgr mgr = new SqlBlockRuleMgr();
- Assert.assertTrue(mgr.getNameToSqlBlockRuleMap() instanceof ConcurrentHashMap);
+ Assertions.assertTrue(mgr.getNameToSqlBlockRuleMap() instanceof ConcurrentHashMap);
SqlBlockRule rule = new SqlBlockRule();
mgr.getNameToSqlBlockRuleMap().put("r1", rule);
String mgrJson = GsonUtils.GSON.toJson(mgr);
SqlBlockRuleMgr mgrNew = GsonUtils.GSON.fromJson(mgrJson, SqlBlockRuleMgr.class);
Map nameToSqlBlockRuleMap = mgrNew.getNameToSqlBlockRuleMap();
- Assert.assertTrue(nameToSqlBlockRuleMap instanceof ConcurrentHashMap);
- Assert.assertTrue(nameToSqlBlockRuleMap.containsKey("r1"));
+ Assertions.assertTrue(nameToSqlBlockRuleMap instanceof ConcurrentHashMap);
+ Assertions.assertTrue(nameToSqlBlockRuleMap.containsKey("r1"));
}
@Test
@@ -54,7 +54,7 @@ public void testRuleSerializeRequirePartitionFilter() {
true, true, true);
String json = GsonUtils.GSON.toJson(rule);
SqlBlockRule roundTrip = GsonUtils.GSON.fromJson(json, SqlBlockRule.class);
- Assert.assertTrue(roundTrip.getRequirePartitionFilter());
+ Assertions.assertTrue(roundTrip.getRequirePartitionFilter());
}
@Test
@@ -62,22 +62,22 @@ public void testShowInfoUseNumericBooleanForRequirePartitionFilter() {
SqlBlockRule enabledRule = new SqlBlockRule("r1", "NULL", "NULL", 0L, 0L, 0L,
true, true, true);
List enabledShowInfo = enabledRule.getShowInfo();
- Assert.assertEquals(9, enabledShowInfo.size());
- Assert.assertEquals("1", enabledShowInfo.get(8));
+ Assertions.assertEquals(9, enabledShowInfo.size());
+ Assertions.assertEquals("1", enabledShowInfo.get(8));
SqlBlockRule disabledRule = new SqlBlockRule("r2", "NULL", "NULL", 0L, 0L, 0L,
false, true, true);
List disabledShowInfo = disabledRule.getShowInfo();
- Assert.assertEquals("0", disabledShowInfo.get(8));
+ Assertions.assertEquals("0", disabledShowInfo.get(8));
}
@Test
public void testConstructorPlaceRequirePartitionFilterBeforeGlobal() {
SqlBlockRule rule = new SqlBlockRule("r1", "NULL", "NULL", 0L, 0L, 0L,
true, false, true);
- Assert.assertTrue(rule.getRequirePartitionFilter());
- Assert.assertFalse(rule.getGlobal());
- Assert.assertTrue(rule.getEnable());
+ Assertions.assertTrue(rule.getRequirePartitionFilter());
+ Assertions.assertFalse(rule.getGlobal());
+ Assertions.assertTrue(rule.getEnable());
}
@Test
@@ -86,9 +86,9 @@ public void testRequirePartitionFilterBlocksPartitionedScanWithoutFilter() {
SqlBlockRule rule = new SqlBlockRule("r1", "NULL", "NULL", 0L, 0L, 0L,
true, true, true);
- AnalysisException exception = Assert.assertThrows(AnalysisException.class,
+ AnalysisException exception = Assertions.assertThrows(AnalysisException.class,
() -> mgr.checkLimitations(rule, 2L, 3L, 4L, true, false));
- Assert.assertTrue(exception.getMessage().contains("sql hits sql block rule: r1, missing partition filter"));
+ Assertions.assertTrue(exception.getMessage().contains("sql hits sql block rule: r1, missing partition filter"));
}
@Test
diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/AIResourceTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/AIResourceTest.java
index 467a0953926e4b..70d37bf5ebf740 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/AIResourceTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/AIResourceTest.java
@@ -33,9 +33,9 @@
import com.google.common.collect.ImmutableMap;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
@@ -62,7 +62,7 @@ public class AIResourceTest {
private String retryDelaySecond;
private Map aiProperties;
- @Before
+ @BeforeEach
public void setUp() {
name = "openai-gpt";
type = "ai";
@@ -102,20 +102,20 @@ public void testFromCommand() throws UserException {
createResourceCommand.getInfo().validate();
AIResource aiResource = (AIResource) Resource.fromCommand(createResourceCommand);
- Assert.assertEquals(name, aiResource.getName());
- Assert.assertEquals(type, aiResource.getType().name().toLowerCase());
- Assert.assertEquals(endpoint, aiResource.getProperty(AIProperties.ENDPOINT));
- Assert.assertEquals(providerType.toUpperCase(), aiResource.getProperty(AIProperties.PROVIDER_TYPE));
- Assert.assertEquals(apiKey, aiResource.getProperty(AIProperties.API_KEY));
- Assert.assertEquals(modelName, aiResource.getProperty(AIProperties.MODEL_NAME));
-
- Assert.assertEquals(AIProperties.DEFAULT_TEMPERATURE,
+ Assertions.assertEquals(name, aiResource.getName());
+ Assertions.assertEquals(type, aiResource.getType().name().toLowerCase());
+ Assertions.assertEquals(endpoint, aiResource.getProperty(AIProperties.ENDPOINT));
+ Assertions.assertEquals(providerType.toUpperCase(), aiResource.getProperty(AIProperties.PROVIDER_TYPE));
+ Assertions.assertEquals(apiKey, aiResource.getProperty(AIProperties.API_KEY));
+ Assertions.assertEquals(modelName, aiResource.getProperty(AIProperties.MODEL_NAME));
+
+ Assertions.assertEquals(AIProperties.DEFAULT_TEMPERATURE,
aiResource.getProperty(AIProperties.TEMPERATURE));
- Assert.assertEquals(AIProperties.DEFAULT_MAX_TOKEN,
+ Assertions.assertEquals(AIProperties.DEFAULT_MAX_TOKEN,
aiResource.getProperty(AIProperties.MAX_TOKEN));
- Assert.assertEquals(AIProperties.DEFAULT_MAX_RETRIES,
+ Assertions.assertEquals(AIProperties.DEFAULT_MAX_RETRIES,
aiResource.getProperty(AIProperties.MAX_RETRIES));
- Assert.assertEquals(AIProperties.DEFAULT_RETRY_DELAY_SECOND,
+ Assertions.assertEquals(AIProperties.DEFAULT_RETRY_DELAY_SECOND,
aiResource.getProperty(AIProperties.RETRY_DELAY_SECOND));
// with no default settings
@@ -129,16 +129,16 @@ public void testFromCommand() throws UserException {
createResourceCommand.getInfo().validate();
aiResource = (AIResource) Resource.fromCommand(createResourceCommand);
- Assert.assertEquals(name, aiResource.getName());
- Assert.assertEquals(type, aiResource.getType().name().toLowerCase());
- Assert.assertEquals(endpoint, aiResource.getProperty(AIProperties.ENDPOINT));
- Assert.assertEquals(providerType.toUpperCase(), aiResource.getProperty(AIProperties.PROVIDER_TYPE));
- Assert.assertEquals(apiKey, aiResource.getProperty(AIProperties.API_KEY));
- Assert.assertEquals(modelName, aiResource.getProperty(AIProperties.MODEL_NAME));
- Assert.assertEquals(temperature, aiResource.getProperty(AIProperties.TEMPERATURE));
- Assert.assertEquals(maxToken, aiResource.getProperty(AIProperties.MAX_TOKEN));
- Assert.assertEquals(maxRetries, aiResource.getProperty(AIProperties.MAX_RETRIES));
- Assert.assertEquals(retryDelaySecond, aiResource.getProperty(AIProperties.RETRY_DELAY_SECOND));
+ Assertions.assertEquals(name, aiResource.getName());
+ Assertions.assertEquals(type, aiResource.getType().name().toLowerCase());
+ Assertions.assertEquals(endpoint, aiResource.getProperty(AIProperties.ENDPOINT));
+ Assertions.assertEquals(providerType.toUpperCase(), aiResource.getProperty(AIProperties.PROVIDER_TYPE));
+ Assertions.assertEquals(apiKey, aiResource.getProperty(AIProperties.API_KEY));
+ Assertions.assertEquals(modelName, aiResource.getProperty(AIProperties.MODEL_NAME));
+ Assertions.assertEquals(temperature, aiResource.getProperty(AIProperties.TEMPERATURE));
+ Assertions.assertEquals(maxToken, aiResource.getProperty(AIProperties.MAX_TOKEN));
+ Assertions.assertEquals(maxRetries, aiResource.getProperty(AIProperties.MAX_RETRIES));
+ Assertions.assertEquals(retryDelaySecond, aiResource.getProperty(AIProperties.RETRY_DELAY_SECOND));
}
}
@@ -165,57 +165,61 @@ public void testAnthropic() throws UserException {
createResourceCommand.getInfo().validate();
AIResource aiResource = (AIResource) Resource.fromCommand(createResourceCommand);
- Assert.assertEquals("anthropic-claude", aiResource.getName());
- Assert.assertEquals("ANTHROPIC", aiResource.getProperty(AIProperties.PROVIDER_TYPE));
- Assert.assertEquals("https://api.anthropic.com/v1/messages",
+ Assertions.assertEquals("anthropic-claude", aiResource.getName());
+ Assertions.assertEquals("ANTHROPIC", aiResource.getProperty(AIProperties.PROVIDER_TYPE));
+ Assertions.assertEquals("https://api.anthropic.com/v1/messages",
aiResource.getProperty(AIProperties.ENDPOINT));
- Assert.assertEquals("claude-opus-4-20250514", aiResource.getProperty(AIProperties.MODEL_NAME));
- Assert.assertEquals("2023-06-01", aiResource.getProperty(AIProperties.ANTHROPIC_VERSION));
+ Assertions.assertEquals("claude-opus-4-20250514", aiResource.getProperty(AIProperties.MODEL_NAME));
+ Assertions.assertEquals("2023-06-01", aiResource.getProperty(AIProperties.ANTHROPIC_VERSION));
}
}
- @Test(expected = DdlException.class)
+ @Test
public void testAbnormalResource() throws UserException {
- try (MockedStatic mockedEnv = Mockito.mockStatic(Env.class)) {
- Env env = Mockito.mock(Env.class);
- EditLog editLog = Mockito.mock(EditLog.class);
- AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
- mockedEnv.when(Env::getCurrentEnv).thenReturn(env);
- Mockito.when(env.getEditLog()).thenReturn(editLog);
- Mockito.when(env.getAccessManager()).thenReturn(accessManager);
- Mockito.when(accessManager.checkGlobalPriv(Mockito.nullable(ConnectContext.class), Mockito.eq(PrivPredicate.ADMIN)))
- .thenReturn(true);
-
- aiProperties.remove("ai.endpoint");
- CreateResourceCommand createResourceCommand = new CreateResourceCommand(
- new CreateResourceInfo(true, false, name, ImmutableMap.copyOf(aiProperties)));
- createResourceCommand.getInfo().validate();
-
- Resource.fromCommand(createResourceCommand);
- }
+ Assertions.assertThrows(DdlException.class, () -> {
+ try (MockedStatic mockedEnv = Mockito.mockStatic(Env.class)) {
+ Env env = Mockito.mock(Env.class);
+ EditLog editLog = Mockito.mock(EditLog.class);
+ AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
+ mockedEnv.when(Env::getCurrentEnv).thenReturn(env);
+ Mockito.when(env.getEditLog()).thenReturn(editLog);
+ Mockito.when(env.getAccessManager()).thenReturn(accessManager);
+ Mockito.when(accessManager.checkGlobalPriv(Mockito.nullable(ConnectContext.class), Mockito.eq(PrivPredicate.ADMIN)))
+ .thenReturn(true);
+
+ aiProperties.remove("ai.endpoint");
+ CreateResourceCommand createResourceCommand = new CreateResourceCommand(
+ new CreateResourceInfo(true, false, name, ImmutableMap.copyOf(aiProperties)));
+ createResourceCommand.getInfo().validate();
+
+ Resource.fromCommand(createResourceCommand);
+ }
+ });
}
- @Test(expected = DdlException.class)
+ @Test
public void testInvalidProvider() throws UserException {
- try (MockedStatic mockedEnv = Mockito.mockStatic(Env.class)) {
- Env env = Mockito.mock(Env.class);
- EditLog editLog = Mockito.mock(EditLog.class);
- AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
- mockedEnv.when(Env::getCurrentEnv).thenReturn(env);
- Mockito.when(env.getEditLog()).thenReturn(editLog);
- Mockito.when(env.getAccessManager()).thenReturn(accessManager);
- Mockito.when(accessManager.checkGlobalPriv(Mockito.nullable(ConnectContext.class), Mockito.eq(PrivPredicate.ADMIN)))
- .thenReturn(true);
-
- // Invalid provider type
- aiProperties.put("ai.provider_type", "invalid_provider");
-
- CreateResourceCommand createResourceCommand = new CreateResourceCommand(
- new CreateResourceInfo(true, false, name, ImmutableMap.copyOf(aiProperties)));
- createResourceCommand.getInfo().validate();
-
- Resource.fromCommand(createResourceCommand);
- }
+ Assertions.assertThrows(DdlException.class, () -> {
+ try (MockedStatic mockedEnv = Mockito.mockStatic(Env.class)) {
+ Env env = Mockito.mock(Env.class);
+ EditLog editLog = Mockito.mock(EditLog.class);
+ AccessControllerManager accessManager = Mockito.mock(AccessControllerManager.class);
+ mockedEnv.when(Env::getCurrentEnv).thenReturn(env);
+ Mockito.when(env.getEditLog()).thenReturn(editLog);
+ Mockito.when(env.getAccessManager()).thenReturn(accessManager);
+ Mockito.when(accessManager.checkGlobalPriv(Mockito.nullable(ConnectContext.class), Mockito.eq(PrivPredicate.ADMIN)))
+ .thenReturn(true);
+
+ // Invalid provider type
+ aiProperties.put("ai.provider_type", "invalid_provider");
+
+ CreateResourceCommand createResourceCommand = new CreateResourceCommand(
+ new CreateResourceInfo(true, false, name, ImmutableMap.copyOf(aiProperties)));
+ createResourceCommand.getInfo().validate();
+
+ Resource.fromCommand(createResourceCommand);
+ }
+ });
}
@Test
@@ -250,17 +254,17 @@ public void testSerialization() throws Exception {
AIResource rAiResource1 = (AIResource) Resource.read(aiDis);
AIResource rAiResource2 = (AIResource) Resource.read(aiDis);
- Assert.assertEquals("ai_1", rAiResource1.getName());
- Assert.assertEquals("ai_2", rAiResource2.getName());
-
- Assert.assertEquals(rAiResource2.getProperty(AIProperties.ENDPOINT), endpoint);
- Assert.assertEquals(rAiResource2.getProperty(AIProperties.PROVIDER_TYPE), providerType.toUpperCase());
- Assert.assertEquals(rAiResource2.getProperty(AIProperties.API_KEY), apiKey);
- Assert.assertEquals(rAiResource2.getProperty(AIProperties.MODEL_NAME), modelName);
- Assert.assertEquals(rAiResource2.getProperty(AIProperties.TEMPERATURE), AIProperties.DEFAULT_TEMPERATURE);
- Assert.assertEquals(rAiResource2.getProperty(AIProperties.MAX_TOKEN), AIProperties.DEFAULT_MAX_TOKEN);
- Assert.assertEquals(rAiResource2.getProperty(AIProperties.MAX_RETRIES), AIProperties.DEFAULT_MAX_RETRIES);
- Assert.assertEquals(rAiResource2.getProperty(AIProperties.RETRY_DELAY_SECOND),
+ Assertions.assertEquals("ai_1", rAiResource1.getName());
+ Assertions.assertEquals("ai_2", rAiResource2.getName());
+
+ Assertions.assertEquals(rAiResource2.getProperty(AIProperties.ENDPOINT), endpoint);
+ Assertions.assertEquals(rAiResource2.getProperty(AIProperties.PROVIDER_TYPE), providerType.toUpperCase());
+ Assertions.assertEquals(rAiResource2.getProperty(AIProperties.API_KEY), apiKey);
+ Assertions.assertEquals(rAiResource2.getProperty(AIProperties.MODEL_NAME), modelName);
+ Assertions.assertEquals(rAiResource2.getProperty(AIProperties.TEMPERATURE), AIProperties.DEFAULT_TEMPERATURE);
+ Assertions.assertEquals(rAiResource2.getProperty(AIProperties.MAX_TOKEN), AIProperties.DEFAULT_MAX_TOKEN);
+ Assertions.assertEquals(rAiResource2.getProperty(AIProperties.MAX_RETRIES), AIProperties.DEFAULT_MAX_RETRIES);
+ Assertions.assertEquals(rAiResource2.getProperty(AIProperties.RETRY_DELAY_SECOND),
AIProperties.DEFAULT_RETRY_DELAY_SECOND);
// 3. delete
@@ -286,8 +290,8 @@ public void testModifyProperties() throws Exception {
modify.put("ai.temperature", "0.9");
aiResource.modifyProperties(modify);
- Assert.assertEquals("new_api_key", aiResource.getProperty(AIProperties.API_KEY));
- Assert.assertEquals("0.9", aiResource.getProperty(AIProperties.TEMPERATURE));
+ Assertions.assertEquals("new_api_key", aiResource.getProperty(AIProperties.API_KEY));
+ Assertions.assertEquals("0.9", aiResource.getProperty(AIProperties.TEMPERATURE));
}
@Test
@@ -337,9 +341,9 @@ public void testDifferentProviders() throws DdlException {
AIResource localResource = new AIResource("local-resource");
localResource.setProperties(ImmutableMap.copyOf(localProps));
- Assert.assertEquals("OPENAI", openaiResource.getProperty(AIProperties.PROVIDER_TYPE));
- Assert.assertEquals("GEMINI", geminiResource.getProperty(AIProperties.PROVIDER_TYPE));
- Assert.assertEquals("ANTHROPIC", anthropicResource.getProperty(AIProperties.PROVIDER_TYPE));
- Assert.assertEquals("LOCAL", localResource.getProperty(AIProperties.PROVIDER_TYPE));
+ Assertions.assertEquals("OPENAI", openaiResource.getProperty(AIProperties.PROVIDER_TYPE));
+ Assertions.assertEquals("GEMINI", geminiResource.getProperty(AIProperties.PROVIDER_TYPE));
+ Assertions.assertEquals("ANTHROPIC", anthropicResource.getProperty(AIProperties.PROVIDER_TYPE));
+ Assertions.assertEquals("LOCAL", localResource.getProperty(AIProperties.PROVIDER_TYPE));
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/BackendTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/BackendTest.java
index a2f4b769ebd0a4..7a036063410692 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/BackendTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/BackendTest.java
@@ -26,10 +26,10 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -57,7 +57,7 @@ public class BackendTest {
private FakeEnv fakeEnv;
private FakeEditLog fakeEditLog;
- @Before
+ @BeforeEach
public void setUp() {
env = AccessTestUtil.fetchAdminCatalog();
@@ -72,7 +72,7 @@ public void setUp() {
backend.updateOnce(bePort, httpPort, beRpcPort);
}
- @After
+ @AfterEach
public void tearDown() {
if (fakeEnv != null) {
fakeEnv.close();
@@ -84,24 +84,24 @@ public void tearDown() {
@Test
public void getMethodTest() {
- Assert.assertEquals(backendId, backend.getId());
- Assert.assertEquals(host, backend.getHost());
- Assert.assertEquals(heartbeatPort, backend.getHeartbeatPort());
- Assert.assertEquals(bePort, backend.getBePort());
+ Assertions.assertEquals(backendId, backend.getId());
+ Assertions.assertEquals(host, backend.getHost());
+ Assertions.assertEquals(heartbeatPort, backend.getHeartbeatPort());
+ Assertions.assertEquals(bePort, backend.getBePort());
// set new port
int newBePort = 31235;
int newHttpPort = 31237;
backend.updateOnce(newBePort, newHttpPort, beRpcPort);
- Assert.assertEquals(newBePort, backend.getBePort());
+ Assertions.assertEquals(newBePort, backend.getBePort());
// check alive
- Assert.assertTrue(backend.isAlive());
+ Assertions.assertTrue(backend.isAlive());
}
@Test
public void testLocationTagIsSafelyPublished() throws NoSuchFieldException {
- Assert.assertTrue(Modifier.isVolatile(Backend.class.getDeclaredField("locationTag").getModifiers()));
+ Assertions.assertTrue(Modifier.isVolatile(Backend.class.getDeclaredField("locationTag").getModifiers()));
}
@Test
@@ -118,17 +118,17 @@ public void diskInfoTest() {
// first update
backend.updateDisks(diskInfos);
- Assert.assertEquals(disk1.getDiskTotalCapacity() + disk2.getDiskTotalCapacity(),
+ Assertions.assertEquals(disk1.getDiskTotalCapacity() + disk2.getDiskTotalCapacity(),
backend.getTotalCapacityB());
- Assert.assertEquals(1, backend.getAvailableCapacityB());
+ Assertions.assertEquals(1, backend.getAvailableCapacityB());
// second update
diskInfos.remove(disk1.getRootPath());
backend.updateDisks(diskInfos);
- Assert.assertEquals(disk2.getDiskTotalCapacity(), backend.getTotalCapacityB());
- Assert.assertEquals(disk2.getDiskAvailableCapacity() + 1, backend.getAvailableCapacityB());
- Assert.assertFalse(backend.hasSpecifiedStorageMedium(TStorageMedium.SSD));
- Assert.assertTrue(backend.hasSpecifiedStorageMedium(TStorageMedium.HDD));
+ Assertions.assertEquals(disk2.getDiskTotalCapacity(), backend.getTotalCapacityB());
+ Assertions.assertEquals(disk2.getDiskAvailableCapacity() + 1, backend.getAvailableCapacityB());
+ Assertions.assertFalse(backend.hasSpecifiedStorageMedium(TStorageMedium.SSD));
+ Assertions.assertTrue(backend.hasSpecifiedStorageMedium(TStorageMedium.HDD));
}
@Test
@@ -169,44 +169,44 @@ public void testSerialization() throws Exception {
for (int count = 0; count < 200; ++count) {
Backend backend = Backend.read(dis);
list2.add(backend);
- Assert.assertEquals(count, backend.getId());
- Assert.assertEquals("10.120.22.32" + count, backend.getHost());
+ Assertions.assertEquals(count, backend.getId());
+ Assertions.assertEquals("10.120.22.32" + count, backend.getHost());
}
// check isAlive
Backend backend100 = list2.get(100);
- Assert.assertTrue(backend100.isAlive());
+ Assertions.assertTrue(backend100.isAlive());
// check disksRef
ImmutableMap backend100DiskRef = backend100.getDisks();
- Assert.assertEquals(2, backend100DiskRef.size());
- Assert.assertTrue(backend100DiskRef.containsKey("disk1"));
- Assert.assertTrue(backend100DiskRef.containsKey("disk2"));
+ Assertions.assertEquals(2, backend100DiskRef.size());
+ Assertions.assertTrue(backend100DiskRef.containsKey("disk1"));
+ Assertions.assertTrue(backend100DiskRef.containsKey("disk2"));
DiskInfo backend100DiskInfo1 = backend100DiskRef.get("disk1");
- Assert.assertEquals("/disk1", backend100DiskInfo1.getRootPath());
+ Assertions.assertEquals("/disk1", backend100DiskInfo1.getRootPath());
DiskInfo backend100DiskInfo2 = backend100DiskRef.get("disk2");
- Assert.assertEquals("/disk2", backend100DiskInfo2.getRootPath());
+ Assertions.assertEquals("/disk2", backend100DiskInfo2.getRootPath());
// check backend status
Backend.BackendStatus backend100BackendStatus = backend100.getBackendStatus();
- Assert.assertEquals(100, backend100BackendStatus.lastStreamLoadTime);
+ Assertions.assertEquals(100, backend100BackendStatus.lastStreamLoadTime);
for (int count = 0; count < 200; count++) {
- Assert.assertEquals(list1.get(count), list2.get(count));
+ Assertions.assertEquals(list1.get(count), list2.get(count));
}
- Assert.assertNotEquals(list1.get(1), list1.get(2));
- Assert.assertNotEquals(list1.get(1), this);
- Assert.assertEquals(list1.get(1), list1.get(1));
+ Assertions.assertNotEquals(list1.get(1), list1.get(2));
+ Assertions.assertNotEquals(list1.get(1), this);
+ Assertions.assertEquals(list1.get(1), list1.get(1));
Backend back1 = new Backend(1, "a", 1);
back1.updateOnce(1, 1, 1);
Backend back2 = new Backend(2, "a", 1);
back2.updateOnce(1, 1, 1);
- Assert.assertNotEquals(back1, back2);
+ Assertions.assertNotEquals(back1, back2);
back1 = new Backend(1, "a", 1);
back1.updateOnce(1, 1, 1);
back2 = new Backend(1, "b", 1);
back2.updateOnce(1, 1, 1);
- Assert.assertNotEquals(back1, back2);
+ Assertions.assertNotEquals(back1, back2);
back1 = new Backend(1, "a", 1);
back1.updateOnce(1, 1, 1);
@@ -216,10 +216,10 @@ public void testSerialization() throws Exception {
tagMap.put(Tag.TYPE_LOCATION, "l1");
tagMap.put("compute", "c1");
back2.setTagMap(tagMap);
- Assert.assertNotEquals(back1, back2);
+ Assertions.assertNotEquals(back1, back2);
- Assert.assertTrue(back1.toString().contains("tags: {location=default}"));
- Assert.assertEquals("{\"compute\" : \"c1\", \"location\" : \"l1\"}", back2.getTagMapString());
+ Assertions.assertTrue(back1.toString().contains("tags: {location=default}"));
+ Assertions.assertEquals("{\"compute\" : \"c1\", \"location\" : \"l1\"}", back2.getTagMapString());
// 3. delete files
dis.close();
diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableIndexTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableIndexTest.java
index 5b78103f71e85c..017e84981f9cba 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableIndexTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableIndexTest.java
@@ -22,8 +22,8 @@
import org.apache.doris.meta.MetaContext;
import com.google.common.collect.Maps;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -41,16 +41,16 @@ public void testGroupId() {
GroupId groupId1 = new GroupId(1000, 2000);
GroupId groupId2 = new GroupId(1000, 2000);
Map map = Maps.newHashMap();
- Assert.assertEquals(groupId1, groupId2);
- Assert.assertTrue(groupId1.hashCode() == groupId2.hashCode());
+ Assertions.assertEquals(groupId1, groupId2);
+ Assertions.assertTrue(groupId1.hashCode() == groupId2.hashCode());
map.put(groupId1, 1000L);
- Assert.assertTrue(map.containsKey(groupId2));
+ Assertions.assertTrue(map.containsKey(groupId2));
Set balancingGroups = new CopyOnWriteArraySet();
balancingGroups.add(groupId1);
- Assert.assertTrue(balancingGroups.size() == 1);
+ Assertions.assertTrue(balancingGroups.size() == 1);
balancingGroups.remove(groupId2);
- Assert.assertTrue(balancingGroups.isEmpty());
+ Assertions.assertTrue(balancingGroups.isEmpty());
}
@Test
@@ -73,7 +73,7 @@ public void testSerialization() throws Exception {
DataInputStream dis = new DataInputStream(Files.newInputStream(path));
ColocateTableIndex.GroupId rGroupId = ColocateTableIndex.GroupId.read(dis);
- Assert.assertEquals(groupId, rGroupId);
+ Assertions.assertEquals(groupId, rGroupId);
// 3. delete files
dis.close();
diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableTest.java
index ef96012d64ef5d..f03ffec9111fda 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableTest.java
@@ -37,14 +37,12 @@
import com.google.common.collect.Multimap;
import com.google.common.collect.Table;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.io.File;
@@ -64,23 +62,20 @@ public class ColocateTableTest {
private static String tableName2 = "t2";
private static String groupName = "group1";
- @Rule
- public ExpectedException expectedEx = ExpectedException.none();
-
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UtFrameUtils.createDorisCluster(runningDir);
connectContext = UtFrameUtils.createDefaultCtx();
}
- @AfterClass
+ @AfterAll
public static void tearDown() {
File file = new File(runningDir);
file.delete();
}
- @Before
+ @BeforeEach
public void createDb() throws Exception {
String createDbStmtStr = "create database " + dbName;
NereidsParser nereidsParser = new NereidsParser();
@@ -92,7 +87,7 @@ public void createDb() throws Exception {
Env.getCurrentEnv().setColocateTableIndex(new ColocateTableIndex());
}
- @After
+ @AfterEach
public void dropDb() throws Exception {
String dropDbStmtStr = "drop database " + dbName;
NereidsParser nereidsParser = new NereidsParser();
@@ -131,7 +126,7 @@ private static void alterColocateGroup(String sql) throws Exception {
if (parsed instanceof AlterColocateGroupCommand) {
((AlterColocateGroupCommand) parsed).run(connectContext, stmtExecutor);
} else {
- Assert.fail("Expected AlterColocateGroupCommand, but parsed: " + parsed.getClass().getSimpleName());
+ Assertions.fail("Expected AlterColocateGroupCommand, but parsed: " + parsed.getClass().getSimpleName());
}
}
@@ -180,29 +175,29 @@ public void testCreateOneTable() throws Exception {
Database db = Env.getCurrentInternalCatalog().getDbOrMetaException(fullDbName);
long tableId = db.getTableOrMetaException(tableName1).getId();
- Assert.assertEquals(1, Deencapsulation.>getField(index, "group2Tables").size());
- Assert.assertEquals(1, index.getAllGroupIds().size());
- Assert.assertEquals(1, Deencapsulation.