2022-09-26 14:19:21 +02:00
|
|
|
import sys
|
|
|
|
|
import os
|
|
|
|
|
import time
|
|
|
|
|
import multiprocessing
|
|
|
|
|
|
2026-03-04 16:27:33 +01:00
|
|
|
import pytest
|
|
|
|
|
|
2022-09-26 14:19:21 +02:00
|
|
|
sys.path.insert(1, os.path.join(sys.path[0], "../../"))
|
|
|
|
|
import rips
|
|
|
|
|
|
|
|
|
|
|
2025-10-01 08:10:03 +02:00
|
|
|
def test_launch_non_existing(rips_instance, initialize_test):
|
2026-03-04 16:27:33 +01:00
|
|
|
with pytest.raises(rips.RipsError):
|
|
|
|
|
rips.Instance.launch("non_existing", console=True)
|
2025-10-01 08:10:03 +02:00
|
|
|
|
|
|
|
|
|
2022-09-26 14:19:21 +02:00
|
|
|
def launch_resinsight(sec=1):
|
2025-01-10 18:25:46 +01:00
|
|
|
resinsight_executable_from_env = os.environ.get("RESINSIGHT_EXECUTABLE")
|
|
|
|
|
if resinsight_executable_from_env is None:
|
|
|
|
|
print("RESINSIGHT_EXECUTABLE environment variable is not set")
|
|
|
|
|
return
|
2022-09-26 14:19:21 +02:00
|
|
|
instance = rips.Instance.launch(console=True, launch_port=0)
|
|
|
|
|
print(instance.location)
|
|
|
|
|
|
|
|
|
|
print(f"Sleeping for {sec} second(s): ", instance.location)
|
|
|
|
|
time.sleep(sec)
|
2025-05-16 15:46:45 +02:00
|
|
|
print("Done sleeping", instance.location)
|
2022-09-26 14:19:21 +02:00
|
|
|
|
|
|
|
|
instance.exit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_launch_sequential(rips_instance, initialize_test):
|
2025-01-10 18:25:46 +01:00
|
|
|
resinsight_executable_from_env = os.environ.get("RESINSIGHT_EXECUTABLE")
|
|
|
|
|
if resinsight_executable_from_env is None:
|
|
|
|
|
print("RESINSIGHT_EXECUTABLE environment variable is not set")
|
|
|
|
|
return
|
2022-09-26 14:19:21 +02:00
|
|
|
instance_list = []
|
|
|
|
|
for i in range(4):
|
|
|
|
|
rips_instance = rips.Instance.launch(console=True)
|
|
|
|
|
instance_list.append(rips_instance)
|
|
|
|
|
|
|
|
|
|
for instance in instance_list:
|
|
|
|
|
print(instance)
|
|
|
|
|
instance.exit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_launch_parallell(rips_instance, initialize_test):
|
2025-01-10 18:25:46 +01:00
|
|
|
resinsight_executable_from_env = os.environ.get("RESINSIGHT_EXECUTABLE")
|
|
|
|
|
if resinsight_executable_from_env is None:
|
|
|
|
|
print("RESINSIGHT_EXECUTABLE environment variable is not set")
|
|
|
|
|
return
|
|
|
|
|
|
2022-09-26 14:19:21 +02:00
|
|
|
process_list = []
|
|
|
|
|
|
|
|
|
|
instance_count = 10
|
|
|
|
|
for i in range(instance_count):
|
|
|
|
|
process = multiprocessing.Process(target=launch_resinsight)
|
|
|
|
|
process_list.append(process)
|
|
|
|
|
|
|
|
|
|
for process in process_list:
|
|
|
|
|
process.start()
|
|
|
|
|
|
|
|
|
|
# completing process
|
|
|
|
|
for p in process_list:
|
|
|
|
|
p.join()
|