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: increment time continuously #8508

Merged
1 commit merged into from
Jan 4, 2022
Merged

Conversation

Zelldon
Copy link
Member

@Zelldon Zelldon commented Jan 3, 2022

Description

In order to prevent for flakiness the time needs to be increased
everytime so we can retrigger the position distribution.

Related issues

closes #8475

Definition of Done

Not all items need to be done depending on the issue and the pull request.

Code changes:

  • The changes are backwards compatibility with previous versions
  • If it fixes a bug then PRs are created to backport the fix to the last two minor versions. You can trigger a backport by assigning labels (e.g. backport stable/0.25) to the PR, in case that fails you need to create backports manually.

Testing:

  • There are unit/integration tests that verify all acceptance criterias of the issue
  • New tests are written to ensure backwards compatibility with further versions
  • The behavior is tested manually
  • The change has been verified by a QA run
  • The impact of the changes is verified by a benchmark

Documentation:

  • The documentation is updated (e.g. BPMN reference, configuration, examples, get-started guides, etc.)
  • New content is added to the release announcement

In order to prevent for flakiness the time needs to be increased
everytime so we can retrigger the position distribution.
@Zelldon Zelldon force-pushed the zell-8475-exporter-distribute branch from 36f757c to abe53bc Compare January 3, 2022 15:24
Copy link
Contributor

@deepthidevaki deepthidevaki left a comment

Choose a reason for hiding this comment

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

🚀
I don't understand why the event is not received with the first clock increment though.

@Zelldon
Copy link
Member Author

Zelldon commented Jan 4, 2022

Thanks @deepthidevaki I think this is a good point I can take a deeper look again.

@Zelldon
Copy link
Member Author

Zelldon commented Jan 4, 2022

Hey @deepthidevaki I had a deeper look and I think I can explain it.

In our test we start the exporters and await the future. The future we await is returned from submitting the Actor, https://github.com/camunda-cloud/zeebe/blob/develop/broker/src/main/java/io/camunda/zeebe/broker/exporter/stream/ExporterDirector.java#L107. Here it becomes interesting.

Taking a look at the actor scheduler, we can see that the future is complete after the starting phase is complete, which means #onActorStarting was called https://github.com/camunda-cloud/zeebe/blob/develop/util/src/main/java/io/camunda/zeebe/util/sched/ActorTask.java#L176

I was able to reproduce this via unit tests:

  @Test
  public void shouldCompleteFutureBeforeStartedComplete() {
    // given
    final CountDownLatch latch = new CountDownLatch(1);
    final var scheduler = ActorScheduler.newActorScheduler().build();

    scheduler.start();

    // when
    final ActorFuture<Void> startedFuture =
        scheduler.submitActor(
            new Actor() {
              @Override
              protected void onActorStarted() {
                try {
                  latch.await();
                } catch (final InterruptedException e) {
                  e.printStackTrace();
                }
              }
            });

    // then
    startedFuture.join();
    assertThat(startedFuture).isDone();
    assertThat(latch.getCount()).isEqualTo(1);
  }

This test completes without issues.

The following test will never complete:

  @Test
  public void shouldCompleteFutureBeforeStartingComplete() {
    // given
    final CountDownLatch latch = new CountDownLatch(1);
    final var scheduler = ActorScheduler.newActorScheduler().build();

    scheduler.start();

    // when
    final ActorFuture<Void> startedFuture =
        scheduler.submitActor(
            new Actor() {
              @Override
              protected void onActorStarting() {
                try {
                  latch.await();
                } catch (final InterruptedException e) {
                  e.printStackTrace();
                }
              }
            });

    // then
    startedFuture.join();
    assertThat(startedFuture).isDone();
    assertThat(latch.getCount()).isEqualTo(1);
  }

So to conclude we already complete the future after the starting phase, after that we wait that the active exporter is in the exporting phase, but this doesn't mean that the passive exporter has completely set up. This means in our test we already increment the time, but the passive exporter might not subscribed yet for the event (this happens in the #onActorStarted) .

@deepthidevaki
Copy link
Contributor

Got it! Thanks for looking into it 👍

@Zelldon
Copy link
Member Author

Zelldon commented Jan 4, 2022

bors r+

@ghost ghost merged commit 0d96dab into develop Jan 4, 2022
@ghost ghost deleted the zell-8475-exporter-distribute branch January 4, 2022 06:35
@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2022

Backport failed for stable/1.2, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally.

git fetch origin stable/1.2
git worktree add -d .worktree/backport-8508-to-stable/1.2 origin/stable/1.2
cd .worktree/backport-8508-to-stable/1.2
git checkout -b backport-8508-to-stable/1.2
ancref=$(git merge-base 4cbae45566fe59acc44c65c8d8ef65d8434322cf abe53bce920a22add55eb0d8e856589e7f046e1e)
git cherry-pick -x $ancref..abe53bce920a22add55eb0d8e856589e7f046e1e

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2022

Backport failed for release-1.3.0, because it was unable to create a new branch.

Please cherry-pick the changes locally.

git fetch origin release-1.3.0
git worktree add -d .worktree/backport-8508-to-release-1.3.0 origin/release-1.3.0
cd .worktree/backport-8508-to-release-1.3.0
git checkout -b backport-8508-to-release-1.3.0
ancref=$(git merge-base 4cbae45566fe59acc44c65c8d8ef65d8434322cf abe53bce920a22add55eb0d8e856589e7f046e1e)
git cherry-pick -x $ancref..abe53bce920a22add55eb0d8e856589e7f046e1e

@npepinpe
Copy link
Member

npepinpe commented Jan 4, 2022

BTW great catch 💪

ghost pushed a commit that referenced this pull request Jan 4, 2022
8512: [Backport 1.3]: test: increment time continously r=deepthidevaki a=Zelldon



## Description

Backports #8508 problems with cherry-pick, because of the import order.

> In order to prevent for flakiness the time needs to be increased
everytime so we can retrigger the position distribution.
<!-- Please explain the changes you made here. -->

## Related issues

<!-- Which issues are closed by this PR or are related -->

closes #8475



Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
ghost pushed a commit that referenced this pull request Jan 4, 2022
8512: [Backport 1.3]: test: increment time continously r=Zelldon a=Zelldon



## Description

Backports #8508 problems with cherry-pick, because of the import order.

> In order to prevent for flakiness the time needs to be increased
everytime so we can retrigger the position distribution.
<!-- Please explain the changes you made here. -->

## Related issues

<!-- Which issues are closed by this PR or are related -->

closes #8475



Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
ghost pushed a commit that referenced this pull request Jan 4, 2022
8511: [Backport 1.2] test: increment time continuously r=Zelldon a=Zelldon

## Description

Backports #8508 problems with cherry-pick, because of the import order.
<!-- Please explain the changes you made here. -->

## Related issues

<!-- Which issues are closed by this PR or are related -->

closes #8475



Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
ghost pushed a commit that referenced this pull request Jan 4, 2022
8512: [Backport 1.3]: test: increment time continously r=Zelldon a=Zelldon



## Description

Backports #8508 problems with cherry-pick, because of the import order.

> In order to prevent for flakiness the time needs to be increased
everytime so we can retrigger the position distribution.
<!-- Please explain the changes you made here. -->

## Related issues

<!-- Which issues are closed by this PR or are related -->

closes #8475



Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
This pull request was closed.
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.

Flaky test ExporterDirectorDistributionTest.shouldDistributeExporterPositions
5 participants