Skip to content

Commit

Permalink
[EAP7-1877-test-dev)]: Add tests for yaml
Browse files Browse the repository at this point in the history
 On branch EAP7-1877-test-dev

 Date:      Wed Feb 28 11:37:46 2024 +0100

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
  • Loading branch information
mnovak1 authored and ehsavoie committed Mar 29, 2024
1 parent 7b77077 commit 04fa197
Show file tree
Hide file tree
Showing 27 changed files with 842 additions and 301 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@

package org.wildfly.core.launcher;

import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;

import static org.wildfly.core.launcher.JBossModulesCommandBuilder.DEFAULT_VM_ARGUMENTS;

import org.wildfly.core.launcher.Arguments.Argument;
Expand Down Expand Up @@ -230,6 +234,39 @@ public BootableJarCommandBuilder addJavaOption(final String jvmArg) {
return this;
}

/**
* Adds the YAML configuration file argument with the given YAML configuration files.
*
* @param yamlFiles the files to add
*
* @return the builder
*/
public BootableJarCommandBuilder setYamlFiles(final Path... yamlFiles) {
if (yamlFiles == null || yamlFiles.length == 0) {
return this;
}
return setYamlFiles(List.of(yamlFiles));
}

/**
* Adds the YAML configuration file argument with the given YAML configuration files.
*
* @param yamlFiles the files to add
*
* @return the builder
*/
public BootableJarCommandBuilder setYamlFiles(final Collection<Path> yamlFiles) {
if (yamlFiles == null || yamlFiles.isEmpty()) {
return this;
}
StringJoiner joiner = new StringJoiner(File.pathSeparator);
for (Path yamlFile : yamlFiles) {
joiner.add(yamlFile.toAbsolutePath().toString());
}
setSingleServerArg("--yaml", joiner.toString());
return this;
}

/**
* Adds the array of JVM arguments to the command.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ public void testBootableJarBuilder() {
.addJavaOption("-Djava.security.manager")
.addJavaOption("-Djava.net.preferIPv4Stack=true")
.addJavaOption("-Djava.net.preferIPv4Stack=false")
.setBindAddressHint("management", "0.0.0.0");
.setBindAddressHint("management", "0.0.0.0")
.setYamlFiles(Path.of("bad.yml"))
.setYamlFiles(Path.of("dummy.yml"));

// Get all the commands
List<String> commands = commandBuilder.buildArguments();
Expand All @@ -151,6 +153,8 @@ public void testBootableJarBuilder() {

Assert.assertTrue("Missing debug argument", commands.contains(String.format(StandaloneCommandBuilder.DEBUG_FORMAT, "y", 5005)));

Assert.assertTrue("--yaml is missing", commands.contains("--yaml=" + Path.of("dummy.yml").toFile().getAbsolutePath()));

// If we're using Java 12+. the enhanced security manager option must be set.
testEnhancedSecurityManager(commands, 1);
// Bootable JAR handles JPMS arguments thanks to its Manifest file.
Expand All @@ -173,6 +177,15 @@ public void testBootableJarBuilder() {
}
Assert.assertEquals("There should be only one --install-dir", 1, count);

// Install dir should be added once.
count = 0L;
for (String s : commandBuilder.getServerArguments()) {
if (s.contains("--yaml")) {
count++;
}
}
Assert.assertEquals("There should be only one --yaml", 1, count);

// Rename the binding address
commandBuilder.setBindAddressHint(null);
commands = commandBuilder.buildArguments();
Expand Down

This file was deleted.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
wildfly-configuration:
extension:

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
wildfly-configuration:
extension:
org.jboss.as.failure:
module: org.jboss.as.failure
deployment-overlay:
dummy-overlay:
path:
test.path:
relative-to: 'jboss.home.dir'
path: bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
wildfly-configuration:
socket-binding-group:
standard-sockets:
default-interface: public
port-offset: ${jboss.socket.binding.port-offset:0}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
wildfly-configuration:
subsystem:
logging:
root-logger:
NON-EXISTENT: !list-add
- level
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
wildfly-configuration:
subsystem:
logging:
root-logger:
ROOT:
level: !list-add
- TRACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
wildfly-configuration:
socket-binding-group:
standard-sockets:
default-interface: public
non-existent-attribute: blabla
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
wildfly-configuration:
socket-binding-group:
standard-sockets:
socket-binding:
management-https: !remove

subsystem:
elytron:
disallowed-providers: !undefine
permission-set:
default-permissions:
permissions: !list-add
- class-name: org.wildfly.security.auth.permission.LoginPermission
module: org.wildfly.security.elytron-base
target-name: "*"
index: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
wildfly-configuration:
socket-binding-group:
standard-sockets:
port-offset: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
wildfly-configuration:
socket-binding-group:
standard-sockets:
socket-binding:
management-https:
port: !remove
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
wildfly-configuration:
socket-binding-group:
standard-sockets:
remote-destination-outbound-socket-binding:
non-existent-binding: !remove
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
wildfly-configuration:
socket-binding-group:
standard-sockets:
remote-destination-outbound-socket-binding:
mail-snmt: !remove
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
wildfly-configuration:
subsystem:
logging:
periodic-rotating-file-handler:
FILE:
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
wildfly-configuration:
socket-binding-group:
standard-sockets:
default-interface: public
non-existent-attribute: blabla
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
wildfly-configuration:
socket-binding-group:
standard-sockets:
remote-destination-outbound-socket-binding:
mail-snmt:
host: foo-override
port: 8083
foo2:
host: foo2-override
port: 8084
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
wildfly-configuration:
socket-binding-group:
standard-sockets:
socket-binding:
txn-status-manager:
asfds: !undefine
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ protected void start(PrintStream out) {
commandBuilder.addJavaOption("-ea")
.setBindAddressHint("management", managementAddress);

commandBuilder.setYamlFiles(yamlFiles);
//Forcing this to be able to test failure when no yaml file is provided
if(yamlFiles != null && yamlFiles.length == 0) {
commandBuilder.addServerArgument("--yaml=");
}

if (jbossArgs != null) {
String[] args = jbossArgs.split("\\s+");
for (String a : args) {
Expand Down Expand Up @@ -255,6 +261,10 @@ protected void start(PrintStream out) {
}

commandBuilder.setYamlFiles(yamlFiles);
//Forcing this to be able to test failure when no yaml file is provided
if(yamlFiles != null && yamlFiles.length == 0) {
commandBuilder.addServerArgument("--yaml= ");
}

if (configDir != null) {
commandBuilder.addJavaOption("-Djboss.server.config.dir="+configDir.toString());
Expand Down Expand Up @@ -570,6 +580,8 @@ public void run() {
target.write(buf, 0, num);
}
} catch (IOException ignore) {
System.out.println("***************************************************************");
ignore.printStackTrace();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ public void startGitBackedConfiguration(final String gitRepository, final String
}

public void startYamlExtension(final Path[] yamlFiles) {
start(null, null, Server.StartMode.NORMAL, System.out, false, null, null, null, null, yamlFiles);
startYamlExtension(System.out, yamlFiles);
}

public void startYamlExtension(final PrintStream out, final Path[] yamlFiles) {
start(null, null, Server.StartMode.NORMAL, out, false, null, null, null, null, yamlFiles);
}

public void stop() {
Expand Down

0 comments on commit 04fa197

Please sign in to comment.