Skip to content

Commit

Permalink
Add stress test.
Browse files Browse the repository at this point in the history
  • Loading branch information
philljj committed Dec 27, 2023
1 parent 91b01f4 commit 2bb400b
Show file tree
Hide file tree
Showing 13 changed files with 373 additions and 202 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/ubuntu-check-curl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Ubuntu Build Test with Curl Support

on:
push:
branches: [ 'master', 'main', 'release/**' ]
branches: [ '*' ]
pull_request:
branches: [ '*' ]

Expand Down Expand Up @@ -98,6 +98,15 @@ jobs:
- name: wolfmqtt make check
run: make check

- name: wolfmqtt configure with libCurl and Stress
env:
WOLFMQTT_NO_EXTERNAL_BROKER_TESTS: 1
run: ./configure --enable-curl --enable-stress
- name: wolfmqtt make
run: make
- name: wolfmqtt make check
run: make check

# capture logs on failure
- name: Show logs on failure
if: failure() || cancelled()
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/ubuntu-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Ubuntu Build Test

on:
push:
branches: [ 'master', 'main', 'release/**' ]
branches: [ '*' ]
pull_request:
branches: [ '*' ]

Expand Down Expand Up @@ -108,6 +108,15 @@ jobs:
- name: make check
run: make check

- name: wolfmqtt configure with Stress
env:
WOLFMQTT_NO_EXTERNAL_BROKER_TESTS: 1
run: ./configure --enable-stress
- name: wolfmqtt make
run: make
- name: wolfmqtt make check
run: make check

# capture logs on failure
- name: Show logs on failure
if: failure() || cancelled()
Expand Down
29 changes: 28 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ if test "x$ENABLED_CURL" = "xyes"; then
AC_CHECK_LIB([curl],[curl_easy_init],,[AC_MSG_ERROR([libcurl is required and wasn't found on the system. It can be obtained from https://curl.se/download.html.])])
fi


# MQTT v5.0
AC_ARG_ENABLE([v5],
[AS_HELP_STRING([--enable-v5],[Enable MQTT v5.0 support (default: disabled)])],
Expand Down Expand Up @@ -329,10 +328,37 @@ then
AM_CFLAGS="$AM_CFLAGS -DWOLFMQTT_MULTITHREAD"
fi

# Stress test convenience build option.
AC_ARG_ENABLE([stress],
[AS_HELP_STRING([--enable-stress],[Enable stress test (default: disabled)])],
[ ENABLED_STRESS=$enableval ],
[ ENABLED_STRESS=no ]
)

if test "x$ENABLED_STRESS" = "xyes"; then
if test "x$ENABLED_ALL" = "xyes"; then
AC_MSG_ERROR([--enable-all and --enable-stress are incompatible])
fi

if test "x$ENABLED_SN" = "xyes"; then
AC_MSG_ERROR([--enable-sn and --enable-stress are incompatible])
fi

ENABLED_TIMEOUT=yes
ENABLED_NONBLOCK=yes
ENABLED_MULTITHREAD=yes
AM_CFLAGS="$AM_CFLAGS -DWOLFMQTT_STRESS"
AM_CFLAGS="$AM_CFLAGS -DWOLFMQTT_NONBLOCK"
AM_CFLAGS="$AM_CFLAGS -DWOLFMQTT_TEST_NONBLOCK"
AM_CFLAGS="$AM_CFLAGS -DWOLFMQTT_TEST_NONBLOCK_TIMES=2"
AM_CFLAGS="$AM_CFLAGS -DWOLFMQTT_MULTITHREAD"
AM_CFLAGS="$AM_CFLAGS -DNUM_PUB_TASKS=5 -DNUM_PUB_PER_TASK=4"
fi


AM_CONDITIONAL([HAVE_LIBWOLFSSL], [test "x$ENABLED_TLS" = "xyes"])
AM_CONDITIONAL([HAVE_LIBCURL], [test "x$ENABLED_CURL" = "xyes"])
AM_CONDITIONAL([BUILD_STRESS], [test "x$ENABLED_STRESS" = "xyes"])
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$ENABLED_EXAMPLES" = "xyes"])
AM_CONDITIONAL([BUILD_STDINCAP], [test "x$ENABLED_STDINCAP" = "xyes"])
AM_CONDITIONAL([BUILD_SN], [test "x$ENABLED_SN" = "xyes"])
Expand Down Expand Up @@ -465,3 +491,4 @@ echo " * STDIN Capture: $ENABLED_STDINCAP"
echo " * TLS: $ENABLED_TLS"
echo " * CURL: $ENABLED_CURL"
echo " * Multi-thread: $ENABLED_MULTITHREAD"
echo " * Stress: $ENABLED_STRESS"
2 changes: 2 additions & 0 deletions examples/mqttexample.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ int mqtt_check_timeout(int rc, word32* start_sec, word32 timeout_sec)
return rc;
}

if (timeout_sec == 0) { timeout_sec = 2; }

elapsed_sec = mqtt_get_timer_seconds();
if (*start_sec < elapsed_sec) {
elapsed_sec -= *start_sec;
Expand Down
Loading

0 comments on commit 2bb400b

Please sign in to comment.