Skip to content

Conversation

@jglick
Copy link
Member

@jglick jglick commented Jul 31, 2025

Test introduced in 4c9f03a. I cannot check if it passed at that time:

com.github.dockerjava.api.exception.NotFoundException: {"message":"No such image: quay.io/testcontainers/ryuk:0.2.2"}

It does not pass now:

…
WARNING	o.a.s.c.u.logging.LoggingUtils#warn: exceptionCaught(ClientSessionImpl[jenkins@localhost/127.0.0.1:32802])[state=Opened] RuntimeException: java.io.IOException: Nodes directory does not exist
…
org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:31)
	at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:183)
	at hudson.plugins.ec2.util.ConnectionExtension.connect(ConnectionExtension.java:81)
	at hudson.plugins.ec2.ssh.verifiers.SshHostKeyVerificationStrategyTest$ConnectionAttempt.connect(SshHostKeyVerificationStrategyTest.java:260)
	at hudson.plugins.ec2.ssh.verifiers.SshHostKeyVerificationStrategyTest$ConnectionAttempt.attempt(SshHostKeyVerificationStrategyTest.java:235)
	at hudson.plugins.ec2.ssh.verifiers.SshHostKeyVerificationStrategyTest$StrategyTest.check(SshHostKeyVerificationStrategyTest.java:188)
	at hudson.plugins.ec2.ssh.verifiers.SshHostKeyVerificationStrategyTest.verifyAllStrategiesTest(SshHostKeyVerificationStrategyTest.java:52)

It is not checked by CI since #434 made it impossible to run Dockerized tests. It is not even listed as skipped in CI trunk builds; not sure if that is a regression from #1076 or not.

#1022 edited this test, but it fails in that revision the same way. Not sure if any attempt was made to run the test there, or just have it compile and trust CI to find failures.

Despite the error message, attempting to fix it

diff --git src/test/java/hudson/plugins/ec2/ssh/verifiers/SshHostKeyVerificationStrategyTest.java src/test/java/hudson/plugins/ec2/ssh/verifiers/SshHostKeyVerificationStrategyTest.java
index 2a2e2cf7..488ed0b7 100644
--- src/test/java/hudson/plugins/ec2/ssh/verifiers/SshHostKeyVerificationStrategyTest.java
+++ src/test/java/hudson/plugins/ec2/ssh/verifiers/SshHostKeyVerificationStrategyTest.java
@@ -8,12 +8,14 @@ import hudson.plugins.ec2.EC2Computer;
 import hudson.plugins.ec2.InstanceState;
 import hudson.plugins.ec2.MockEC2Computer;
 import hudson.plugins.ec2.util.ConnectionExtension;
+import java.io.File;
 import java.io.IOException;
 import java.net.SocketAddress;
 import java.security.PublicKey;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.logging.Level;
+import jenkins.model.Jenkins;
 import org.apache.sshd.client.keyverifier.ServerKeyVerifier;
 import org.apache.sshd.client.session.ClientSession;
 import org.hamcrest.core.StringContains;
@@ -46,6 +48,7 @@ class SshHostKeyVerificationStrategyTest {
      */
     @Test
     void verifyAllStrategiesTest() throws Exception {
+        new File(Jenkins.get().getRootDir(), "nodes").mkdirs();
         List<StrategyTest> strategiesToCheck = getStrategiesToTest();
 
         for (StrategyTest strategyToCheck : strategiesToCheck) {

does not work; it just fails with the same stack and different logs

INFO	hudson.plugins.ec2.EC2Cloud#log: The instance MockInstanceForTest-hardStrategyNotPrinted is not running, waiting to validate the key against the console
INFO	hudson.plugins.ec2.EC2Cloud#log: The instance MockInstanceForTest-hardStrategyNotPrinted has a blank console. Maybe the console is yet not available. If enough time has passed, consider changing the key verification strategy or the AMI used by one printing out the host key in the instance console
INFO	hudson.plugins.ec2.EC2Cloud#log: The instance console is blank. Cannot check the key. The connection to MockInstanceForTest-hardStrategyNotPrinted is not allowed
WARNING	o.a.s.c.u.logging.LoggingUtils#warn: exceptionCaught(ClientSessionImpl[jenkins@localhost/127.0.0.1:32804])[state=Opened] SshException: Server key did not validate
INFO	o.a.s.c.s.helpers.SessionHelper#disconnect: Disconnecting(ClientSessionImpl[jenkins@localhost/127.0.0.1:32804]): SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE - Server key did not validate

LoggingUtils seems to be using SLF4J not JUL and I could not figure out how to get stack traces from it.

I do notice that the test is written rather awkwardly copying in a public key, when it suffices to set JENKINS_AGENT_SSH_PUBKEY as in jenkinsci/ssh-agents-plugin#607.

@fcojfernandez fcojfernandez merged commit f82d94c into jenkinsci:master Aug 12, 2025
17 checks passed
@jglick jglick deleted the SshHostKeyVerificationStrategyTest branch August 12, 2025 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants