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

[DRAFT] Mutation server #4877

Closed
wants to merge 43 commits into from
Closed

Conversation

jaspervdveen
Copy link

This pull request introduces a mutation server within the core module of StrykerJS, implementing the Mutation Server Protocol. This server facilitates communication between StrykerJS and external clients, specifically the (unpublished) vscode-stryker IDE extension.

The Mutation Server Protocol is designed to enhance the integration and interaction between Stryker mutation testing frameworks and development tools, offering a standardized method for communication. The protocol leverages JSON-RPC messages for its operations, ensuring a consistent and efficient communication pattern. The detailed reasoning and decision-making process for the Mutation Server Protocol can be found in the corresponding ADR (Architectural Decision Record). As of now, messages are transported using a web socket, the corresponding ADR for this decision can be found here.

To further enhance modularity and reusability, there are plans to extract the Mutation Server Protocol into a separate npm package. This will allow other projects to easily adopt and implement the protocol.

The VS Code extension, the Mutation Server Protocol and its implementation in StrykerJS were developed as part of my internship. I am eager to hear your thoughts and feedback on this implementation.

jaspervdveen and others added 30 commits April 3, 2024 10:57
@jaspervdveen jaspervdveen changed the title Mutation server [DRAFT] Mutation server Jun 20, 2024
Copy link
Member

@nicojs nicojs left a comment

Choose a reason for hiding this comment

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

I did a quick review. Let's discus this in a call.

}

private async requestCancellationMiddleware(next: JSONRPCServerMiddlewareNext<void>, request: JSONRPCRequest, serverParams: void) {
if (request.id) {
Copy link
Member

Choose a reason for hiding this comment

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

id can be a number or a string, both of which have falsy values. You probably want an undefined check here.

const abortController = this.cancellableRequests.get(jsonRPCRequest.id);

if (!abortController) {
throw new Error('No cancellation token found for request');
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't happen, but because of the way you've implemented the middlewares it is actually a requirement you have to deal with it here. I think there must be a better way, let's talk about this.

import { ConfigError, retrieveCause } from '../../errors.js';
import { LogConfigurator } from '../../logging/log-configurator.js';

export class MutationTestMethod {
Copy link
Member

Choose a reason for hiding this comment

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

This is a copy of the Stryker class. Why have 2 separate processes for the same thing? I think we should reuse the Stryker class.

import { MutantInstrumenterContext } from '../../../process/2-mutant-instrumenter-executor.js';

export class MutantInstrumenterExecutor {
public static readonly inject = tokens(commonTokens.injector, coreTokens.project, commonTokens.options, coreTokens.pluginCreator);
Copy link
Member

Choose a reason for hiding this comment

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

Same as my previous remark. We should try to reuse as much as we can.

@@ -0,0 +1,3 @@
// Stryker disable file
export const port = 'port';
Copy link
Member

Choose a reason for hiding this comment

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

We can simply add these to the 'core tokens'

* feat(server): Add versioning and capabilities handshake

* fix: Close websocket transporter after test

* refactor: Rename 'mutate' request to 'mutationTest'

* fix: Tests failing due to rename

* chore: Upgrade ws package to fix vulnerability

* Revert "chore: Upgrade ws package to fix vulnerability"

This reverts commit 428e2d4.
@nicojs nicojs closed this Oct 19, 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.

2 participants