Commit d5eb8b3e authored by legoc's avatar legoc

Renamed test cancel

parent c42ac0c9
......@@ -89,6 +89,12 @@ target_link_libraries(requester PUBLIC cameo zmq)
add_executable(testrequester src/tests/TestRequester.cpp)
target_link_libraries(testrequester PUBLIC cameo zmq)
add_executable(publisherloop src/tests/PublisherLoop.cpp)
target_link_libraries(publisherloop PUBLIC cameo zmq)
add_executable(testcancel src/tests/TestCancel.cpp)
target_link_libraries(testcancel PUBLIC cameo zmq pthread)
......@@ -124,13 +130,8 @@ target_link_libraries(testsubscriberandpublishertwo PUBLIC cameo zmq)
add_executable(testpublisherloop src/tests/TestPublisherLoopApplication.cpp)
target_link_libraries(testpublisherloop PUBLIC cameo zmq)
add_executable(testcancel src/tests/TestCancelApplication.cpp)
target_link_libraries(testcancel PUBLIC cameo zmq pthread)
add_executable(testtimeout src/tests/TestTimeoutApplication.cpp)
target_link_libraries(testtimeout PUBLIC cameo zmq)
......
......@@ -74,7 +74,7 @@ public class TestSelector {
outputThread.start();
}
System.out.println("\n*** Starting test " + appName + " ***");
System.out.println("\n*** Starting " + appName + " ***");
instance.waitFor();
// Terminate the thread and the server.
......@@ -82,7 +82,7 @@ public class TestSelector {
outputThread.waitFor();
}
System.out.println("*** Finished test " + appName + " ***");
System.out.println("*** Finished " + appName + " ***");
}
else {
System.out.println("*** No application ***");
......@@ -123,8 +123,7 @@ public class TestSelector {
apps.add("testsubscribercpp");
apps.add("testrespondercpp");
apps.add("testrequestercpp");
apps.add("cancelcpp");
apps.add("testcancelcpp");
return apps;
}
......@@ -140,6 +139,8 @@ public class TestSelector {
apps.add("testpublisherpy");
apps.add("testsubscriberpy");
apps.add("testresponderpy");
apps.add("testrequesterpy");
apps.add("testcancelpy");
return apps;
}
......@@ -168,7 +169,6 @@ public class TestSelector {
argsIndex = 1;
try {
boolean all = false;
String appName;
String[] appArgs;
......
......@@ -20,26 +20,26 @@ import fr.ill.ics.cameo.Application;
import fr.ill.ics.cameo.RemoteException;
public class TestPublisherLoopApplication {
public class PublisherLoop {
public static void main(String[] args) {
Application.This.init(args);
try {
System.out.println("creating publisher and waiting for 1 subscriber...");
System.out.println("Creating publisher and waiting for 1 subscriber...");
// create the publisher
// Create the publisher.
Application.Publisher publisher = Application.Publisher.create("publisher", 1);
// synchronize with subscribers
// Synchronize with subscribers.
publisher.waitForSubscribers();
System.out.println("synchronized with the subscriber");
System.out.println("Synchronized with the subscriber");
Application.This.setRunning();
// sending data
// Sending data.
while (!publisher.isEnded()) {
publisher.send("hello");
......@@ -51,14 +51,13 @@ public class TestPublisherLoopApplication {
}
} catch (RemoteException e) {
System.out.println("publisher error");
System.out.println("Publisher error");
} finally {
// Do not forget to terminate This.
Application.This.terminate();
}
System.out.println("finished the application");
System.out.println("Finished the application");
}
}
\ No newline at end of file
......@@ -23,7 +23,7 @@ public class TestBadEndpoint {
public static void main(String[] args) {
try {
Server server = new Server("tcp://ferrazpc.ill.fr:7000", 1000);
new Server("tcp://abcd.ill.fr:7000", 1000);
}
catch (Exception e) {
System.out.println("The server has bad endpoint");
......
......@@ -21,25 +21,20 @@ import fr.ill.ics.cameo.Application.This;
import fr.ill.ics.cameo.RemoteException;
public class TestCancelApplication {
public class TestCancel {
public static void main(String[] args) {
Application.This.init(args);
if (Application.This.isAvailable()) {
System.out.println("connected");
}
try {
// Test This.cancelWaitings
// Test This.cancelWaitings.
{
System.out.println("starting stopjava for cancelWaitings");
System.out.println("Starting stopjava for cancelWaitings");
Application.Instance stopApplication = This.getServer().start("stopjava");
// Start thread
// Start thread.
Thread cancel = new Thread(new Runnable() {
@Override
public void run() {
......@@ -56,19 +51,19 @@ public class TestCancelApplication {
stopApplication.waitFor();
System.out.println("end of waitFor");
System.out.println("End of waitFor");
stopApplication.stop();
int state = stopApplication.waitFor();
System.out.println("end of stopjava with state " + Application.State.toString(state));
System.out.println("End of stopjava with state " + Application.State.toString(state));
cancel.join();
}
// Test Instance.cancelWaitFor
// Test Instance.cancelWaitFor.
{
System.out.println("starting stopjava for cancelWaitFor");
System.out.println("Starting stopjava for cancelWaitFor");
final Application.Instance stopApplication = This.getServer().start("stopjava");
......@@ -89,19 +84,19 @@ public class TestCancelApplication {
stopApplication.waitFor();
System.out.println("end of waitFor");
System.out.println("End of waitFor");
stopApplication.stop();
int state = stopApplication.waitFor();
System.out.println("end of stopjava with state " + Application.State.toString(state));
System.out.println("End of stopjava with state " + Application.State.toString(state));
cancel.join();
}
// Test Publisher.cancelWaitForSubscribers
// Test Publisher.cancelWaitForSubscribers.
{
System.out.println("creating publisher and waiting for 1 subscriber...");
System.out.println("Creating publisher and waiting for 1 subscriber...");
// create the publisher
final Application.Publisher publisher = Application.Publisher.create("publisher", 1);
......@@ -120,20 +115,20 @@ public class TestCancelApplication {
cancel.start();
System.out.println("wait for subscribers");
System.out.println("Wait for subscribers");
boolean synced = publisher.waitForSubscribers();
cancel.join();
System.out.println("synchronization with the subscriber synced ? " + synced);
System.out.println("Synchronization with the subscriber " + synced);
}
// Test the killing of the application.
{
System.out.println("starting publoopjava for killing");
System.out.println("Starting publisherloopjava for killing");
final Application.Instance pubLoopApplication = This.getServer().start("publoopjava");
final Application.Instance pubLoopApplication = This.getServer().start("publisherloopjava");
// Start thread
Thread cancel = new Thread(new Runnable() {
......@@ -155,19 +150,19 @@ public class TestCancelApplication {
while (true) {
String data = subscriber.receiveString();
if (data == null) {
System.out.println("exiting loop");
System.out.println("Exiting loop");
break;
} else {
System.out.println("received " + data);
System.out.println("Received " + data);
}
}
System.out.println("subscriber end of stream " + subscriber.isEnded());
System.out.println("Subscriber end of stream " + subscriber.isEnded());
int state = pubLoopApplication.waitFor();
System.out.println("end of waitFor " + Application.State.toString(state));
System.out.println("End of waitFor " + Application.State.toString(state));
cancel.join();
}
......@@ -178,11 +173,11 @@ public class TestCancelApplication {
} catch (InterruptedException e) {
}
// Test the Responder
// Test the Responder.
{
System.out.println("creating responder and waiting for requests");
System.out.println("Creating responder and waiting for requests");
// create the publisher
// Create the publisher.
final Application.Responder responder = Application.Responder.create("responder");
Thread cancel = new Thread(new Runnable() {
......@@ -199,28 +194,27 @@ public class TestCancelApplication {
cancel.start();
System.out.println("wait for requests");
System.out.println("Wait for requests");
Application.Request request = responder.receive();
if (request != null) {
System.err.println("responder error: receive should return null");
System.err.println("Responder error: receive should return null");
}
cancel.join();
}
} catch (RemoteException e) {
System.err.println("publisher error");
System.err.println("Publisher error");
} catch (InterruptedException e) {
} finally {
// Do not forget to terminate This
Application.This.terminate();
}
System.out.println("finished the application");
System.out.println("Finished the application");
}
}
\ No newline at end of file
......@@ -19,7 +19,6 @@ package fr.ill.ics.cameo.test;
import java.util.List;
import fr.ill.ics.cameo.Application;
import fr.ill.ics.cameo.ConnectionTimeout;
import fr.ill.ics.cameo.PublisherCreationException;
import fr.ill.ics.cameo.Server;
......
......@@ -117,6 +117,15 @@
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestRequester requesterjava"/>
</application>
<application name="publisherloopjava" starting_time="inf" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.PublisherLoop"/>
</application>
<application name="testcanceljava" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestCancel"/>
</application>
......@@ -131,10 +140,6 @@
</application>
<application name="publoopjava" starting_time="inf" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestPublisherLoopApplication"/>
</application>
<application name="subpubjava" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestSubscriberAndPublisherApplication"/>
</application>
......@@ -155,11 +160,6 @@
<application name="canceljava" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestCancelApplication"/>
</application>
<application name="reqrepjava" starting_time="inf" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestRequesterAndResponderApplication"/>
</application>
......@@ -278,6 +278,14 @@
<start executable="testrequester" args="requestercpp"/>
</application>
<application name="publisherloopcpp" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="publisherloop"/>
</application>
<application name="testcancelcpp" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="testcancel"/>
</application>
......@@ -289,10 +297,6 @@
<application name="publoopcpp" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="testpublisherloop"/>
</application>
<application name="subpubcpp" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="testsubscriberandpublisher"/>
</application>
......@@ -307,10 +311,6 @@
<application name="cancelcpp" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="testcancel"/>
</application>
<application name="reqrepcpp" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="testrequesterandresponder"/>
</application>
......@@ -362,71 +362,79 @@
<!-- Python apps -->
<application name="simplepy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="simple.py"/>
<start executable="python3" args="-u python/tests/simple.py"/>
</application>
<application name="testsimplepy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="testsimple.py"/>
<start executable="python3" args="-u python/tests/testsimple.py"/>
</application>
<application name="veryfastpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="veryfast.py"/>
<start executable="python3" args="-u python/tests/veryfast.py"/>
</application>
<application name="testveryfastpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="testveryfast.py"/>
<start executable="python3" args="-u python/tests/testveryfast.py"/>
</application>
<application name="teststoppy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="teststop.py"/>
<start executable="python3" args="-u python/tests/teststop.py"/>
</application>
<application name="resultpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="result.py"/>
<start executable="python3" args="-u python/tests/result.py"/>
</application>
<application name="testresultpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="testresult.py"/>
<start executable="python3" args="-u python/tests/testresult.py"/>
</application>
<application name="errorpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="error.py"/>
<start executable="python3" args="-u python/tests/error.py"/>
</application>
<application name="testerrorpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="testerror.py"/>
<start executable="python3" args="-u python/tests/testerror.py"/>
</application>
<application name="publisherpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="publisher.py"/>
<start executable="python3" args="-u python/tests/publisher.py"/>
</application>
<application name="testpublisherpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="testpublisher.py" args="publisherpy"/>
<start executable="python3" args="-u python/tests/testpublisher.py publisherpy"/>
</application>
<application name="subscriberpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="yes" restart="no">
<start executable="subscriber.py"/>
<start executable="python3" args="-u python/tests/subscriber.py"/>
</application>
<application name="testsubscriberpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="testsubscriber.py" args="subscriberpy"/>
<start executable="python3" args="-u python/tests/testsubscriber.py subscriberpy"/>
</application>
<application name="responderpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="yes" restart="no">
<start executable="responder.py"/>
<start executable="python3" args="-u python/tests/responder.py"/>
</application>
<application name="testresponderpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="testresponder.py" args="responderpy"/>
<start executable="python3" args="-u python/tests/testresponder.py responderpy"/>
</application>
<application name="requesterpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="yes" restart="no">
<start executable="requester.py"/>
<start executable="python3" args="-u python/tests/requester.py"/>
</application>
<application name="testrequesterpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="testrequester.py" args="requesterpy"/>
<start executable="python3" args="-u python/tests/testrequester.py requesterpy"/>
</application>
<application name="publisherlooppy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="python3" args="-u python/tests/publisherloop.py"/>
</application>
<application name="testcancelpy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="python3" args="-u python/tests/testcancel.py"/>
</application>
......
#!/usr/bin/python3 -u
import time
import sys
......
#!/usr/bin/python3 -u
import sys
import cameopy
......@@ -7,7 +5,7 @@ this = cameopy.This
this.init(sys.argv)
numberOfSubscribers = 1 if len(sys.argv) < 3 else int(sys.argv[1])
print("Number of subscribers:", numberOfSubscribers)
print("Number of subscribers", numberOfSubscribers)
print("Creating publisher and waiting for ", numberOfSubscribers, "subscriber(s)...")
......
import sys
import time
import cameopy
this = cameopy.This
this.init(sys.argv)
publisher = cameopy.Publisher.create("publisher", 1)
publisher.waitForSubscribers()
this.setRunning()
print("Synchronized with the subscriber")
while (True):
publisher.send("hello")
time.sleep(0.1)
print("Finished the application")
#!/usr/bin/python3 -u
import sys
import time
import cameopy
......
#!/usr/bin/python3 -u
import sys
import cameopy
......
#!/usr/bin/python3 -u
import sys
import cameopy
......
#!/usr/bin/python3 -u
import sys
import cameopy
......
#!/usr/bin/python3 -u
import sys
import cameopy
......
import sys
import time
import threading
import cameopy
def cancelAll():
time.sleep(1)
cameopy.This.cancelWaitings()
def cancelWaitFor(instance):
time.sleep(1)
instance.cancelWaitFor()
def cancelWaitForSubscribers(publisher):
time.sleep(1)
publisher.cancelWaitForSubscribers()
def killApplication(app):
time.sleep(1)
app.kill()
this = cameopy.This
this.init(sys.argv)
server = this.getServer()
def testCancelAll():
print("Starting stopcpp for cancelWaitings")
app = server.start("stopcpp", 0)
# Start thread.
t = threading.Thread(target=cancelAll)
t.start()
app.waitFor()
print("End of waitFor")
app.stop()
state = app.waitFor()
t.join()
print("End of stopcpp with state", state)
def testCancelWaitFor():
print("Starting stopcpp for cancelWaitFor")
app = server.start("stopcpp", 0)
# Start thread.
t = threading.Thread(target=cancelWaitFor, args=(app,))
t.start()
app.waitFor()
print("End of waitFor")
app.stop()
state = app.waitFor()
t.join()
print("End of stopcpp with state", state)
def testCancelWaitForSubscribers():
print("Creating publisher and waiting for 1 subscriber...")
publisher = cameopy.Publisher.create("publisher", 1)
# Start thread.
t = threading.Thread(target=cancelWaitForSubscribers, args=(publisher,))