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

Create a test control api #191

Merged
merged 5 commits into from
Feb 21, 2022
Merged

Create a test control api #191

merged 5 commits into from
Feb 21, 2022

Conversation

remcowesterhoud
Copy link
Contributor

@remcowesterhoud remcowesterhoud commented Feb 17, 2022

Description

This PR adds a way for the extension to communicate with the containerised engine. A new engine-protocol module has been created. In this module the protobuf file will live that defines the interface of communication between the extension and the agent.

This PR also adds the serverside implementation of the protocol. This implementation will live in the engine-agent. This is because this agent is responsible for wrapping the engine in a testcontainer. Communication with the engine comes with this responsibility.

Related issues

closes #7

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

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

Documentation:

  • Javadoc has been written
  • The documentation is updated

The protocol module will be a shared module between the engine-agent and the extension. It defines the grpc proto files that allow communicating with the engine inside the testcontainer.
Adds a proto file that describes the communication with the engine. The extension will use this as a client. The engine-agent will take care of the server-side implementation.
Adds the server-side implementation of the engine control. The engine control implementation lives in the engine-agent. The reason for this is that we only need to communicate with the engine through grpc when it is running in a testcontainer. The engine-agent is a wrapper around the engine that make it executable in docker and now is also responsible for the communication with the container.
@github-actions
Copy link

github-actions bot commented Feb 17, 2022

Unit Test Results

  90 files    90 suites   4m 18s ⏱️
192 tests 192 ✔️ 0 💤 0
576 runs  576 ✔️ 0 💤 0

Results for commit 9d731e7.

♻️ This comment has been updated with latest results.

Copy link
Member

@korthout korthout left a comment

Choose a reason for hiding this comment

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

Sorry for the late review @remcowesterhoud

👍 I like the general direction, and thanks for the good explanation in the commit messages and comments. Great job!

However, I'm not that familiar with some of these topics. So, I still have a bunch of questions that might sound a bit dumb or redundant. Please bear with me. It would be nice if you could clarify them.

❌ The main thing that's missing is tests. Please make sure to add some.

Comment on lines +58 to +77
<!-- protobuf generation -->
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>${plugin.version.protobuf-maven-plugin}</version>
<configuration>
<checkStaleness>true</checkStaleness>
<protocArtifact>com.google.protobuf:protoc:${version.protobuf}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${version.grpc}:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
Copy link
Member

Choose a reason for hiding this comment

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

🔧 I haven't really created a gRPC implementation before. It would be nice to explain in the commit message why this plugin is necessary instead of the official gRPC tools.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This plugin is for the code generation. This is how the gRPC docs recommend doing this https://grpc.io/docs/languages/java/generated-code/#codegen

Comment on lines +356 to +362
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>${plugin.version.os-maven}</version>
</extension>
</extensions>
Copy link
Member

Choose a reason for hiding this comment

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

🔧 I'm not familiar with this extension. Can you add a comment explaining what it does and/or add to the commit message why it's needed for this project?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The os-maven-plugin generates various useful platform-dependent project properties. We need this for the protobuf-maven-plugin for the ${os.detected.classifier} property.

message WaitForIdleStateRequest {
// timeout (in ms). The request will be closed if an idle state has not been
// achieved withing the timeout.
int64 timeout = 1;
Copy link
Member

Choose a reason for hiding this comment

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

❓ Do we only want to have a timeout on this specific message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. This is the only request where we will be waiting for something on the server-side. We don't want to get stuck so a timeout here seems like a good addition. This timeout is not the request timeout, it's the waiting timeout. gRPC can handle request timeouts itself.

engine-protocol/src/main/proto/engine_control.proto Outdated Show resolved Hide resolved
public void resetEngine(
final ResetEngineRequest request,
final StreamObserver<ResetEngineResponse> responseObserver) {
engine.stop();
Copy link
Member

Choose a reason for hiding this comment

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

❓ Can stopping the engine fail? If so, what happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could fail. If it happens an error will be thrown which will cause in a failed gRPC request. In the end it would result in a failed unit test. I've added logging in case this happens so we can see what went wrong. I've never had it actually happen before.

@remcowesterhoud
Copy link
Contributor Author

@korthout Thanks for reviewing! I've answered your questions and made some changes. Please have another look.

About the unit tests. This will all be extensively tested by the QA tests once the client-side implementation gets merged and this code actually gets used. I wanted to keep the PR's a bit more small and isolated.

Copy link
Member

@korthout korthout left a comment

Choose a reason for hiding this comment

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

Thanks for the changes @remcowesterhoud LGTM 🚀

We should log our exceptions.
Add documentation on the grpc calls that were still missing it.
@remcowesterhoud remcowesterhoud merged commit 34a090c into main Feb 21, 2022
@remcowesterhoud remcowesterhoud deleted the 7-test-control-api branch February 21, 2022 14:58
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 a test control API to the engine
2 participants