Skip to content

test(admin): use json payloads in the heartbeat metadata tests (#7692) - #7846

Merged
Aias00 merged 1 commit into
apache:masterfrom
konlue:fix/heartbeat-test-normalize
Oct 19, 2026
Merged

Aias00 merged 1 commit into
apache:masterfrom
konlue:fix/heartbeat-test-normalize

Conversation

@konlue

@konlue konlue commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #7721 (merged): the two new heartbeat-metadata tests fail on master since #7785 introduced InstanceInfoUtils.normalize — the non-JSON payloads (version=1.0) normalize to "{}", breaking the refresh assertions (as reported in the #7721 comments).

Modifications

  • Switch both payloads to JSON objects ({"version":"1.0"} / {"version":"2.0"}), which normalize passes through compacted, keeping the assertions' intent (refresh on repeated heartbeats, keep-last-known on a blank payload) intact.

Verifying this change

  • On current master with the old payloads: exactly the two tests fail with expected: <version=1.0> but was: <{}>.

  • Targeted tests pass with JSON payloads:

    ./mvnw -B -ntp -pl shenyu-admin test -Dtest=InstanceCheckServiceTest

    22/22 green.

  • Checkstyle passes:

    ./mvnw -B -ntp -pl shenyu-admin checkstyle:check

    clean.

Checklist

@Aias00 Aias00 left a comment

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.

Approved — this is exactly the fix needed and it unblocks master.

The two assertions now use a payload the storage contract accepts:

first.setInstanceInfo("{\"version\":\"1.0\"}");
...
assertEquals("{\"version\":\"1.0\"}", cached.getInstanceInfo());

That is correct on both branches. The insert path runs InstanceInfoUtils.normalize, which returns an already-compact JSON object unchanged, so the first assertion holds; the containsKey path stores the reported value raw, so the second heartbeat yields {"version":"2.0"} verbatim. The blank-beat case then keeps the previously stored object, which is the behaviour the test exists to protect.

The original intent of these tests — metadata is refreshed when the same identity reports again — is fully preserved; only the incidental payload literal changed. That was the right call rather than relaxing testInvalidOptionalInformationDoesNotStopHeartbeats, which documents a deliberate contract ("not-json" → "{}").

One note, non-blocking: the containsKey branch of handleBeatInfo still stores the reported value without normalizing, while the insert branch normalizes. With JSON payloads the two agree, so this PR is not affected — but the asymmetry is still there and is what made the original tests drift. Worth a follow-up on #7785 rather than here.

CI is green on this branch (the same suite that was failing), so this should turn master green once merged.

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