Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
test: integ: file_upload: Stop webserver earlier
The webserver runs in a different thread than the test, therefor
deleting the uploaded files and checking if they are deleted might lead
into a race condition, and thus into tests failing sometimes, but not
always.

Moving the webserver stop and destructor behind the curl action should
be safe, every information needed for the test is copied to or in the
resource handler.
  • Loading branch information
LeSpocky committed Apr 8, 2022
commit 0c18064c7c7597bf8e30818f3a6ab38e3d8b4b9d
25 changes: 12 additions & 13 deletions test/integ/file_upload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ LT_BEGIN_AUTO_TEST(file_upload_suite, file_upload_memory_and_disk)
CURLcode res = send_file_to_webserver(false, false);
LT_ASSERT_EQ(res, 0);

ws->stop();
delete ws;

string actual_content = resource.get_content();
LT_CHECK_EQ(actual_content.find(FILENAME_IN_GET_CONTENT) != string::npos, true);
LT_CHECK_EQ(actual_content.find(TEST_CONTENT) != string::npos, true);
Expand All @@ -223,9 +226,6 @@ LT_BEGIN_AUTO_TEST(file_upload_suite, file_upload_memory_and_disk)
LT_CHECK_EQ(file->second.get_file_system_file_name().substr(0, file->second.get_file_system_file_name().size() - 6),
expected_filename.substr(0, expected_filename.size() - 6));
LT_CHECK_EQ(file_exists(file->second.get_file_system_file_name()), false);

ws->stop();
delete ws;
LT_END_AUTO_TEST(file_upload_memory_and_disk)

LT_BEGIN_AUTO_TEST(file_upload_suite, file_upload_memory_and_disk_via_put)
Expand Down Expand Up @@ -277,6 +277,9 @@ LT_BEGIN_AUTO_TEST(file_upload_suite, file_upload_memory_and_disk_additional_par
CURLcode res = send_file_to_webserver(false, true);
LT_ASSERT_EQ(res, 0);

ws->stop();
delete ws;

string actual_content = resource.get_content();
LT_CHECK_EQ(actual_content.find(FILENAME_IN_GET_CONTENT) != string::npos, true);
LT_CHECK_EQ(actual_content.find(TEST_CONTENT) != string::npos, true);
Expand Down Expand Up @@ -308,9 +311,6 @@ LT_BEGIN_AUTO_TEST(file_upload_suite, file_upload_memory_and_disk_additional_par
LT_CHECK_EQ(file->second.get_file_system_file_name().substr(0, file->second.get_file_system_file_name().size() - 6),
expected_filename.substr(0, expected_filename.size() - 6));
LT_CHECK_EQ(file_exists(file->second.get_file_system_file_name()), false);

ws->stop();
delete ws;
LT_END_AUTO_TEST(file_upload_memory_and_disk_additional_params)

LT_BEGIN_AUTO_TEST(file_upload_suite, file_upload_memory_and_disk_two_files)
Expand All @@ -331,6 +331,9 @@ LT_BEGIN_AUTO_TEST(file_upload_suite, file_upload_memory_and_disk_two_files)
CURLcode res = send_file_to_webserver(true, false);
LT_ASSERT_EQ(res, 0);

ws->stop();
delete ws;

string actual_content = resource.get_content();
LT_CHECK_EQ(actual_content.find(FILENAME_IN_GET_CONTENT) != string::npos, true);
LT_CHECK_EQ(actual_content.find(TEST_CONTENT) != string::npos, true);
Expand Down Expand Up @@ -377,10 +380,6 @@ LT_BEGIN_AUTO_TEST(file_upload_suite, file_upload_memory_and_disk_two_files)
LT_CHECK_EQ(file->second.get_file_system_file_name().substr(0, file->second.get_file_system_file_name().size() - 6),
expected_filename.substr(0, expected_filename.size() - 6));
LT_CHECK_EQ(file_exists(file->second.get_file_system_file_name()), false);


ws->stop();
delete ws;
LT_END_AUTO_TEST(file_upload_memory_and_disk_two_files)

LT_BEGIN_AUTO_TEST(file_upload_suite, file_upload_disk_only)
Expand All @@ -401,6 +400,9 @@ LT_BEGIN_AUTO_TEST(file_upload_suite, file_upload_disk_only)
CURLcode res = send_file_to_webserver(false, false);
LT_ASSERT_EQ(res, 0);

ws->stop();
delete ws;

string actual_content = resource.get_content();
LT_CHECK_EQ(actual_content.size(), 0);

Expand All @@ -423,9 +425,6 @@ LT_BEGIN_AUTO_TEST(file_upload_suite, file_upload_disk_only)
LT_CHECK_EQ(file->second.get_file_system_file_name().substr(0, file->second.get_file_system_file_name().size() - 6),
expected_filename.substr(0, expected_filename.size() - 6));
LT_CHECK_EQ(file_exists(file->second.get_file_system_file_name()), false);

ws->stop();
delete ws;
LT_END_AUTO_TEST(file_upload_disk_only)

LT_BEGIN_AUTO_TEST(file_upload_suite, file_upload_memory_only_incl_content)
Expand Down