Skip to content

test: Coodinator handlers - #977

Merged
morgsmccauley merged 11 commits into
mainfrom
test/coordinator-handlers
Aug 5, 2024
Merged

morgsmccauley merged 11 commits into
mainfrom
test/coordinator-handlers

Conversation

@morgsmccauley

@morgsmccauley morgsmccauley commented Aug 5, 2024 •

Copy link
Copy Markdown
Contributor

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 August 5, 2024 04:33
uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust

Copy link
Copy Markdown
Contributor 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()))

@darunrs darunrs Aug 5, 2024 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor 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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor 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

Comment thread coordinator/src/handlers/block_streams.rs
}

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

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor 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 force-pushed the test/coordinator-handlers branch from 8892aaa to 0fb9321 Compare August 5, 2024 21:12
@morgsmccauley
morgsmccauley merged commit cdc5066 into main Aug 5, 2024
@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