Skip to content

MINOR: Move RequestConvertToJsonTest to server module - #22988

Merged
mimaison merged 1 commit into
apache:trunkfrom
mimaison:RequestConvertToJsonTest
Aug 20, 2026
Merged

MINOR: Move RequestConvertToJsonTest to server module#22988
mimaison merged 1 commit into
apache:trunkfrom
mimaison:RequestConvertToJsonTest

Conversation

@mimaison

@mimaison mimaison commented Jul 29, 2026

Copy link
Copy Markdown
Member

In
18340c9
we only moved part of this class as some tests still depended on core
classes.

We can now move the remaining of the tests and delete the old Scala
file.

Reviewers: Ken Huang s7133700@gmail.com, Luke Chen showuon@gmail.com

@github-actions github-actions Bot added core Kafka Broker tests Test fixes (including flaky tests) labels Jul 29, 2026

@m1a2st m1a2st left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, LGTM

@showuon showuon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@mimaison
mimaison merged commit 9e2f834 into apache:trunk Aug 20, 2026
24 checks passed
@mimaison
mimaison deleted the RequestConvertToJsonTest branch August 20, 2026 07:58

@chia7712 chia7712 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@mimaison thanks for this migration. I left two comments on pre-existing issues unrelated to this migration. No need for you to worry about them since we will file a patch to address them :)

int messageConversionsTimeMs = 9;

ObjectNode expectedNode = (ObjectNode) RequestConvertToJson.requestDesc(req.header(), req.requestLog(), req.isForwarded());
expectedNode.set("response", res.responseLog().orElse(NullNode.getInstance()));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I prefer to verify the fields one-by-one instead of creating a whole JSON object. It looks a bit like a copy-paste from production code😆

assertEquals(false, actualNode.get("isForwarded").asBoolean());
        assertEquals("connection-id", actualNode.get("connection").asText());
        assertEquals(1.0, actualNode.get("totalTimeMs").asDouble());
        assertEquals(2.0, actualNode.get("requestQueueTimeMs").asDouble());
        assertEquals(3.0, actualNode.get("localTimeMs").asDouble());
        assertEquals(4.0, actualNode.get("remoteTimeMs").asDouble());

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 opened a follow-up minor PR for it: #23218.

expectedNode.set("principal", new TextNode(req.session().principal.toString()));
expectedNode.set("listener", new TextNode(req.context().listenerName.value()));
expectedNode.set("clientInformation", RequestConvertToJson.clientInfoNode(req.context().clientInformation));
expectedNode.set("temporaryMemoryBytes", new LongNode(temporaryMemoryBytes));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could have a follow-up to include a test for the following behavior

        if (temporaryMemoryBytes > 0) {
            node.set("temporaryMemoryBytes", new LongNode(temporaryMemoryBytes));
        }
        if (messageConversionsTimeMs > 0) {
            node.set("messageConversionsTime", new DoubleNode(messageConversionsTimeMs));
        }

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 also cover it in #23218.

chia7712 pushed a commit that referenced this pull request Aug 23, 2026
…#23218)

This patch addresses the follow-up comments on RequestConvertToJsonTest
#22988 (review).

Make RequestConvertToJsonTest verify fields individually and add
coverage for omitting temporaryMemoryBytes and messageConversionsTime
when their values are zero or negative.

Reviewers: Uros (github:uros-b), Chia-Ping Tsai <chia7712@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Kafka Broker tests Test fixes (including flaky tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants