Skip to content

Commit a28e858

Browse files
committed
snapshot - still working on orchestrated tests.
1 parent 338ffca commit a28e858

6 files changed

Lines changed: 53 additions & 29 deletions

File tree

src/net/sharksystem/ui/messenger/cli/ProductionUI.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,15 @@ public class ProductionUI {
4949

5050
public static void main(String[] args) throws SharkException, IOException {
5151
ProductionUI cli = new ProductionUI(args);
52-
cli.startCLI();
52+
String peerName = "no peer name defined as parameter";
53+
if(args != null && args.length > 0) peerName = args[0];
54+
cli.startCLI(peerName);
5355
}
5456

55-
public void startCLI() {
57+
public void startCLI(String peerName) {
5658
System.out.println("type 'help' to see the list of commands");
5759
smUI.runCommandLoop();
60+
System.out.println("end CLI for " + peerName);
5861
}
5962

6063
public ProductionUI(String[] args) throws SharkException, IOException {

src/net/sharksystem/ui/messenger/cli/SharkNetMessengerAppSupportingDistributedTesting.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,21 @@ public void run() {
408408
effectiveScripts[peerIndex] = sb.toString() + this.test2run.scripts.get(peerIndex) + scriptEnd_Exit;
409409
}
410410

411-
// send script to each peer
411+
// run orchestrator script first - wait to collect logs
412+
ScriptRunnerThread scriptRunnerThread =
413+
new ScriptRunnerThread(ORCHESTRATOR_PEER_NAME,
414+
Integer.toString(this.testNumber), orchestratorScript);
415+
SharkNetMessengerAppSupportingDistributedTesting.this.tellUI(
416+
"running script as peer " + ORCHESTRATOR_PEER_NAME + ": " + orchestratorScript);
417+
scriptRunnerThread.start();
418+
419+
// now - send script to each peer
420+
421+
// to avoid even the slightest chance of a race condition - make a little break;
422+
try { Thread.sleep(1000); } catch (InterruptedException e) {}
423+
424+
SharkNetMessengerAppSupportingDistributedTesting.this.tellUI("sending test scripts to peers");
425+
412426
try {
413427
for (int i = 0; i < this.test2run.peerEnvironment.size(); i++) {
414428
PeerHostingEnvironmentDescription peerEnvironment = this.test2run.peerEnvironment.get(i);
@@ -432,14 +446,6 @@ public void run() {
432446

433447
SharkNetMessengerAppSupportingDistributedTesting.this.
434448
tellUI("test scripts sent to " + peerEnvironment.ipAddress);
435-
436-
// run orchestrator script - wait to collect logs
437-
ScriptRunnerThread scriptRunnerThread =
438-
new ScriptRunnerThread(ORCHESTRATOR_PEER_NAME,
439-
Integer.toString(this.testNumber), orchestratorScript);
440-
SharkNetMessengerAppSupportingDistributedTesting.this.tellUI(
441-
"running script as peer " + ORCHESTRATOR_PEER_NAME + ": " + orchestratorScript);
442-
scriptRunnerThread.start();
443449
}
444450
}
445451
catch(IOException | SharkNetMessengerException ioe) {

src/net/sharksystem/ui/messenger/cli/commands/basics/UICommandExit.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ public UICommandExit(SharkNetMessengerApp sharkMessengerApp, SharkNetMessengerUI
1717
@Override
1818
public void execute() throws Exception {
1919
//this.printTODOReimplement();
20-
System.exit(1);
20+
this.getSharkMessengerApp().tellUI("end CLI for peer " +
21+
this.getSharkMessengerApp().getSharkPeer().getPeerID());
22+
System.exit(0);
2123
}
2224

2325
@Override

src/net/sharksystem/ui/messenger/cli/commands/testing/ScriptRunnerThread.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public ScriptRunnerThread(String peerName, String testName, String script) {
3030
}
3131

3232
public void run() {
33-
this.ui.startCLI();
33+
this.ui.startCLI(peerName);
3434
}
3535

3636
public static String getFriendlyPeerName(String peerName) {

src/net/sharksystem/ui/messenger/cli/commands/testing/UICommandOrchestrateTest.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,37 @@ protected void execute() throws Exception {
2222
* script for each peer
2323
*/
2424

25-
/**
26-
* what works - independent tests - no interaction between test peers
27-
* Test with one peer... test is executed - results are persistent in test peer
28-
* Test with two peers... no script is executed, Clara even claims not to be able to stage a test.
29-
*/
25+
// what works - independent tests - no interaction between test peers
26+
// 2025-12-03
27+
String script0_0 = "sendMessage HiFromTest;wait 1000;lsMessages;";
28+
String script0_1 = "sendMessage HiFromTest;wait 1000;lsMessages;";
3029

31-
// Orchestrator: orchestrateTest dummy; openTCP 9999
32-
// dann Peers: connectTCP localhost 9999; scriptRQ
30+
// Orchestrator: orchestrateTest dummy; openTCP 6907
31+
// dann Peers: connectTCP localhost 6907; scriptRQ
3332

34-
String script1_0 = "connectTCP localhost 9999;release A1;wait 5000;lsMessages;";
35-
String script1_1 = "openTCP 9999;block A1;sendMessage HiFromBob;wait 5000;";
33+
// testing - seems orchestrator does not receive peerSettled release messages - it does sometimes, though.
34+
// Race condition - no doubt. S***.
35+
// check locks - getting even weirder - to test peer names are generated twice?
36+
// There is nothing but a good mystery :)
37+
// what the difference to scenario 0? no additional TCP connections(?)
38+
String script1_A = "wait 5000;connectTCP localhost 9999;release A1;wait 5000;lsMessages;";
39+
String script1_B = "openTCP 9999;block A1;sendMessage HiFromBob;wait 5000;";
3640

37-
// works: 2025.12.03
38-
String script0_0 = "sendMessage HiFromTest;wait 1000;lsMessages;";
39-
String script0_1 = "sendMessage HiFromTest;wait 1000;lsMessages;";
41+
/* effective scripts
42+
// message sent but not received but at least scenario runs - it is a race condition causing the problem above.
43+
o: openTCP 1984;block peerSettled_0_0;block peerSettled_0_1;release launchTest_0;;exit;
44+
a: connectTCP 192.168.0.116 1984;release peerSettled_0_0;block launchTest_0;wait 1000;wait 5000;connectTCP localhost 9999;release A1;wait 5000;lsMessages;;exit;
45+
b: connectTCP 192.168.0.116 1984;release peerSettled_0_1;block launchTest_0;wait 1000;openTCP 9999;block A1;sendMessage HiFromBob;wait 5000;;exit;
46+
*/
4047

4148
//List<PeerHostingEnvironmentDescription> requiredPeerEnvironment = new ArrayList<>();
4249
List<String> scripts = new ArrayList<>();
4350

4451
// fill with example data
4552
this.getSharkMessengerApp().tellUI("use sample data - todo: fill with real data");
4653
// anything will do
47-
scripts.add(script0_0);
48-
scripts.add(script0_1);
54+
scripts.add(script1_A);
55+
scripts.add(script1_B);
4956

5057
this.snmTestSupport.orchestrateTest(scripts);
5158

src/net/sharksystem/ui/messenger/cli/commands/testing/UICommandWait.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ public UICommandWait(SharkNetMessengerApp sharkMessengerApp, SharkNetMessengerUI
1010
}
1111

1212
@Override
13-
protected void execute() throws Exception {
13+
protected void execute() {
1414
this.getSharkMessengerApp().tellUI("wait " + this.getIntegerArgument() + " ms ...");
15-
Thread.sleep(this.getIntegerArgument());
15+
16+
try {
17+
Thread.sleep(this.getIntegerArgument());
18+
} catch (InterruptedException e) {
19+
this.getSharkMessengerApp().tellUIError("wait received interrupt - that shouldn't happen");
20+
e.printStackTrace();
21+
}
1622
this.getSharkMessengerApp().tellUI("resume");
1723
}
1824

0 commit comments

Comments
 (0)