fix: use 127.0.0.1 instead of localIP in LockdownModeTaskTestCase#605
Open
fix: use 127.0.0.1 instead of localIP in LockdownModeTaskTestCase#605
Conversation
…nModeTaskTestCase Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenDJ/sessions/807d09ee-6b9e-40b4-a1a9-e956b013c9c2 Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix LockdownModeTaskTestCase to use loopback IP
fix: use 127.0.0.1 instead of localIP in LockdownModeTaskTestCase
Mar 31, 2026
vharseko
approved these changes
Mar 31, 2026
Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenDJ/sessions/542b95d5-ad14-45af-bfed-f54dc48cbf11 Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LockdownModeTaskTestCase.javaOriginal prompt
Problem
The CI job for
OpenIdentityPlatform/OpenDJis failing inorg.opends.server.tasks.LockdownModeTaskTestCase#testLockdownModeTaskswith:The failure occurs at line 102 of
opendj-server-legacy/src/test/java/org/opends/server/tasks/LockdownModeTaskTestCase.java.Root Cause
The test calls
InetAddress.getLocalHost()to get the machine's primary IP address and uses that IP to connect to the embedded test LDAP server. In CI environments (e.g., macOS GitHub Actions runners),InetAddress.getLocalHost()returns a non-loopback IP address, but the embedded test server only listens on127.0.0.1. This causes a "No route to host" / connect error (LDAP result code 91).The first assertion at line 102:
uses
localIP(fromInetAddress.getLocalHost().getHostAddress()) as the-hargument, which fails whenlocalIPis not127.0.0.1.The final assertion at line 273 also uses
localIPfor the same reason.Fix
In
opendj-server-legacy/src/test/java/org/opends/server/tasks/LockdownModeTaskTestCase.java, make the following changes:1. Line ~95 — change
-hfromlocalIPto"127.0.0.1"for the initial unauthenticated searchBefore:
After:
2. Lines ~265–273 — change
-hfromlocalIPto"127.0.0.1"for the final post-lockdown-exit searchBefore:
After:
The
localIPandisLoopbackvariables are still needed for the conditional checks in the middle of the test (lines 134–183) and should be kept.File to Modify
opendj-server-legacy/src/test/java/org/opends/server/tasks/LockdownModeTaskTestCase.javaThe following is the prior conversation context from the user's chat exploration (may be truncated):
User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.
Assistant: Let me fetch the job logs to analyze the failure.
Assistant: ## Root Cause
The failing test is
LockdownModeTaskTestCase#testLockdownModeTasks, and the key error is:Error code 91 is an LDAP "Connect Error". The failure occurs at line 102:
The test resolves
InetAddress.getLocalHost()and uses the resulting IP (which, in the CI/macOS runner, is not the loopback address127.0.0.1). It then tries to connect to the LDAP server on that non-loopback IP — but the server is only listening onlocalhost/127.0.0.1, causing a "No route to host" error.Solution
The fix is to always use
127.0.0.1for the initial unauthenticated search (line 90–102) instead oflocalIP, since the test server only binds to the loopback interface. ThelocalIP/isLoopbacklogic is still needed for the conditional checks further in the test, but the very first search should be safe and unconditional.Change lines 90–102 from: