From 6412d12fa73018177367dfe809598880376b9d3a Mon Sep 17 00:00:00 2001 From: youliang Date: Wed, 12 May 2021 10:57:41 +0800 Subject: [PATCH 1/5] add integration test Signed-off-by: youliang --- .rmf_schedule_node.yaml | 30 +++++ tests/integration_test.py | 235 ++++++++++++++++++++++++++++++++++++++ web_server.log | 56 +++++++++ 3 files changed, 321 insertions(+) create mode 100644 .rmf_schedule_node.yaml create mode 100644 tests/integration_test.py create mode 100644 web_server.log diff --git a/.rmf_schedule_node.yaml b/.rmf_schedule_node.yaml new file mode 100644 index 00000000..07123ec5 --- /dev/null +++ b/.rmf_schedule_node.yaml @@ -0,0 +1,30 @@ +- operation: Add + participant_description: + name: tinyRobot1 + group: tinyRobot + responsiveness: Responsive + profile: + footprint: + type: Circle + index: "\x00" + vicinity: + type: Circle + index: "\x01" + shape_context: + - 0.3 + - 1 +- operation: Add + participant_description: + name: tinyRobot2 + group: tinyRobot + responsiveness: Responsive + profile: + footprint: + type: Circle + index: "\x00" + vicinity: + type: Circle + index: "\x01" + shape_context: + - 0.3 + - 1 \ No newline at end of file diff --git a/tests/integration_test.py b/tests/integration_test.py new file mode 100644 index 00000000..64046695 --- /dev/null +++ b/tests/integration_test.py @@ -0,0 +1,235 @@ +#!/usr/bin/env python3 + +# Copyright 2021 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys +import subprocess +import signal +import requests +import time +import json + +api_server_url = 'http://localhost:8080/' + +office_tasks = [ + {"task_type": "Loop", "start_time": 0, "description": + {"start_name": "coe", "finish_name": "supplies", "num_loops": 1}}, + # TODO: Fix delivery not working + {"task_type": "Delivery", "start_time": 0, "description": + {"pickup_place_name": "pantry", + "pickup_dispenser": "coke_dispenser", + "dropoff_place_name": "hardware_2", + "dropoff_ingestor": "coke_ingestor"}}, + {"task_type": "Loop", "start_time": 0, "description": + {"start_name": "lounge", "finish_name": "coe", "num_loops": 1}} +] + +airport_terminal_tasks = [ + {"task_type": "Clean", "start_time": 0, "priority": 0, + "description": {"cleaning_zone": "zone_1"}}, + {"task_type": "Clean", "start_time": 0, "priority": 0, + "description": {"cleaning_zone": "zone_4"}}, + {"task_type": "Loop", "start_time": 0, "priority": 1, "description": + {"num_loops": 2, "start_name": "n23", "finish_name": "n24"}} + # TODO: mop cart will drop when step size is high, thus wont test this + # {"task_type": "Delivery", "start_time": 0, "description": + # {"pickup_place_name": "mopcart_pickup", + # "pickup_dispenser": "mopcart_dispenser", + # "dropoff_place_name": "spill", + # "dropoff_ingestor": "mopcart_collector"}} +] + +clinic_tasks = [ + {"task_type": "Loop", "start_time": 0, "priority": 0, "description": + {"num_loops": 1, + "start_name": "L1_left_treatment_1", + "finish_name": "L2_sub_waiting_area_1"}}, + {"task_type": "Loop", "start_time": 0, "priority": 0, "description": + {"num_loops": 1, + "start_name": "L1_left_nurse_center", + "finish_name": "L2_south_counter"}}, + {"task_type": "Loop", "start_time": 1, "priority": 0, "description": + {"num_loops": 1, + "start_name": "L2_left_nurse_center", + "finish_name": "L2_sub_waiting_area_2"}}, + {"task_type": "Loop", "start_time": 2, "priority": 0, "description": + {"num_loops": 1, + "start_name": "L2_north_counter", + "finish_name": "L1_right_nurse_center"}} +] + + +class RMFSenarioTest: + + def __init__( + self, + world_name: str, + total_robots: int, + timeout_sec=50): + """ + world_name arg: Launch file world name + total_robots arg: number of robots in the world + timeout_sec arg: Time out for init + """ + self.world_name = world_name + launch_cmd = (f"ros2 launch rmf_demos {world_name}.launch.xml" + " headless:=1") + print(f" Initialize command [{launch_cmd}]") + self.proc1 = subprocess.Popen(launch_cmd, + # stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + shell=True, preexec_fn=os.setsid) + + # Here we will check if the robot state is avail to determine whether + # the rmf world has launched successfully. + # Periodically Checks the tasks till timeout + start = time.time() + robot_states_res = None + while True: + if ((time.time() - start) > timeout_sec): + raise RuntimeError(f"TimeOut in launching: {launch_cmd}, " + f"Get request, res: {robot_states_res}") + time.sleep(2) + try: + r = requests.get(url=api_server_url + "robot_list") + except requests.exceptions.ConnectionError: + continue + if (r.status_code != 200): + continue + + robot_states_res = r.json() + if (len(robot_states_res) == total_robots): + break + + # Warm up + print(f"World is ready, received status from {total_robots} robots") + time.sleep(2) + + # This is to speed up the simulation + self.proc2 = subprocess.Popen("gz physics -s 0.01", shell=True) + time.sleep(4) + + # Check if intermediate command is success + self.proc1.poll() + self.proc2.poll() + print(f"kill: {self.proc1.returncode} {self.proc2.returncode}") + + if (self.proc2.returncode != 0): # 0 means good + raise RuntimeError("gz physics -s: Command Error") + + def __del__(self): + print(f"Destructor is called! \n") + self.stop() + + def stop(self): + # Send the signal to all the process groups in gazebo launch + os.killpg(os.getpgid(self.proc1.pid), signal.SIGTERM) + self.proc2.kill() + self.proc1.poll() + self.proc2.poll() + + def start( + self, + task_requests: list, + timeout_sec: int): + """ + This will start the intergration test by sending multiple task + requests to rmf. Return True if all tasks passed, else false. + + TODO: should use ros_time as timeout + """ + print(f"Start senario with {len(task_requests)} requests") + for req in task_requests: + print(" - request a task: ", req) + r = requests.post(api_server_url + 'submit_task', json=req) + time.sleep(1) + if (r.status_code != 200): + print("Failed to connect api-server: not 200") + return False + if (r.json == ""): + print("Task Submission failed!", r.json()) + return False + + # Periodically Checks the tasks + start = time.time() + while ((time.time() - start) < timeout_sec): + time.sleep(3) + r = requests.get(url=api_server_url + "task_list") + + if (r.status_code != 200): + print("Not able to get tasklist from api-server") + return + + success_count = 0 + for task in r.json(): + print(f"task: {task['task_id']} \t " + f"| robot: {task['robot_name']} \t" + f"| state: {task['state']} ") + if (task['state'] == 'Completed'): + success_count += 1 + if (task['state'] == 'Failed'): + return False + print("------------"*5) + if success_count == len(task_requests): + print(f"[{self.world_name}] All {success_count} Tasks Passed") + return True + return False + + +############################################################################### + + +def main(args=None): + print("Starting integration test") + + ########################################################################### + # Test Senario 1: Office World with 3 requests + + office = RMFSenarioTest("office", 2) + success = office.start(office_tasks, 150) + office.stop() + del office + + if not success: + raise RuntimeError + + # ########################################################################### + # # Test Senario 2: Airport World with 3 requests + + airport = RMFSenarioTest("airport_terminal", 11) + success = airport.start(airport_terminal_tasks, 250) + airport.stop() + del airport + + if not success: + raise RuntimeError + + # ########################################################################### + # # Test Senario 3: Clinic World with 4 requests + + clinic = RMFSenarioTest("clinic", 4) + success = clinic.start(clinic_tasks, 600) + clinic.stop() + del clinic + + if not success: + raise RuntimeError + + print("====================== Successfully End All ======================") + + +if __name__ == "__main__": + main(sys.argv) diff --git a/web_server.log b/web_server.log new file mode 100644 index 00000000..fd8f1edb --- /dev/null +++ b/web_server.log @@ -0,0 +1,56 @@ +2021-04-14 17:18:20,020 DEBUG ROS Time: 0 | active tasks: 0 | terminated tasks: 0 | active robots: 0 +2021-04-14 17:18:22,023 DEBUG ROS Time: 0 | active tasks: 0 | terminated tasks: 0 | active robots: 0 +2021-04-14 17:18:24,029 DEBUG ROS Time: 0 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:26,037 DEBUG ROS Time: 2 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:28,046 DEBUG ROS Time: 4 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:30,053 DEBUG ROS Time: 6 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:32,064 DEBUG ROS Time: 8 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:34,076 DEBUG ROS Time: 10 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:36,094 DEBUG ROS Time: 12 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:38,103 DEBUG ROS Time: 14 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:40,111 DEBUG ROS Time: 16 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:42,123 DEBUG ROS Time: 18 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:44,149 DEBUG ROS Time: 20 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:46,164 DEBUG ROS Time: 21 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:48,176 DEBUG ROS Time: 23 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:50,184 DEBUG ROS Time: 25 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:52,195 DEBUG ROS Time: 27 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:54,210 DEBUG ROS Time: 29 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:56,220 DEBUG ROS Time: 31 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:18:58,250 DEBUG ROS Time: 33 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:00,265 DEBUG ROS Time: 35 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:02,277 DEBUG ROS Time: 37 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:04,299 DEBUG ROS Time: 39 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:06,307 DEBUG ROS Time: 41 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:08,316 DEBUG ROS Time: 42 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:10,336 DEBUG ROS Time: 44 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:12,347 DEBUG ROS Time: 46 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:14,357 DEBUG ROS Time: 48 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:16,396 DEBUG ROS Time: 50 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:18,427 DEBUG ROS Time: 52 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:20,441 DEBUG ROS Time: 54 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:22,449 DEBUG ROS Time: 56 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:24,459 DEBUG ROS Time: 58 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:26,470 DEBUG ROS Time: 60 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:28,492 DEBUG ROS Time: 62 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:30,510 DEBUG ROS Time: 64 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:32,536 DEBUG ROS Time: 66 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:34,549 DEBUG ROS Time: 68 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:36,565 DEBUG ROS Time: 69 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:38,588 DEBUG ROS Time: 71 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:40,597 DEBUG ROS Time: 73 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:42,614 DEBUG ROS Time: 75 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:44,623 DEBUG ROS Time: 77 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:46,649 DEBUG ROS Time: 79 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:48,659 DEBUG ROS Time: 81 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:50,688 DEBUG ROS Time: 83 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:52,714 DEBUG ROS Time: 85 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:54,722 DEBUG ROS Time: 87 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:56,744 DEBUG ROS Time: 89 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:19:58,781 DEBUG ROS Time: 91 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:20:00,791 DEBUG ROS Time: 93 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:20:02,815 DEBUG ROS Time: 95 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:20:04,824 DEBUG ROS Time: 96 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:20:06,834 DEBUG ROS Time: 98 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:20:09,101 DEBUG ROS Time: 99 | active tasks: 0 | terminated tasks: 0 | active robots: 2 +2021-04-14 17:20:11,107 DEBUG ROS Time: 99 | active tasks: 0 | terminated tasks: 0 | active robots: 2 From 3e99297dff96d6f7fc1f4638a92b2e98d7ec982a Mon Sep 17 00:00:00 2001 From: youliang Date: Wed, 12 May 2021 10:58:31 +0800 Subject: [PATCH 2/5] update build ci Signed-off-by: youliang --- .github/workflows/build.yaml | 39 +++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7d9d21b2..6eacf5ce 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -4,18 +4,47 @@ on: branches: [ main ] pull_request: branches: [ main ] + # schedule: + # # 2am SGT + # - cron: '0 18 * * *' jobs: - build-docker-images: - name: Push Docker image to GitHub Packages + build-docker-image: + name: build-docker-image runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: build rmf image and push to gh registry + # Merge to main/nightly, build image as: rmf_demos:latest + # Open PR, build image as: rmf_demos:test + - name: build rmf image and push to gh registry, default tag latest + if: ${{ github.event_name == 'push' }} uses: docker/build-push-action@v1 with: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} registry: docker.pkg.github.com repository: ${{ github.repository }}/rmf_demos - push: ${{ github.event_name == 'push' }} # update registry only during push to main - tags: latest + push: true + tags: ${{ github.event_name == 'pull_request' && 'test' || 'latest' }} + e2e-test: + name: rmf-test-senarios + needs: build-docker-image + runs-on: ubuntu-latest + container: + # Will use tag test if a open pr, for main, use latest + image: docker.pkg.github.com/tanyouliang95/rmf/rmf_demos:${{ github.event_name == 'pull_request' && 'test' || 'latest' }} + credentials: + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: checkout + uses: actions/checkout@v2 + with: + path: rmf/ + - name: run-tests + shell: bash + run: | + source /ros_entrypoint.sh + export HOME=/root # this is crucial for setting a correct path to .gazebo/models + echo "Start Integration Test" + python3 rmf/tests/integration_test.py + echo "Finish Integration Test" From f1ba9b9eb9537551d888f52f479ff02c70107474 Mon Sep 17 00:00:00 2001 From: youliang Date: Wed, 12 May 2021 12:42:23 +0800 Subject: [PATCH 3/5] fix incorrect build path Signed-off-by: youliang --- .github/workflows/build.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6eacf5ce..1912fb42 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -15,8 +15,7 @@ jobs: - uses: actions/checkout@v2 # Merge to main/nightly, build image as: rmf_demos:latest # Open PR, build image as: rmf_demos:test - - name: build rmf image and push to gh registry, default tag latest - if: ${{ github.event_name == 'push' }} + - name: build rmf image with ${{ github.event_name == 'pull_request' && 'test' || 'latest' }} tag uses: docker/build-push-action@v1 with: username: ${{ github.actor }} @@ -31,7 +30,7 @@ jobs: runs-on: ubuntu-latest container: # Will use tag test if a open pr, for main, use latest - image: docker.pkg.github.com/tanyouliang95/rmf/rmf_demos:${{ github.event_name == 'pull_request' && 'test' || 'latest' }} + image: docker.pkg.github.com/open-rmf/rmf/rmf_demos:${{ github.event_name == 'pull_request' && 'test' || 'latest' }} credentials: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} From d90c0219428ed4d032197c5d5105b0f6263adb6e Mon Sep 17 00:00:00 2001 From: youliang Date: Mon, 17 May 2021 15:32:36 +0800 Subject: [PATCH 4/5] update test with cancel task and use cyclone as default Signed-off-by: youliang --- .github/workflows/build.yaml | 7 ++-- Dockerfile | 5 ++- tests/integration_test.py | 71 +++++++++++++++++++++++++++--------- web_server.log | 56 ---------------------------- 4 files changed, 61 insertions(+), 78 deletions(-) delete mode 100644 web_server.log diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1912fb42..da4c1d35 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -4,9 +4,9 @@ on: branches: [ main ] pull_request: branches: [ main ] - # schedule: - # # 2am SGT - # - cron: '0 18 * * *' + schedule: + # 4pm, 2am SGT + - cron: '0 8,18 * * *' jobs: build-docker-image: name: build-docker-image @@ -47,3 +47,4 @@ jobs: echo "Start Integration Test" python3 rmf/tests/integration_test.py echo "Finish Integration Test" + diff --git a/Dockerfile b/Dockerfile index ea6ebd2a..a6568582 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ RUN apt-get update \ qt5-default \ wget \ python3-pip \ + ros-foxy-rmw-cyclonedds-cpp \ && pip3 install flask-socketio \ && rm -rf /var/lib/apt/lists/* @@ -67,7 +68,9 @@ RUN . /opt/ros/$ROS_DISTRO/setup.sh \ # cleanup RUN rm -rf build devel src \ - && sed -i '$isource "/rmf_demos_ws/install/setup.bash"' /ros_entrypoint.sh + && sed -i '$isource /rmf_demos_ws/install/setup.bash' /ros_entrypoint.sh \ + && sed -i '$iexport RMW_IMPLEMENTATION=rmw_cyclonedds_cpp' /ros_entrypoint.sh ENTRYPOINT ["/ros_entrypoint.sh"] CMD ["bash"] + diff --git a/tests/integration_test.py b/tests/integration_test.py index 64046695..11e31b5c 100644 --- a/tests/integration_test.py +++ b/tests/integration_test.py @@ -21,13 +21,14 @@ import requests import time import json +from functools import partial api_server_url = 'http://localhost:8080/' +print = partial(print, flush=True) office_tasks = [ {"task_type": "Loop", "start_time": 0, "description": {"start_name": "coe", "finish_name": "supplies", "num_loops": 1}}, - # TODO: Fix delivery not working {"task_type": "Delivery", "start_time": 0, "description": {"pickup_place_name": "pantry", "pickup_dispenser": "coke_dispenser", @@ -88,6 +89,9 @@ def __init__( launch_cmd = (f"ros2 launch rmf_demos {world_name}.launch.xml" " headless:=1") print(f" Initialize command [{launch_cmd}]") + + # Note: uncomment stdout and stderr in subprocess to hide printouts + # during local test. self.proc1 = subprocess.Popen(launch_cmd, # stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, @@ -136,18 +140,21 @@ def __del__(self): def stop(self): # Send the signal to all the process groups in gazebo launch - os.killpg(os.getpgid(self.proc1.pid), signal.SIGTERM) - self.proc2.kill() - self.proc1.poll() - self.proc2.poll() + try: + os.killpg(os.getpgid(self.proc1.pid), signal.SIGTERM) + self.proc2.kill() + except Exception: + pass def start( self, task_requests: list, - timeout_sec: int): + timeout_sec: int, + cancel_tasks=[]) -> bool: """ This will start the intergration test by sending multiple task - requests to rmf. Return True if all tasks passed, else false. + requests to rmf. Optional arg to provide cancel tasks. + Return True if all tasks passed, else false. TODO: should use ros_time as timeout """ @@ -163,6 +170,21 @@ def start( print("Task Submission failed!", r.json()) return False + # Cancel a submitted task + if (len(cancel_tasks) != 0): + print(f"Cancel a submitted task: {cancel_tasks}") + for id in cancel_tasks: + print(" - cancel a task: ", id) + r = requests.post(api_server_url + 'cancel_task', + json={"task_id": id}) + time.sleep(1) + if (r.status_code != 200): + print("Failed to connect api-server: not 200") + return False + if (r.json == ""): + print("Cancel failed!", r.json()) + return False + # Periodically Checks the tasks start = time.time() while ((time.time() - start) < timeout_sec): @@ -180,12 +202,18 @@ def start( f"| state: {task['state']} ") if (task['state'] == 'Completed'): success_count += 1 - if (task['state'] == 'Failed'): + elif (task['state'] == 'Failed'): return False print("------------"*5) - if success_count == len(task_requests): - print(f"[{self.world_name}] All {success_count} Tasks Passed") + + # check if all submited tasks, substract canceled tasks + # are all successfully completed + if success_count == (len(task_requests) - len(cancel_tasks)): + print(f"[{self.world_name}] Done \n" + f"All {success_count} Tasks Passed, " + f"Canceled {cancel_tasks}") return True + return False @@ -204,10 +232,12 @@ def main(args=None): del office if not success: - raise RuntimeError + raise RuntimeError("requested tasks in office are not fully completed") + + time.sleep(5) # ensures previous pids was fully tore down - # ########################################################################### - # # Test Senario 2: Airport World with 3 requests + ########################################################################### + # Test Senario 2: Airport World with 3 requests airport = RMFSenarioTest("airport_terminal", 11) success = airport.start(airport_terminal_tasks, 250) @@ -215,18 +245,23 @@ def main(args=None): del airport if not success: - raise RuntimeError + raise RuntimeError( + "requested tasks in airport are not fully completed") + + time.sleep(5) # ensures pids was fully tore down - # ########################################################################### - # # Test Senario 3: Clinic World with 4 requests + ########################################################################### + # Test Senario 3: Clinic World with 4 requests clinic = RMFSenarioTest("clinic", 4) - success = clinic.start(clinic_tasks, 600) + # Loop2 is chosen as a cancel tasks because currently rmf can only cancel + # queued task. Loop2 will be queued under deliveryRobot_1 + success = clinic.start(clinic_tasks, 650, cancel_tasks=["Loop2"]) clinic.stop() del clinic if not success: - raise RuntimeError + raise RuntimeError("requested tasks in clinic are not fully completed") print("====================== Successfully End All ======================") diff --git a/web_server.log b/web_server.log deleted file mode 100644 index fd8f1edb..00000000 --- a/web_server.log +++ /dev/null @@ -1,56 +0,0 @@ -2021-04-14 17:18:20,020 DEBUG ROS Time: 0 | active tasks: 0 | terminated tasks: 0 | active robots: 0 -2021-04-14 17:18:22,023 DEBUG ROS Time: 0 | active tasks: 0 | terminated tasks: 0 | active robots: 0 -2021-04-14 17:18:24,029 DEBUG ROS Time: 0 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:26,037 DEBUG ROS Time: 2 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:28,046 DEBUG ROS Time: 4 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:30,053 DEBUG ROS Time: 6 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:32,064 DEBUG ROS Time: 8 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:34,076 DEBUG ROS Time: 10 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:36,094 DEBUG ROS Time: 12 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:38,103 DEBUG ROS Time: 14 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:40,111 DEBUG ROS Time: 16 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:42,123 DEBUG ROS Time: 18 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:44,149 DEBUG ROS Time: 20 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:46,164 DEBUG ROS Time: 21 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:48,176 DEBUG ROS Time: 23 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:50,184 DEBUG ROS Time: 25 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:52,195 DEBUG ROS Time: 27 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:54,210 DEBUG ROS Time: 29 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:56,220 DEBUG ROS Time: 31 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:18:58,250 DEBUG ROS Time: 33 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:00,265 DEBUG ROS Time: 35 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:02,277 DEBUG ROS Time: 37 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:04,299 DEBUG ROS Time: 39 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:06,307 DEBUG ROS Time: 41 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:08,316 DEBUG ROS Time: 42 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:10,336 DEBUG ROS Time: 44 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:12,347 DEBUG ROS Time: 46 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:14,357 DEBUG ROS Time: 48 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:16,396 DEBUG ROS Time: 50 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:18,427 DEBUG ROS Time: 52 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:20,441 DEBUG ROS Time: 54 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:22,449 DEBUG ROS Time: 56 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:24,459 DEBUG ROS Time: 58 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:26,470 DEBUG ROS Time: 60 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:28,492 DEBUG ROS Time: 62 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:30,510 DEBUG ROS Time: 64 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:32,536 DEBUG ROS Time: 66 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:34,549 DEBUG ROS Time: 68 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:36,565 DEBUG ROS Time: 69 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:38,588 DEBUG ROS Time: 71 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:40,597 DEBUG ROS Time: 73 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:42,614 DEBUG ROS Time: 75 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:44,623 DEBUG ROS Time: 77 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:46,649 DEBUG ROS Time: 79 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:48,659 DEBUG ROS Time: 81 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:50,688 DEBUG ROS Time: 83 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:52,714 DEBUG ROS Time: 85 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:54,722 DEBUG ROS Time: 87 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:56,744 DEBUG ROS Time: 89 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:19:58,781 DEBUG ROS Time: 91 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:20:00,791 DEBUG ROS Time: 93 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:20:02,815 DEBUG ROS Time: 95 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:20:04,824 DEBUG ROS Time: 96 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:20:06,834 DEBUG ROS Time: 98 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:20:09,101 DEBUG ROS Time: 99 | active tasks: 0 | terminated tasks: 0 | active robots: 2 -2021-04-14 17:20:11,107 DEBUG ROS Time: 99 | active tasks: 0 | terminated tasks: 0 | active robots: 2 From ab4642b10419053776360aa1986505bbff06d6a1 Mon Sep 17 00:00:00 2001 From: youliang Date: Tue, 18 May 2021 11:05:07 +0800 Subject: [PATCH 5/5] clean up Signed-off-by: youliang --- .rmf_schedule_node.yaml | 30 ------------------------------ tests/integration_test.py | 12 ++++-------- 2 files changed, 4 insertions(+), 38 deletions(-) delete mode 100644 .rmf_schedule_node.yaml diff --git a/.rmf_schedule_node.yaml b/.rmf_schedule_node.yaml deleted file mode 100644 index 07123ec5..00000000 --- a/.rmf_schedule_node.yaml +++ /dev/null @@ -1,30 +0,0 @@ -- operation: Add - participant_description: - name: tinyRobot1 - group: tinyRobot - responsiveness: Responsive - profile: - footprint: - type: Circle - index: "\x00" - vicinity: - type: Circle - index: "\x01" - shape_context: - - 0.3 - - 1 -- operation: Add - participant_description: - name: tinyRobot2 - group: tinyRobot - responsiveness: Responsive - profile: - footprint: - type: Circle - index: "\x00" - vicinity: - type: Circle - index: "\x01" - shape_context: - - 0.3 - - 1 \ No newline at end of file diff --git a/tests/integration_test.py b/tests/integration_test.py index 11e31b5c..6af16316 100644 --- a/tests/integration_test.py +++ b/tests/integration_test.py @@ -93,7 +93,7 @@ def __init__( # Note: uncomment stdout and stderr in subprocess to hide printouts # during local test. self.proc1 = subprocess.Popen(launch_cmd, - # stdout=subprocess.DEVNULL, + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, shell=True, preexec_fn=os.setsid) @@ -231,8 +231,7 @@ def main(args=None): office.stop() del office - if not success: - raise RuntimeError("requested tasks in office are not fully completed") + assert success, "requested tasks in office are not fully completed" time.sleep(5) # ensures previous pids was fully tore down @@ -244,9 +243,7 @@ def main(args=None): airport.stop() del airport - if not success: - raise RuntimeError( - "requested tasks in airport are not fully completed") + assert success, "requested tasks in airport are not fully completed" time.sleep(5) # ensures pids was fully tore down @@ -260,8 +257,7 @@ def main(args=None): clinic.stop() del clinic - if not success: - raise RuntimeError("requested tasks in clinic are not fully completed") + assert success, "requested tasks in clinic are not fully completed" print("====================== Successfully End All ======================")