Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alternative way of obtaining CI test results #110

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
run: |
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
docker run -t --network host -e DISPLAY -v /tmp/.X11-unix ${{ secrets.PILOTING_DOCKERHUB_USERNAME }}/noetic-dev:${{github.event.number}} /bin/bash -c "rostest piloting_demo mission.test || (rostest --text piloting_demo mission.test && false)"
docker run -t --network host -e DISPLAY -v /tmp/.X11-unix ${{ secrets.PILOTING_DOCKERHUB_USERNAME }}/noetic-dev:${{github.event.number}} /bin/bash -c "rostest piloting_demo mission.test"

# test:
# needs: build
Expand Down
3 changes: 2 additions & 1 deletion moma_demos/piloting_demo/launch/mission.launch
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<launch>
<arg name="sim" default="false"/>
<arg name="delay" default="0"/>

<!-- Load joint controller to publish the joint state under object namespace -->
<group ns="valve" if="$(arg sim)">
Expand Down Expand Up @@ -30,7 +31,7 @@
<!-- mission state machine -->
<rosparam command="load" file="$(find moma_mission)/config/state_machine/piloting.yaml" subst_value="true"/>
<rosparam command="load" file="$(find moma_mission)/config/state_machine/piloting_frames.yaml"/>
<node pkg="moma_mission" type="piloting.py" name="piloting_demo" output="screen" required="true">
<node pkg="moma_mission" type="piloting.py" name="piloting_demo" output="screen" required="true" launch-prefix="bash -c 'sleep $(arg delay); $0 $@' ">
<param name="telemetry_odom_topic" value="/base_odom"/>
</node>
</launch>
26 changes: 16 additions & 10 deletions moma_demos/piloting_demo/scripts/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import rospy
import rospkg
import subprocess
from std_msgs.msg import Int8


class TestPilotingMission(unittest.TestCase):
Expand All @@ -16,19 +17,24 @@ def test_state_machine(self):
os.system(
f"perl -i -0777 -pe 's/(IDLE:.*?default_outcome: ).*?\n/\\1ExecuteDummyPlan\n/s' {moma_mission_path}/config/state_machine/piloting.yaml"
)
rospy.sleep(120) # Wait for environment
p = subprocess.Popen(
["roslaunch", "piloting_demo", "mission.launch", "sim:=true"],
stderr=subprocess.PIPE,
)
err = str(p.stderr.read())
p.communicate()
self.assertEquals("exit code" in err, False)
# https://github.com/ros/ros_comm/issues/919
self.assertEquals(p.returncode, 0)
result = rospy.wait_for_message("/piloting_mission", Int8)
self.assertEquals(result, 0)

# rospy.sleep(120) # Wait for environment
# p = subprocess.Popen(
# ["roslaunch", "piloting_demo", "mission.launch", "sim:=true"],
# stderr=subprocess.PIPE,
# )
# err = str(p.stderr.read())
# p.communicate()
# self.assertEquals("exit code" in err, False)
# # https://github.com/ros/ros_comm/issues/919
# self.assertEquals(p.returncode, 0)


if __name__ == "__main__":
import rostest

rospy.init_node("piloting_demo_test")

rostest.rosrun(PKG, "test_piloting_mission", TestPilotingMission)
5 changes: 5 additions & 0 deletions moma_demos/piloting_demo/test/mission.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
<arg name="rviz" value="false" />
</include>

<include file="$(find piloting_demo)/launch/mission.launch">
<arg name="sim" value="true"/>
<arg name="delay" value="20"/>
</include>

<test test-name="piloting_mission" pkg="piloting_demo" type="test.py" time-limit="1800.0"/>
</launch>
10 changes: 10 additions & 0 deletions moma_mission/demo/piloting.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import sys
import rospy
from std_msgs.msg import Int8
from moma_mission.core.state_ros import *
from moma_mission.missions.piloting.states import *
from moma_mission.missions.piloting.sequences import *
Expand All @@ -22,6 +23,9 @@
Frames.init_from_ros()
Frames.print_summary()

# Init test result feedback
result_pub = rospy.Publisher("/piloting_mission", Int8, queue_size=1, latch=True)

# Build the state machine
state_machine = StateMachineRos(outcomes=["Success", "Failure"])

Expand Down Expand Up @@ -233,8 +237,14 @@
rospy.loginfo("\n\nRunning the mission state machine!\n\n")
outcome = state_machine.execute()
rospy.loginfo("Mission plan terminated with outcome {}.".format(outcome))
result = Int8()
if outcome != "Success":
result.data = 1
result_pub.publish(result)
rospy.sleep(10)
sys.exit(1)
result.data = 0
result_pub.publish(result)
sys.exit(0)

# Wait for ctrl-c to stop the application
Expand Down