Skip to content

Fix TaskManagerTest#8

Merged
guozhangwang merged 7 commits into
guozhangwang:k9113-basefrom
vvcephei:task-manager-test
Jan 27, 2020
Merged

Fix TaskManagerTest#8
guozhangwang merged 7 commits into
guozhangwang:k9113-basefrom
vvcephei:task-manager-test

Conversation

@vvcephei

Copy link
Copy Markdown

Finishing up the TaskManagerTests.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@vvcephei

Copy link
Copy Markdown
Author

@guozhangwang , I have a minute, so I figured I could fix this. I fixed the failing tests, but there are still ignored tests that need to be re-enabled.

@Test
public void shouldUnassignChangelogPartitionsOnShutdown() {
throw new RuntimeException();
// restoreConsumer.unsubscribe();

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added this check to shouldCloseActiveTasksOnShutdown (although now, it's a changelogReader expectation)


@Ignore
@Test
public void shouldUpdateTasksFromPartitionAssignment() {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is no longer relevant.


@Ignore
@Test
public void shouldNotResumeConsumptionUntilAllStoresRestored() {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is tested effectively by making consumer a strict mock.

@vvcephei vvcephei left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hey @guozhangwang ,

I managed to finish up the failing/ignored tests in TaskManagerTest this evening. There are several tests of logic that has been moved elsewhere in Streams, so I made a note of them on this PR.

}

@Test
public void shouldNotUpdateSubscriptionFromAssignmentOfExistingTopic1() {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

If I read it right, this test is unnecessary now that we just pass through the whole assignment and let the topology builder itself merge the new subscription with the old one. I.e., this test is the same as the prior one now.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Sounds good.


@Ignore
@Test
public void shouldResumeRestoredPartitions() {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Does this need to be a ChangelogReader test now?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yes, it should be, I can add one in ChangelogReaderTest.


@Ignore
@Test
public void shouldReturnTrueWhenActiveAndStandbyTasksAreRunning() {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is asserted all over the other tests now


@Ignore
@Test
public void shouldReturnFalseWhenOnlyActiveTasksAreRunning() {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I honestly wasn't sure what this test was going for... maybe it meant when only standby tasks are running?

Even so, that hardly seems like an important behavior to verify. Just to be clear, behavior of the manager is to return true when all its tasks are in RUNNING state, regardless of the task type.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yup, I agree.


@Ignore
@Test
public void shouldSeekToCheckpointedOffsetOnStandbyPartitionsWhenOffsetGreaterThanEqualTo0() {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

should this be a ChangelogReader test now?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yes, this is already in the test class.


@Ignore
@Test
public void shouldSeekToBeginningIfOffsetIsLessThan0() {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

should this be a ChangelogReader test now?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yes, already in StoreChangelogReaderTest.

assertThat(taskManager.punctuate(), equalTo(2));
}

// TODO K9113: the following three tests needs to be fixed once thread calling restore is cleaned

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This test still needs to be added elsewhere, too.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ack, this is covered in the ChangelogReaderTest now.

@guozhangwang guozhangwang left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks @vvcephei ! I will merge the PR now and try to finish up the rest of the tests.

At the moment I'm adding more coverage to StreamTaskTest after I've completed the suspend / commit / close logic branching on state(), if you can take a quick look and lmk what do you think on these three functions that would be great :)

}

@Test
public void shouldNotUpdateSubscriptionFromAssignmentOfExistingTopic1() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Sounds good.


@Ignore
@Test
public void shouldResumeRestoredPartitions() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yes, it should be, I can add one in ChangelogReaderTest.


@Ignore
@Test
public void shouldReturnFalseWhenOnlyActiveTasksAreRunning() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yup, I agree.


@Ignore
@Test
public void shouldSeekToCheckpointedOffsetOnStandbyPartitionsWhenOffsetGreaterThanEqualTo0() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yes, this is already in the test class.


@Ignore
@Test
public void shouldSeekToBeginningIfOffsetIsLessThan0() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yes, already in StoreChangelogReaderTest.

assertThat(taskManager.punctuate(), equalTo(2));
}

// TODO K9113: the following three tests needs to be fixed once thread calling restore is cleaned

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ack, this is covered in the ChangelogReaderTest now.

@guozhangwang guozhangwang merged commit 499bedc into guozhangwang:k9113-base Jan 27, 2020
@vvcephei vvcephei deleted the task-manager-test branch January 27, 2020 15:16
@vvcephei

Copy link
Copy Markdown
Author

Thanks @guozhangwang ! I just took a look at those methods in base. I think they look the same as the last time i saw them, but did confirm they are missing coverage. I'll be available sporadically for reviews, if you want to send a PR for your tests.

guozhangwang added a commit to apache/kafka that referenced this pull request Feb 5, 2020
This PR is collaborated by Guozhang Wang and John Roesler. It is a significant tech debt cleanup on task management and state management, and is broken down by several sub-tasks listed below:

Extract embedded clients (producer and consumer) into RecordCollector from StreamTask.
guozhangwang#2
guozhangwang#5

Consolidate the standby updating and active restoring logic into ChangelogReader and extract out of StreamThread.
guozhangwang#3
guozhangwang#4

Introduce Task state life cycle (created, restoring, running, suspended, closing), and refactor the task operations based on the current state.
guozhangwang#6
guozhangwang#7

Consolidate AssignedTasks into TaskManager and simplify the logic of changelog management and task management (since they are already moved in step 2) and 3)).
guozhangwang#8
guozhangwang#9

Also simplified the StreamThread logic a bit as the embedded clients / changelog restoration logic has been moved into step 1) and 2).
guozhangwang#10

Reviewers: A. Sophie Blee-Goldman <sophie@confluent.io>, Bruno Cadonna <bruno@confluent.io>, Boyang Chen <boyang@confluent.io>
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.

2 participants