Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEST/CALLBACKQ: Fix test_callbackq.test_callbackq test failures #10024

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

yosefe
Copy link
Contributor

@yosefe yosefe commented Jul 21, 2024

Why

Fix test failures like:

2024-07-10T10:31:07.4474989Z [ RUN      ] test_callbackq.oneshot_mt/mt_10 <> <>
2024-07-10T10:31:07.4478332Z /scrap/azure/agent-04/AZP_WORKSPACE/1/s/contrib/../test/gtest/ucs/test_callbackq.cc:360: Failure
2024-07-10T10:31:07.4478820Z Expected equality of these values:
2024-07-10T10:31:07.4479038Z   1u
2024-07-10T10:31:07.4479254Z     Which is: 1
2024-07-10T10:31:07.4479513Z   ctx.count
2024-07-10T10:31:07.4479810Z     Which is: 1
2024-07-10T10:31:07.4481242Z [  FAILED  ] test_callbackq.oneshot_mt/mt_10, where TypeParam =  and GetParam() =  (1 ms)
2024-07-10T10:31:07.4481612Z [ RUN      ] test_callbackq.remove_self_safe <> <>

@yosefe
Copy link
Contributor Author

yosefe commented Jul 21, 2024

@tvegas1 @iyastreb can you pls review?

Comment on lines 93 to 115
template<typename T>
void wait_for_value(volatile T *var, T value,
double timeout = DEFAULT_TIMEOUT_SEC) const
{
ucs_time_t deadline = ucs_get_time() + (ucs_time_from_sec(timeout) *
ucs::test_time_multiplier());
while ((ucs_get_time() < deadline) && (*var != value)) {
sched_yield();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I counted 3 exiting reincarnations on exactly this function in UCX, and now this is the 4th.

ucp_test::wait_for_value
2 overloads in uct_test::wait_for_value

Apart from that there are multiple variations of the same function with slightly different names/behavior:

wait_progress
wait_for_rx_sn
many more...

Maybe we need to generalize it so that we don't have dozens of the similar functions?
Something like:

    template<typename Cond, typename Wait>
    void wait_for(Cond cond, Wait wait,
                        double timeout = DEFAULT_TIMEOUT_SEC) const
    {
        ucs_time_t deadline = ucs_get_time() + (ucs_time_from_sec(timeout) *
                                                ucs::test_time_multiplier());
        while ((ucs_get_time() < deadline) && (!cond())) {
            wait();
        }
    }

    template<typename T, Wait>
    void wait_for_value(volatile T *var, T value, Wait wait,
                        double timeout = DEFAULT_TIMEOUT_SEC) const
    {
        wait_for([&](){ return (*var == value); }, wait, timeout);
    }

Usage:
wait_for_value(..., sched_yield);

We can have overloads/default values for different wait strategies, or maybe leave it explicit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

test/gtest/common/test.h Outdated Show resolved Hide resolved
Copy link
Contributor

@tvegas1 tvegas1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can merge similar functions to some extent (wait_for_flag/wait_for_bits/wait_for_value..), gain might not be huge as code is small.

test/gtest/common/test.h Outdated Show resolved Hide resolved
test/gtest/common/test.h Outdated Show resolved Hide resolved
iyastreb
iyastreb previously approved these changes Aug 7, 2024
tvegas1
tvegas1 previously approved these changes Aug 7, 2024
@yosefe yosefe force-pushed the topic/test-callbackq-fix-test-callbackq-test-callbackq branch from b5fa88f to 3cb5400 Compare August 11, 2024 08:39
@yosefe yosefe dismissed stale reviews from tvegas1 and iyastreb via efcdcac August 11, 2024 10:16
@yosefe yosefe force-pushed the topic/test-callbackq-fix-test-callbackq-test-callbackq branch from 3cb5400 to efcdcac Compare August 11, 2024 10:16
@yosefe yosefe force-pushed the topic/test-callbackq-fix-test-callbackq-test-callbackq branch from efcdcac to e8edb84 Compare August 11, 2024 10:17
tvegas1
tvegas1 previously approved these changes Aug 12, 2024
@yosefe
Copy link
Contributor Author

yosefe commented Aug 23, 2024

/azp run UCX PR

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants