|
2 | 2 |
|
3 | 3 | import io.hyperfoil.tools.qdup.Host; |
4 | 4 | import io.hyperfoil.tools.qdup.SshTestBase; |
| 5 | +import io.hyperfoil.tools.qdup.cmd.Script; |
5 | 6 | import io.hyperfoil.tools.qdup.config.yaml.Parser; |
6 | 7 | import org.junit.Ignore; |
7 | 8 | import org.junit.Test; |
8 | 9 |
|
9 | 10 | import java.util.List; |
10 | 11 | import java.util.Set; |
| 12 | +import java.util.stream.Collectors; |
11 | 13 |
|
12 | | -import static org.junit.Assert.assertEquals; |
| 14 | +import static org.junit.Assert.*; |
13 | 15 |
|
14 | 16 | public class RunConfigTest extends SshTestBase { |
15 | 17 |
|
| 18 | + @Test |
| 19 | + public void script_load_order(){ |
| 20 | + Parser parser = Parser.getInstance(); |
| 21 | + RunConfigBuilder builder = getBuilder(); |
| 22 | + builder.loadYaml(parser.loadFile("local", |
| 23 | + """ |
| 24 | + scripts: |
| 25 | + uno: |
| 26 | + - sh: echo "hi" |
| 27 | + """ |
| 28 | + )); |
| 29 | + builder.loadYaml(parser.loadFile("remote", |
| 30 | + """ |
| 31 | + scripts: |
| 32 | + uno: |
| 33 | + - wait-for: bar |
| 34 | + """ |
| 35 | + )); |
| 36 | + RunConfig config = builder.buildConfig(parser); |
| 37 | + assertFalse("runConfig errors:\n" + config.getErrorStrings().stream().collect(Collectors.joining("\n")), config.hasErrors()); |
| 38 | + |
| 39 | + Script uno = config.getScript("uno"); |
| 40 | + assertNotNull("uno", uno); |
| 41 | + assertTrue(uno.getNext().toString().contains("sh")); |
| 42 | + } |
| 43 | + |
| 44 | + @Test |
| 45 | + public void host_load_order(){ |
| 46 | + Parser parser = Parser.getInstance(); |
| 47 | + RunConfigBuilder builder = getBuilder(); |
| 48 | + builder.loadYaml(parser.loadFile("local", |
| 49 | + """ |
| 50 | + hosts: |
| 51 | + uno: LOCAL//quay.io/fedora/fedora |
| 52 | + """ |
| 53 | + )); |
| 54 | + builder.loadYaml(parser.loadFile("remote", |
| 55 | + """ |
| 56 | + scripts: |
| 57 | + foo: |
| 58 | + - sh: echo "foo" |
| 59 | + hosts: |
| 60 | + uno: user@localhost:2222 |
| 61 | + roles: |
| 62 | + test: |
| 63 | + hosts: |
| 64 | + - uno |
| 65 | + setup-scripts: |
| 66 | + - foo |
| 67 | + """ |
| 68 | + )); |
| 69 | + RunConfig config = builder.buildConfig(parser); |
| 70 | + assertFalse("runConfig errors:\n" + config.getErrorStrings().stream().collect(Collectors.joining("\n")), config.hasErrors()); |
| 71 | + Set<Host> hosts = config.getAllHostsInRoles(); |
| 72 | + assertEquals(1, hosts.size()); |
| 73 | + Host first = hosts.iterator().next(); |
| 74 | + assertNotNull(first); |
| 75 | + assertTrue(first.isLocal()); |
| 76 | + assertTrue(first.isContainer()); |
| 77 | + assertTrue(first.getDefinedContainer().contains("fedora")); |
| 78 | + } |
| 79 | + |
| 80 | + |
16 | 81 | @Test |
17 | 82 | public void getAllHostsInRoles_alias_same_host(){ |
18 | 83 | Parser parser = Parser.getInstance(); |
|
0 commit comments