backport add some test cases
This commit is contained in:
parent
4c1bdb337e
commit
0881216d3c
80
patch040-backport-add-some-test-cases.patch
Normal file
80
patch040-backport-add-some-test-cases.patch
Normal file
@ -0,0 +1,80 @@
|
||||
From 56e886bf70669befd7b9e7380e68751fe67f05b2 Mon Sep 17 00:00:00 2001
|
||||
From: YASH PATEL <121890726+yp969803@users.noreply.github.com>
|
||||
Date: Wed, 29 Nov 2023 10:02:38 +0530
|
||||
Subject: [PATCH] =?UTF-8?q?[ISSUE=20#7592]=20testCleanBuffer=20unit=20test?=
|
||||
=?UTF-8?q?=20modifies,=20changed=20non-direct=20=E2=80=A6=20(#7593)?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
* [ISSUE #7592] testCleanBuffer unit test modifies, changed non-direct to direct buffer allocation
|
||||
|
||||
* fix: consolidate UtilAll#cleanBuffer by checking if the given buffer is direct or not
|
||||
|
||||
Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>
|
||||
|
||||
---------
|
||||
|
||||
Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>
|
||||
Co-authored-by: Li Zhanhui <lizhanhui@gmail.com>
|
||||
---
|
||||
.../main/java/org/apache/rocketmq/common/UtilAll.java | 9 +++++++++
|
||||
.../java/org/apache/rocketmq/common/UtilAllTest.java | 3 ++-
|
||||
.../rocketmq/store/timer/TimerMessageStoreTest.java | 2 +-
|
||||
3 files changed, 12 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
|
||||
index 2808f106a..19efa9aa9 100644
|
||||
--- a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
|
||||
+++ b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
|
||||
@@ -699,10 +699,19 @@ public class UtilAll {
|
||||
}
|
||||
}
|
||||
|
||||
+ /**
|
||||
+ * Free direct-buffer's memory actively.
|
||||
+ * @param buffer Direct buffer to free.
|
||||
+ */
|
||||
public static void cleanBuffer(final ByteBuffer buffer) {
|
||||
if (null == buffer) {
|
||||
return;
|
||||
}
|
||||
+
|
||||
+ if (!buffer.isDirect()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
PlatformDependent.freeDirectBuffer(buffer);
|
||||
}
|
||||
|
||||
diff --git a/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java b/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java
|
||||
index cb288578c..2d22d5254 100644
|
||||
--- a/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java
|
||||
+++ b/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java
|
||||
@@ -215,8 +215,9 @@ public class UtilAllTest {
|
||||
@Test
|
||||
public void testCleanBuffer() {
|
||||
UtilAll.cleanBuffer(null);
|
||||
+ UtilAll.cleanBuffer(ByteBuffer.allocateDirect(10));
|
||||
+ UtilAll.cleanBuffer(ByteBuffer.allocateDirect(0));
|
||||
UtilAll.cleanBuffer(ByteBuffer.allocate(10));
|
||||
- UtilAll.cleanBuffer(ByteBuffer.allocate(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
diff --git a/store/src/test/java/org/apache/rocketmq/store/timer/TimerMessageStoreTest.java b/store/src/test/java/org/apache/rocketmq/store/timer/TimerMessageStoreTest.java
|
||||
index 63ec97cdb..02ff35681 100644
|
||||
--- a/store/src/test/java/org/apache/rocketmq/store/timer/TimerMessageStoreTest.java
|
||||
+++ b/store/src/test/java/org/apache/rocketmq/store/timer/TimerMessageStoreTest.java
|
||||
@@ -387,7 +387,7 @@ public class TimerMessageStoreTest {
|
||||
assertEquals(PutMessageStatus.PUT_OK, putMessageResult.getPutMessageStatus());
|
||||
}
|
||||
|
||||
- // Wait until messages have wrote to TimerLog and currReadTimeMs catches up current time.
|
||||
+ // Wait until messages have written to TimerLog and currReadTimeMs catches up current time.
|
||||
await().atMost(5000, TimeUnit.MILLISECONDS).until(new Callable<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() {
|
||||
--
|
||||
2.32.0.windows.2
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
Summary: Cloud-Native, Distributed Messaging and Streaming
|
||||
Name: rocketmq
|
||||
Version: 5.1.5
|
||||
Release: 40
|
||||
Release: 41
|
||||
License: Apache-2.0
|
||||
Group: Applications/Message
|
||||
URL: https://rocketmq.apache.org/
|
||||
@ -49,6 +49,7 @@ Patch0036: patch036-backport-RIP65.patch
|
||||
Patch0037: patch037-backport-Retry-topic-v2-in-pop.patch
|
||||
Patch0038: patch038-backport-SlaveActingMaster-Timer-Message-retry-without-escape-logic.patch
|
||||
Patch0039: patch039-backport-add-some-validations.patch
|
||||
Patch0040: patch040-backport-add-some-test-cases.patch
|
||||
BuildRequires: java-1.8.0-openjdk-devel, maven, maven-local, git
|
||||
Requires: java-1.8.0-openjdk-devel
|
||||
|
||||
@ -89,6 +90,9 @@ exit 0
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Dec 11 2023 ShiZhili <shizhili_yewu@cmss.chinamobile.com> - 5.1.3-41
|
||||
- backport add some test cases
|
||||
|
||||
* Mon Dec 11 2023 ShiZhili <shizhili_yewu@cmss.chinamobile.com> - 5.1.3-40
|
||||
- backport add some validations
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user