-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Feature/solace example #6432
Feature/solace example #6432
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @infoShare ! I think would have been much better trying to give an overview about the implementation instead of investing time in the example itself. IMHO, the example should provide different use-cases instead of the most complex one. I wonder if all of this setup is needed just to send a message... probably, yes.
One thing to consider, testcontainers-java is built with Java 8 and there are some features such as Collections factories that will not be available. As a consequence, the build will fail.
MountableFile.forHostPath(getResourceFile("solace.pem")), | ||
MountableFile.forHostPath(getResourceFile("rootCA.crt")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MountableFile.forHostPath(getResourceFile("solace.pem")), | |
MountableFile.forHostPath(getResourceFile("rootCA.crt")) | |
MountableFile.forClasspathResource("solace.pem"), | |
MountableFile.forClasspathResource("rootCA.crt") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
SolaceContainer solace = new SolaceContainer(DEFAULT_IMAGE_NAME.withTag(DEFAULT_TAG)) | ||
.withCredentials("user", "pass") | ||
.withTopic(TOPIC_NAME, Protocol.SMF) | ||
.withVpn("test_vpn") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is vpn required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one VPN configured (but it has a lot of more additional configuration) - and it's not the best one for certificates usage.
|
||
@Override | ||
protected void configure() { | ||
addEnv("system_scaling_maxconnectioncount", String.valueOf(maxConnections)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it can be added using withEnv(key, value)
. So, I would remove it from here.
} | ||
|
||
private MountableFile createConfigurationScript() throws IOException { | ||
Path scriptFile = Files.createTempFile("script", ".cli"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of create a tmp file and writing into it, create the script in the string and the use Transferable.of(string)
. updateConfigScript
can be deleted.
private void waitOnCommandResult(List<String> command, String waitingFor) { | ||
waitUntilConditionIsMet( | ||
() -> { | ||
try { | ||
return execInContainer(command.toArray(new String[0])).getStdout().contains(waitingFor); | ||
} catch (IOException | InterruptedException e) { | ||
logger().error("Could not execute command {}: {}", command, e.getMessage()); | ||
return true; | ||
} | ||
}, | ||
30 | ||
); | ||
} | ||
|
||
private void waitUntilConditionIsMet(BooleanSupplier awaitedCondition, int timeoutInSec) { | ||
boolean done; | ||
long startTime = System.currentTimeMillis(); | ||
do { | ||
done = awaitedCondition.getAsBoolean(); | ||
try { | ||
Thread.sleep(500); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} while (!done && System.currentTimeMillis() - startTime < timeoutInSec * 1000); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may want to use awaitility instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @infoShare ! Thanks again for updating the PR. I'm submitting more comments and also want to let you know that we are glad to accept this as a new module instead of only an example. As a more knowledgeable about solace, would you be able to perform those changes? :)
public SolaceContainer(final DockerImageName dockerImageName) { | ||
super(dockerImageName.toString()); | ||
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); | ||
this.waitStrategy = Wait.forLogMessage(SOLACE_READY_MESSAGE, 1).withStartupTimeout(Duration.ofSeconds(60)); | ||
} | ||
|
||
@Override | ||
protected void configure() { | ||
withCreateContainerCmdModifier(cmd -> { | ||
cmd | ||
.getHostConfig() | ||
.withShmSize(SHM_SIZE) | ||
.withUlimits(new Ulimit[] { new Ulimit("nofile", 2448L, 6592L) }); | ||
}); | ||
configureSolace(); | ||
} | ||
|
||
private void configureSolace() { | ||
withCopyToContainer(createConfigurationScript(), TMP_SCRIPT_LOCATION); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public SolaceContainer(final DockerImageName dockerImageName) { | |
super(dockerImageName.toString()); | |
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); | |
this.waitStrategy = Wait.forLogMessage(SOLACE_READY_MESSAGE, 1).withStartupTimeout(Duration.ofSeconds(60)); | |
} | |
@Override | |
protected void configure() { | |
withCreateContainerCmdModifier(cmd -> { | |
cmd | |
.getHostConfig() | |
.withShmSize(SHM_SIZE) | |
.withUlimits(new Ulimit[] { new Ulimit("nofile", 2448L, 6592L) }); | |
}); | |
configureSolace(); | |
} | |
private void configureSolace() { | |
withCopyToContainer(createConfigurationScript(), TMP_SCRIPT_LOCATION); | |
} | |
public SolaceContainer(final DockerImageName dockerImageName) { | |
super(dockerImageName); | |
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); | |
withCreateContainerCmdModifier(cmd -> { | |
cmd | |
.getHostConfig() | |
.withShmSize(SHM_SIZE) | |
.withUlimits(new Ulimit[] { new Ulimit("nofile", 2448L, 6592L) }); | |
}); | |
this.waitStrategy = Wait.forLogMessage(SOLACE_READY_MESSAGE, 1).withStartupTimeout(Duration.ofSeconds(60)); | |
} | |
@Override | |
protected void configure() { | |
withCopyToContainer(createConfigurationScript(), TMP_SCRIPT_LOCATION); | |
} |
AMQP("amqp", 5672, "amqp", false), | ||
MQTT("mqtt", 1883, "tcp", false), | ||
REST("rest", 9000, "http", false), | ||
SEMP("semp", 8080, "http", false), | ||
SMF("smf", 55555, "tcp", true), | ||
SMF_SSL("smf", 55443, "tcps", true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should cover those protocols with tests
} | ||
|
||
public String getUsername() { | ||
return username; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return username; | |
return this.username; |
} | ||
|
||
public String getPassword() { | ||
return password; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return password; | |
return password; |
return password; | |
return this.password; |
} | ||
|
||
public Integer getPort() { | ||
return port; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return port; | |
return this.port; |
} | ||
|
||
private String getProtocol() { | ||
return protocol; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return protocol; | |
return this.protocol; |
} | ||
|
||
public String getService() { | ||
return service; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return service; | |
return this.service; |
} | ||
|
||
public boolean isSupportSSL() { | ||
return supportSSL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return supportSSL; | |
return this.supportSSL; |
} | ||
|
||
public String getVpn() { | ||
return vpn; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return vpn; | |
return this.vpn; |
"grep", | ||
"-R", | ||
SOLACE_ACTIVE_MESSAGE, | ||
"/usr/sw/jail/logs/system.log" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wonder if system.log is displayed as part of the container log. If so, checking against the container log would be easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly - it is not displayed. There is no information about that in the logs.
I'll do that in the next week ! |
@eddumelendez |
Closing in favor of PR #6583 |
Example for Solace Pub Sub (solace/solace-pubsub-standard)