def graphics_test() -> None:
    from utility.constants import DATA_PATH, TEST_DATA_PATH
    import pyautogui

    # pick RRT Connect algorithm
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'algorithm_new.png'),
                                          confidence=0.55)
    pyautogui.click(x + 150, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'rrt_connect.png'),
                                          confidence=0.8)
    pyautogui.click(x, y)

    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'update.png'),
                                          confidence=0.5)
    pyautogui.click(x, y)

    wait_for('initialised.png')

    # make obstacles transparent for a better ss comparison
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'obstacles_new.png'),
                                          confidence=0.75)
    pyautogui.click(x - 115, y)

    # run algo
    pyautogui.press('t')
    wait_for('done.png')

    take_screenshot("RRT_Connect_test_3D.png", threshold=350)
def graphics_test() -> None:
    from utility.constants import DATA_PATH, TEST_DATA_PATH
    import pyautogui

    # Select map Labyrinth, Potential Field algorithm
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'map.png'),
                                          confidence=0.5)
    pyautogui.click(x + 160, y + 5)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'labyrinth_new.png'),
                                          confidence=0.5)
    pyautogui.click(x, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'algorithm_new.png'),
                                          confidence=0.5)
    pyautogui.click(x + 150, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'potential_field.png'),
                                          confidence=0.7)
    pyautogui.click(x, y)

    # start and end goals coordinate input
    pyautogui.click(342, 545)
    pyautogui.write('17')
    pyautogui.doubleClick(422, 545)
    pyautogui.write('15')
    pyautogui.doubleClick(342, 617)
    pyautogui.write('17')
    pyautogui.doubleClick(422, 617)
    pyautogui.write('4')

    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'update.png'),
                                          confidence=0.5)
    pyautogui.click(x, y)
    wait_for('initialised.png')

    # pick colours and do other modifications on the map
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'traversables_new.png'),
                                          confidence=0.5)
    pyautogui.click(x - 85, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'lime.png'),
                                          confidence=0.9)
    pyautogui.click(x, y)

    pyautogui.press('t')
    wait_for('done.png')
    take_screenshot("potential_field_2d.png")
def do_cert_test(mgr, temp_chains, client_ca_certs,
                 server_trusted_client_certs, cert_to_names):
    install_keystore()
    setup_tls_config(mgr, server_trusted_client_certs, cert_to_names)

    def openssl_connect():
        with open(os.devnull, "r") as n:
            subprocess.check_call(
                "openssl s_client -connect localhost:6513 -CAfile {ca_certs} -cert {certfile} -key {keyfile} "
                "-state -debug -showcerts -verify_return_error -verify 1 2>&1".
                format(
                    keyfile=CLIENT_LEAF_KEY,
                    certfile=CLIENT_LEAF,
                    ca_certs=temp_chains.create(client_ca_certs),
                ),
                shell=True,
                stdin=n,
            )

    wait_for(openssl_connect, timeout=30, period=0.5)
Exemple #4
0
def graphics_test() -> None:
    from utility.constants import DATA_PATH, TEST_DATA_PATH
    import pyautogui


    # pick RRT algorithm
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'algorithm_new.png'), confidence=0.55)
    pyautogui.click(x + 150, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'rrt2.png'), confidence=0.9)
    pyautogui.click(x, y)

    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'update.png'), confidence=0.5)
    pyautogui.click(x, y)

    wait_for('initialised.png')

    # run algo
    pyautogui.press('t')
    wait_for('done.png')

    take_screenshot("RRT_test_2D.png", threshold=350)
Exemple #5
0
def services():
    """Start the services"""
    subprocess.check_call("echo root:password | chpasswd", shell=True)
    subprocess.check_call("supervisord")

    wait_for(connect_mgr, timeout=60, period=0.5).close_session()
    wait_for(test_send_notification_service_ready, timeout=60, period=0.5)
    wait_for(test_set_action_reply_service_ready, timeout=60, period=0.5)
Exemple #6
0
def graphics_test() -> None:
    from utility.constants import DATA_PATH, TEST_DATA_PATH
    import pyautogui

    # Select map Labyrinth, A* algorithm, update
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'map.png'), confidence=0.6)
    pyautogui.click(x + 160, y + 5)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'labyrinth_new.png'), confidence=0.5)
    pyautogui.click(x, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'algorithm_new.png'), confidence=0.6)
    pyautogui.click(x + 150, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'a_star.png'), confidence=0.6)
    pyautogui.click(x, y)

    # start and end goals coordinate input
    pyautogui.click(342, 545)
    pyautogui.write('17')
    pyautogui.doubleClick(422, 545)
    pyautogui.write('9')
    pyautogui.doubleClick(342, 617)
    pyautogui.write('6')
    pyautogui.doubleClick(422, 617)
    pyautogui.write('4')

    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'update.png'), confidence=0.6)
    pyautogui.click(x, y)

    wait_for('initialised.png')
    wait_for('traversables_new.png')

    # pick colours and other modifications of the map
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'traversables_new.png'), confidence=0.5)
    pyautogui.click(x - 85, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'lightblue.png'), confidence=0.8)
    pyautogui.click(x, y)

    pyautogui.press('t')
    wait_for('done.png')

    take_screenshot("labyrinth_A_1.png", threshold=350)

    wait_for('traversables_new.png')

    # make traversables transparent
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'traversables_new.png'), confidence=0.5)
    pyautogui.click(x - 125, y)

    take_screenshot("labyrinth_A_2.png", threshold=350)
Exemple #7
0
def services(nacm_off):
    """Start the services"""
    if not os.path.isfile("/var/run/supervisord.pid"):
        subprocess.check_call("echo root:password | chpasswd", shell=True)
        subprocess.check_call("supervisord")

    wait_for(connect_mgr, timeout=20, period=0.5).close_session()
    wait_for(test_send_notification_service_ready, timeout=60, period=0.5)
    wait_for(test_set_action_reply_service_ready, timeout=60, period=0.5)
def graphics_test() -> None:
    from utility.constants import DATA_PATH, TEST_DATA_PATH
    import pyautogui

    # Pick Uniform Random Fill 3D with Potential Field
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'map.png'),
                                          confidence=0.5)
    pyautogui.click(x + 160, y + 5)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'uniform.png'),
                                          confidence=0.9)
    pyautogui.click(x, y)
    time.sleep(0.5)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'algorithm_new.png'),
                                          confidence=0.55)
    pyautogui.click(x + 150, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'potential_field.png'),
                                          confidence=0.7)
    pyautogui.click(x, y)

    # start and end goals coordinate input
    pyautogui.click(342, 545)
    pyautogui.write('6')
    pyautogui.doubleClick(422, 545)
    pyautogui.write('1')
    pyautogui.doubleClick(502, 545)
    pyautogui.write('2')
    time.sleep(0.5)
    pyautogui.doubleClick(342, 617)
    pyautogui.write('6')
    time.sleep(0.5)
    pyautogui.doubleClick(422, 617)
    pyautogui.write('5')
    pyautogui.doubleClick(502, 617)
    pyautogui.write('5')

    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'update.png'),
                                          confidence=0.5)
    pyautogui.click(x, y)

    wait_for('initialised.png')
    wait_for('traversables_new.png')

    # make traversables transparent for the RRT
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'traversables_new.png'),
                                          confidence=0.5)
    pyautogui.click(x - 120, y)

    # run algo
    pyautogui.press('t')
    wait_for('done.png', confidence=0.8)
    take_screenshot("potential_field_3d.png")
Exemple #9
0
def test_record_cancel(tmp_path):
    bag_path = str(tmp_path / 'test_record_cancel')
    storage_options, converter_options = get_rosbag_options(bag_path)

    recorder = rosbag2_py.Recorder()

    record_options = rosbag2_py.RecordOptions()
    record_options.all = True
    record_options.is_discovery_disabled = False
    record_options.topic_polling_interval = datetime.timedelta(
        milliseconds=100)

    rclpy.init()
    record_thread = threading.Thread(target=recorder.record,
                                     args=(storage_options, record_options),
                                     daemon=True)
    record_thread.start()

    node = rclpy.create_node('test_record_cancel')
    executor = rclpy.executors.SingleThreadedExecutor()
    executor.add_node(node)
    pub = node.create_publisher(String, 'chatter', 10)

    i = 0
    msg = String()

    while rclpy.ok() and i < 10:
        msg.data = 'Hello World: {0}'.format(i)
        i += 1
        pub.publish(msg)

    recorder.cancel()

    metadata_path = Path(bag_path) / 'metadata.yaml'
    db3_path = Path(bag_path) / 'test_record_cancel_0.db3'
    assert wait_for(lambda: metadata_path.is_file() and db3_path.is_file(),
                    timeout=rclpy.duration.Duration(seconds=3))
Exemple #10
0
def graphics_test() -> None:
    from utility.constants import DATA_PATH, TEST_DATA_PATH
    import pyautogui

    # Pick 3d cube with A*
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'map.png'),
                                          confidence=0.5)
    pyautogui.click(x + 160, y + 5)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       '3d_cube.png'),
                                          confidence=0.9)
    pyautogui.click(x, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'algorithm_new.png'),
                                          confidence=0.5)
    pyautogui.click(x + 150, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'a_star.png'),
                                          confidence=0.5)
    pyautogui.click(x, y)

    # start and end goals coordinate input
    pyautogui.click(342, 545)
    pyautogui.write('1')
    pyautogui.doubleClick(422, 545)
    pyautogui.write('1')
    pyautogui.doubleClick(502, 545)
    pyautogui.write('1')
    time.sleep(0.5)
    pyautogui.doubleClick(342, 617)
    pyautogui.write('13')
    time.sleep(0.5)
    pyautogui.doubleClick(422, 617)
    pyautogui.write('1')
    pyautogui.doubleClick(502, 617)
    pyautogui.write('13')

    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'update.png'),
                                          confidence=0.5)
    pyautogui.click(x, y)

    wait_for('initialised.png')

    # run algo
    pyautogui.press('t')

    wait_for('traversables_new.png')

    # pick colours and other modifications of the map
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'traversables_new.png'),
                                          confidence=0.5)
    pyautogui.click(x - 85, y)
    time.sleep(0.5)

    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'colour_1.png'),
                                          confidence=0.7)
    pyautogui.click(x, y)
    time.sleep(0.5)

    wait_for('traversables_new.png')
    wait_for('done.png')

    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'traversables_new.png'),
                                          confidence=0.5)
    pyautogui.click(x - 125, y)
    time.sleep(0.6)
    take_screenshot("3d_A_1.png")

    wait_for('traversables_new.png')

    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'traversables_new.png'),
                                          confidence=0.5)
    pyautogui.click(x - 125, y)

    take_screenshot("3d_A_2.png")
Exemple #11
0
def graphics_test() -> None:
    from utility.constants import DATA_PATH, TEST_DATA_PATH
    import pyautogui

    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'map.png'),
                                          confidence=0.5)
    pyautogui.click(x + 160, y + 5)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'labyrinth_new.png'),
                                          confidence=0.5)
    pyautogui.click(x, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'algorithm_new.png'),
                                          confidence=0.5)
    pyautogui.click(x + 150, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'a_star.png'),
                                          confidence=0.5)
    pyautogui.click(x, y)

    # start and end goals coordinate input
    pyautogui.click(342, 545)
    pyautogui.write('17')
    pyautogui.doubleClick(422, 545)
    pyautogui.write('9')
    pyautogui.doubleClick(342, 617)
    pyautogui.write('4')
    pyautogui.doubleClick(422, 617)
    pyautogui.write('5')

    # update
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'update.png'),
                                          confidence=0.5)
    pyautogui.click(x, y)
    wait_for('initialised.png')

    # go into state 1
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'one.png'),
                                          confidence=0.7)
    pyautogui.click(x, y)

    # pick colors and other modifications of the map
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'traversables_new.png'),
                                          confidence=0.5)
    pyautogui.click(x - 83, y)
    time.sleep(0.5)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'orange.png'),
                                          confidence=0.9)
    pyautogui.click(x, y)
    time.sleep(0.5)

    # run
    pyautogui.press('t')
    wait_for('done.png')
    time.sleep(0.2)

    # change trace color
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'trace.png'),
                                          confidence=0.8)
    pyautogui.click(x - 70, y)
    time.sleep(0.5)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'colour_1.png'),
                                          confidence=0.8)
    pyautogui.click(x, y)
    time.sleep(1.5)

    transparent_1 = take_screenshot()
    time.sleep(1)

    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'save.png'),
                                          confidence=0.7)
    pyautogui.click(x, y)
    time.sleep(2)

    # go to state 2
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'two.png'),
                                          confidence=0.7)
    pyautogui.click(x, y)

    transparent_2 = take_screenshot()

    # change colors
    time.sleep(0.5)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'traversables_new.png'),
                                          confidence=0.5)
    pyautogui.click(x - 85, y)
    time.sleep(0.5)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'lime.png'),
                                          confidence=0.9)
    pyautogui.click(x, y)
    time.sleep(0.5)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'trace.png'),
                                          confidence=0.8)
    pyautogui.click(x - 70, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'lightblue.png'),
                                          confidence=0.7)
    pyautogui.click(x, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'visited.png'),
                                          confidence=0.7)
    pyautogui.click(x - 70, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'colour_2.png'),
                                          confidence=0.7)
    pyautogui.click(x, y)

    # test restore changes
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'restore.png'),
                                          confidence=0.7)
    pyautogui.click(x, y)
    time.sleep(1.5)

    transparent_restored_2 = take_screenshot()

    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'one.png'),
                                          confidence=0.7)
    pyautogui.click(x, y)
    time.sleep(2.5)

    transparent_restored_1 = take_screenshot()

    # check if all states are working
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'three.png'),
                                          confidence=0.9)
    pyautogui.click(x, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'four.png'),
                                          confidence=0.9)
    pyautogui.click(x, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'five.png'),
                                          confidence=0.9)
    pyautogui.click(x, y)
    x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH,
                                                       'six.png'),
                                          confidence=0.9)
    pyautogui.click(x, y)

    compare_images(transparent_restored_1, transparent_1, threshold=1)
    compare_images(transparent_restored_2, transparent_2, threshold=1)
Exemple #12
0
def setup():
    download_terraform()
    print(
        "Attempting to setup rancher host... May take a while due to spot instance  availability..."
    )
    wait_for(setup_host)