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: Coodinator handlers #977

Merged
merged 11 commits into from
Aug 5, 2024
Merged

test: Coodinator handlers #977

merged 11 commits into from
Aug 5, 2024

Conversation

morgsmccauley
Copy link
Collaborator

@morgsmccauley morgsmccauley commented Aug 5, 2024

Adds tests for: DataLayerHandler, BlockStreamsHandler, and ExecutorsHandler. No functional changes, but I did need to extract/create internal client wrappers so that the RPC requests can be mocked.

@morgsmccauley morgsmccauley requested a review from a team as a code owner August 5, 2024 04:33
@@ -21,6 +21,13 @@ jobs:
uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will conflict with #976 - I'll remove from whichever is merged first

};

handler
.synchronise(&config, Some(config.get_registry_version()))
Copy link
Collaborator

@darunrs darunrs Aug 5, 2024

Choose a reason for hiding this comment

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

I think the utility of having a function which encapsulates "Make the state match the action" is neat, it feels like it abstracts a lot of behavior. I think I would prefer if we had functions which described what they did. For example, "handle_update" or "handle_restart". So, the handler contains direct and concrete actions you can take with the resource, and lifecycle is fully responsible for calling them when appropriate. This removes the sharing of logical responsibility between the handler and lifecycle, where lifecycle seems to defer to the handler for things. What do you think?

Basically, migrate the synchronize logic to lifecycle.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I think I agree, but am also on the fence. On one hand, it's nice that the lifecycle is thin, and essentially manages state changes only. On the other, it encapsulates a lot like you've mentioned.

The encapsulation also allows us to refactor lifecycle quite easily, as the majority of the logic is delegated. This logic is pretty concrete and won't change. I've been burnt in the past having to refactor synchronisation many times, but with this encapsulation I can refactor around it.

I'd like to sit on this for a bit longer to really get a feel for what is/isn't working. I've also been burnt in the past pre-optimising. Are you ok with that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep! No issues with it. I'm happy to let it sit.

}

#[tokio::test]
async fn restarts_unhealthy_streams() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I added a pretty long wait between the stop and start call. Does this unit test also wait that timeout, or did you find a way to have it skipped?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

tokio::time::pause handles that

coordinator/src/handlers/block_streams.rs Show resolved Hide resolved
}

#[tokio::test]
async fn restarts_unhealthy_executors() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

So is it here that we would change the test, once we add in limited retries?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think so, we'd expect it to stop after some amount of time.

@morgsmccauley morgsmccauley merged commit cdc5066 into main Aug 5, 2024
4 checks passed
@morgsmccauley morgsmccauley deleted the test/coordinator-handlers branch August 5, 2024 21:21
@darunrs darunrs mentioned this pull request Aug 6, 2024
@morgsmccauley morgsmccauley linked an issue Aug 7, 2024 that may be closed by this pull request
morgsmccauley added a commit that referenced this pull request Aug 11, 2024
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.

Add unit tests for Coordinator
2 participants