DPDK CI discussions
 help / color / mirror / Atom feed
From: Harry van Haaren <harry.van.haaren@intel.com>
To: dev@dpdk.org
Cc: david.marchand@redhat.com, dpdklab@iol.unh.edu, ci@dpdk.org,
	Honnappa.Nagarahalli@arm.com, mb@smartsharesystems.com,
	mattias.ronnblom@ericsson.com, thomas@monjalon.net,
	Harry van Haaren <harry.van.haaren@intel.com>
Subject: [PATCH v3] test/service: fix spurious failures by extending timeout
Date: Thu,  6 Oct 2022 12:52:47 +0000	[thread overview]
Message-ID: <20221006125247.1018265-1-harry.van.haaren@intel.com> (raw)
In-Reply-To: <20221006081729.578475-1-harry.van.haaren@intel.com>

This commit extends the timeout for service_may_be_active()
from 100ms to 1000ms. Local testing on a idle and loaded system
(compiling DPDK with all cores) always completes after 1 ms.

The wait time for a service-lcore to finish is also extended
from 100ms to 1000ms.

The same timeout waiting code was duplicated in two tests, and
is now refactored to a standalone function avoiding duplication.

Reported-by: David Marchand <david.marchand@redhat.com>
Suggested-by: Mattias Ronnblom <mattias.ronnblom@ericsson.com>
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>

---

v3:
- Use #define for timeout, and delay(1) (Mattias)
- Rework slcore-wait to use TIMEOUT_MS as well.

v2:
- v1 addressed only testcase 15 issue, v2 also addresses test
  case 5, which has an service-lcore wait code-path.
---
 app/test/test_service_cores.c | 49 ++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 26 deletions(-)

diff --git a/app/test/test_service_cores.c b/app/test/test_service_cores.c
index 359b6dcd8b..637fcd7cf9 100644
--- a/app/test/test_service_cores.c
+++ b/app/test/test_service_cores.c
@@ -22,6 +22,7 @@ static uint64_t service_tick;
 static uint32_t service_remote_launch_flag;
 
 #define SERVICE_DELAY 1
+#define TIMEOUT_MS 1000
 
 #define DUMMY_SERVICE_NAME "dummy_service"
 #define MT_SAFE_SERVICE_NAME "mt_safe_service"
@@ -123,15 +124,15 @@ unregister_all(void)
 	return TEST_SUCCESS;
 }
 
-/* Wait until service lcore not active, or for 100x SERVICE_DELAY */
+/* Wait until service lcore not active, or for TIMEOUT_MS */
 static void
 wait_slcore_inactive(uint32_t slcore_id)
 {
 	int i;
 
 	for (i = 0; rte_service_lcore_may_be_active(slcore_id) == 1 &&
-			i < 100; i++)
-		rte_delay_ms(SERVICE_DELAY);
+			i < TIMEOUT_MS; i++)
+		rte_delay_ms(1);
 }
 
 /* register a single dummy service */
@@ -921,12 +922,25 @@ service_lcore_start_stop(void)
 	return unregister_all();
 }
 
+static int
+service_ensure_stopped_with_timeout(uint32_t sid)
+{
+	/* give the service time to stop running */
+	int i;
+	for (i = 0; i < TIMEOUT_MS; i++) {
+		if (!rte_service_may_be_active(sid))
+			break;
+		rte_delay_ms(1);
+	}
+
+	return rte_service_may_be_active(sid);
+}
+
 /* stop a service and wait for it to become inactive */
 static int
 service_may_be_active(void)
 {
 	const uint32_t sid = 0;
-	int i;
 
 	/* expected failure cases */
 	TEST_ASSERT_EQUAL(-EINVAL, rte_service_may_be_active(10000),
@@ -946,19 +960,11 @@ service_may_be_active(void)
 	TEST_ASSERT_EQUAL(1, service_lcore_running_check(),
 			"Service core expected to poll service but it didn't");
 
-	/* stop the service */
+	/* stop the service, and wait for not-active with timeout */
 	TEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 0),
 			"Error: Service stop returned non-zero");
-
-	/* give the service 100ms to stop running */
-	for (i = 0; i < 100; i++) {
-		if (!rte_service_may_be_active(sid))
-			break;
-		rte_delay_ms(SERVICE_DELAY);
-	}
-
-	TEST_ASSERT_EQUAL(0, rte_service_may_be_active(sid),
-			  "Error: Service not stopped after 100ms");
+	TEST_ASSERT_EQUAL(0, service_ensure_stopped_with_timeout(sid),
+			  "Error: Service not stopped after timeout period.");
 
 	return unregister_all();
 }
@@ -972,7 +978,6 @@ service_active_two_cores(void)
 		return TEST_SKIPPED;
 
 	const uint32_t sid = 0;
-	int i;
 
 	uint32_t lcore = rte_get_next_lcore(/* start core */ -1,
 					    /* skip main */ 1,
@@ -1002,16 +1007,8 @@ service_active_two_cores(void)
 	/* stop the service */
 	TEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 0),
 			"Error: Service stop returned non-zero");
-
-	/* give the service 100ms to stop running */
-	for (i = 0; i < 100; i++) {
-		if (!rte_service_may_be_active(sid))
-			break;
-		rte_delay_ms(SERVICE_DELAY);
-	}
-
-	TEST_ASSERT_EQUAL(0, rte_service_may_be_active(sid),
-			  "Error: Service not stopped after 100ms");
+	TEST_ASSERT_EQUAL(0, service_ensure_stopped_with_timeout(sid),
+			  "Error: Service not stopped after timeout period.");
 
 	return unregister_all();
 }
-- 
2.34.1


  parent reply	other threads:[~2022-10-06 12:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-06  8:17 [PATCH] " Harry van Haaren
2022-10-06  8:28 ` [PATCH v2] " Harry van Haaren
2022-10-06  8:39   ` David Marchand
2022-10-06  8:54     ` Mattias Rönnblom
2022-10-06  8:37 ` [PATCH] " Mattias Rönnblom
2022-10-06 12:52 ` Harry van Haaren [this message]
2022-10-06 13:27   ` [PATCH v3] " Morten Brørup
2022-10-06 19:33     ` David Marchand
2023-01-26  9:29       ` David Marchand
2023-01-31 17:24         ` Van Haaren, Harry
2023-02-03 15:03           ` Van Haaren, Harry
2023-02-03 15:12             ` Bruce Richardson
2023-02-23 20:10               ` Thomas Monjalon
2023-02-27  8:41                 ` Van Haaren, Harry
2023-02-03 15:16             ` Thomas Monjalon
2023-02-03 16:09               ` Van Haaren, Harry
2023-02-23 20:15                 ` Thomas Monjalon
2023-02-27  8:41                   ` Van Haaren, Harry
2022-10-06 14:00   ` Mattias Rönnblom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221006125247.1018265-1-harry.van.haaren@intel.com \
    --to=harry.van.haaren@intel.com \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=ci@dpdk.org \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=dpdklab@iol.unh.edu \
    --cc=mattias.ronnblom@ericsson.com \
    --cc=mb@smartsharesystems.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).