Skip to content

Commit 4fe2e1b

Browse files
FireBoyAJ24Jng468lross03
authored
Integration test ros workflow (#504)
* Local Transceiver: Fix Issue with Parsing Mailbox (#500) * this is preliminary remember to clean up * Local transceiver updated to correct receive format, but still need to fix hanging OK issue * try new readrsp * Modified readRsp to read until STATUS_OK instead of DELIMITER * test with different value * restore deleted website file --------- Co-authored-by: lross03 <liamyr0802@gmail.com> * Revert "Add ROS workflows" * Updating the integration test workflow * Make it temperory run the workflow during a push to the branch * Add pull request actions * Adding integrationn test script * Adjusting the script path * Add chmod permissions * Debug script location * Adjusting the script * Comment out chmod command * Add chmod command * Adjust Script run command * Adjust the script path * Adjusting script path * Remove the extra sh * Add execute permission to the bash script * Added permissions to the path * Make run_integration_tests.sh executable --------- Co-authored-by: Jing <128339540+Jng468@users.noreply.github.com> Co-authored-by: lross03 <liamyr0802@gmail.com>
1 parent fbb085b commit 4fe2e1b

File tree

7 files changed

+102
-78
lines changed

7 files changed

+102
-78
lines changed
Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1+
name: Integration-Tests
2+
13
on:
24
schedule:
35
- cron: '00 4 * * 0' # Runs at 8:00 am PST (4:00 am UTC) on Sunday
46
workflow_dispatch:
7+
pull_request:
8+
branches:
9+
- main
10+
- develop
511

612

713
jobs:
8-
test_schedule:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- name: ros_integration_test
12-
run: ./scripts/run_integration_tests.sh
14+
ros_integration_test:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout workspace
18+
uses: actions/checkout@v4
19+
20+
- name: ROS Integration Test
21+
uses: ./.github/actions/
22+
with:
23+
script: './scripts/run_integration_tests'

scripts/run_integration_tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ if [[ $LOCAL_RUN != "true" ]]; then
1010
./scripts/build.sh
1111
source $ROS_WORKSPACE/install/setup.bash
1212
fi
13+
ls -la
14+
sudo chown -R $(whoami):$(whoami) $ROS_WORKSPACE
1315

1416
echo "Integration tests started"
1517
cd $ROS_WORKSPACE/src/integration_tests

src/integration_tests/testplans/example.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Example testplan - Does not currently show HTTP I/O
2-
timeout_sec: 10
2+
timeout_sec: 3
33

44
required_packages:
55
- name: local_pathfinding

src/network_systems/projects/local_transceiver/inc/at_cmds.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace AT
1414
const std::string DELIMITER = "\r\n";
1515
const std::string STATUS_OK = "OK";
1616
const std::string RSP_READY = "READY";
17+
const std::string GARBAGE = "\n";
1718

1819
const std::string CHECK_CONN = "AT";
1920
const std::string SBD_SESSION = "AT+SBDIX"; // 5.144

src/network_systems/projects/local_transceiver/src/local_transceiver.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ custom_interfaces::msg::Path LocalTransceiver::receive()
274274
continue;
275275
}
276276

277-
if (!rcvRsps({message_to_queue_cmd, AT::Line("\n")})) {
277+
if (!rcvRsps({message_to_queue_cmd, AT::Line("\n"), AT::Line("+SBDRB:"), AT::Line("\n")})) {
278278
continue;
279279
}
280280

@@ -283,21 +283,22 @@ custom_interfaces::msg::Path LocalTransceiver::receive()
283283
continue;
284284
}
285285

286-
std::regex re(
287-
R"(name=\"data\"; filename=\"[^\"]*\"\r?\n(?:.*\r?\n)*\r?\n([\s\S]*?)\r?\n--)", std::regex::ECMAScript);
286+
std::string message_size_str;
287+
std::string message;
288+
std::string checksum;
289+
uint16_t message_size_int = 0;
288290

289-
std::smatch match;
290-
291-
if (std::regex_search(*buffer_data, match, re)) {
292-
*buffer_data = match[1];
293-
std::stringstream ss;
294-
ss << *buffer_data;
295-
std::cout << ss.str() << std::endl;
291+
if (buffer_data && buffer_data->size() >= 2) {
292+
message_size_str = buffer_data->substr(0, 2);
296293
} else {
297-
std::cout << "No match found." << std::endl;
294+
continue;
298295
}
299296

300-
receivedDataBuffer = buffer_data.value();
297+
message_size_int = (static_cast<uint8_t>(message_size_str[0]) << 8) | //NOLINT(readability-magic-numbers)
298+
static_cast<uint8_t>(message_size_str[1]); //NOLINT(readability-magic-numbers)
299+
message = buffer_data->substr(2, message_size_int);
300+
301+
receivedDataBuffer = message;
301302
break;
302303
}
303304

@@ -367,7 +368,7 @@ std::optional<std::string> LocalTransceiver::readRsp()
367368
error_code ec;
368369

369370
// Caution: will hang if another proccess is reading from serial port
370-
bio::read_until(serial_, buf, AT::DELIMITER, ec);
371+
bio::read_until(serial_, buf, AT::STATUS_OK, ec);
371372
if (ec) {
372373
return std::nullopt;
373374
}

src/network_systems/projects/local_transceiver/test/test_local_transceiver.cpp

Lines changed: 68 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -227,61 +227,71 @@ TEST_F(TestLocalTransceiver, parseInMsgValid)
227227
EXPECT_EQ(parsed_test.waypoints[1].longitude, holder);
228228
}
229229

230-
// std::mutex port_mutex;
231-
232-
// TEST_F(TestLocalTransceiver, testMailboxBlackbox)
233-
// {
234-
// std::lock_guard<std::mutex> lock(port_mutex); // because same port is being used
235-
236-
// std::string holder = "curl -X POST -F \"test=1234\" http://localhost:8080";
237-
// std::string holder2 = "printf \"at+sbdix\r\" > $LOCAL_TRANSCEIVER_TEST_PORT";
238-
239-
// system(holder.c_str()); //NOLINT
240-
// system(holder2.c_str()); //NOLINT
241-
242-
// std::optional<std::string> response = lcl_trns_->readRsp();
243-
// std::cout << *response << std::endl;
244-
// }
245-
246-
// TEST_F(TestLocalTransceiver, parseReceiveMessageBlackbox)
247-
// {
248-
// std::lock_guard<std::mutex> lock(port_mutex);
249-
250-
// constexpr float holder = 14.3;
251-
// Polaris::GlobalPath sample_data;
252-
253-
// Polaris::Waypoint * waypoint_a = sample_data.add_waypoints();
254-
// waypoint_a->set_latitude(holder);
255-
// waypoint_a->set_longitude(holder);
256-
// Polaris::Waypoint * waypoint_b = sample_data.add_waypoints();
257-
// waypoint_b->set_latitude(holder);
258-
// waypoint_b->set_longitude(holder);
259-
260-
// std::string serialized_data;
261-
// ASSERT_TRUE(sample_data.SerializeToString(&serialized_data));
262-
263-
// std::ofstream outfile("/tmp/serialized_data.bin", std::ios::binary);
264-
// outfile.write(serialized_data.data(), static_cast<std::streamsize>(serialized_data.size()));
265-
// outfile.close();
266-
267-
// std::string holder2 = "curl -X POST -F \"data=@/tmp/serialized_data.bin\" http://localhost:8080";
268-
// std::system(holder2.c_str()); //NOLINT
269-
270-
// custom_interfaces::msg::Path received_data = lcl_trns_->receive();
271-
272-
// Polaris::GlobalPath global_path;
273-
// for (const auto & waypoint : received_data.waypoints) {
274-
// Polaris::Waypoint * new_waypoint = global_path.add_waypoints();
275-
// new_waypoint->set_latitude(waypoint.latitude);
276-
// new_waypoint->set_longitude(waypoint.longitude);
277-
// }
278-
279-
// if (global_path.waypoints_size() > 0) {
280-
// ASSERT_EQ(global_path.waypoints_size(), sample_data.waypoints_size())
281-
// << "Mismatch in number of waypoints received.";
282-
// ASSERT_EQ(global_path.waypoints(0).latitude(), holder);
283-
// ASSERT_EQ(global_path.waypoints(0).longitude(), holder);
284-
// } else {
285-
// std::cout << "No waypoints received." << std::endl;
286-
// }
287-
// }
230+
std::mutex port_mutex;
231+
232+
TEST_F(TestLocalTransceiver, testMailboxBlackbox)
233+
{
234+
std::lock_guard<std::mutex> lock(port_mutex); // because same port is being used
235+
236+
std::string holder = "curl -X POST -F \"test=1234\" http://localhost:8080";
237+
std::string holder2 = "printf \"at+sbdix\r\" > $LOCAL_TRANSCEIVER_TEST_PORT";
238+
239+
system(holder.c_str()); //NOLINT
240+
system(holder2.c_str()); //NOLINT
241+
242+
std::optional<std::string> response = lcl_trns_->readRsp();
243+
std::cout << *response << std::endl;
244+
}
245+
246+
TEST_F(TestLocalTransceiver, parseReceiveMessageBlackbox)
247+
{
248+
std::lock_guard<std::mutex> lock(port_mutex);
249+
250+
constexpr float holder = 10.3;
251+
Polaris::GlobalPath sample_data;
252+
253+
Polaris::Waypoint * waypoint_a = sample_data.add_waypoints();
254+
waypoint_a->set_latitude(holder);
255+
waypoint_a->set_longitude(holder);
256+
Polaris::Waypoint * waypoint_b = sample_data.add_waypoints();
257+
waypoint_b->set_latitude(holder);
258+
waypoint_b->set_longitude(holder);
259+
260+
std::string serialized_data;
261+
ASSERT_TRUE(sample_data.SerializeToString(&serialized_data));
262+
263+
uint16_t message_size = static_cast<uint16_t>(serialized_data.size());
264+
uint16_t message_size_be = htons(message_size); // Convert to big-endian
265+
266+
std::string size_prefix(reinterpret_cast<const char *>(&message_size_be), sizeof(message_size_be));
267+
268+
std::ofstream outfile("/tmp/serialized_data.bin", std::ios::binary);
269+
outfile.write(size_prefix.data(), size_prefix.size()); //NOLINT
270+
outfile.write(serialized_data.data(), static_cast<std::streamsize>(serialized_data.size()));
271+
outfile.close();
272+
273+
outfile.close(); // Close the file after writing
274+
275+
std::string holder2 = "curl -X POST --data-binary @/tmp/serialized_data.bin http://localhost:8080";
276+
std::system(holder2.c_str()); //NOLINT
277+
std::string test_cmd = "hexdump -C /tmp/serialized_data.bin";
278+
std::system(test_cmd.c_str()); //NOLINT
279+
280+
custom_interfaces::msg::Path received_data = lcl_trns_->receive();
281+
282+
Polaris::GlobalPath global_path;
283+
for (const auto & waypoint : received_data.waypoints) {
284+
Polaris::Waypoint * new_waypoint = global_path.add_waypoints();
285+
new_waypoint->set_latitude(waypoint.latitude);
286+
new_waypoint->set_longitude(waypoint.longitude);
287+
}
288+
289+
if (global_path.waypoints_size() > 0) {
290+
ASSERT_EQ(global_path.waypoints_size(), sample_data.waypoints_size())
291+
<< "Mismatch in number of waypoints received.";
292+
ASSERT_EQ(global_path.waypoints(0).latitude(), holder);
293+
ASSERT_EQ(global_path.waypoints(0).longitude(), holder);
294+
} else {
295+
std::cout << "No waypoints received." << std::endl;
296+
}
297+
}

src/website/views/components/DropDown/DropDown.module.css renamed to src/website/views/components/DropDown/Dropdown.module.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,3 @@
100100
position: absolute;
101101
right: 15px;
102102
}
103-

0 commit comments

Comments
 (0)