Skip to content
Snippets Groups Projects
Commit ac6c060e authored by Carsten Patzke's avatar Carsten Patzke
Browse files

Fixed ip/tcp resolve hostname tests

parent 4ca00667
No related branches found
No related tags found
No related merge requests found
......@@ -44,12 +44,12 @@ struct Args {
};
class LatchedTimer {
private:
private:
volatile int count_;
std::chrono::high_resolution_clock::time_point start_time_ = std::chrono::high_resolution_clock::time_point::max();
std::mutex mutex;
std::condition_variable waiter;
public:
public:
explicit LatchedTimer(int count) : count_{count} {};
void count_down_and_wait() {
......@@ -98,7 +98,7 @@ StartThreads(const Args& params, std::vector<int>* nfiles, std::vector<int>* err
asapo::FileInfo fi;
Error err;
auto broker = asapo::DataBrokerFactory::CreateServerBroker(params.server, params.file_path, true,
asapo::SourceCredentials{params.beamtime_id, "", params.stream, params.token}, &err);
asapo::SourceCredentials{params.beamtime_id, "", params.stream, params.token}, &err);
if (err) {
std::cout << "Error CreateServerBroker: " << err << std::endl;
exit(EXIT_FAILURE);
......@@ -177,7 +177,8 @@ StartThreads(const Args& params, std::vector<int>* nfiles, std::vector<int>* err
return threads;
}
int ReadAllData(const Args& params, uint64_t* duration_ms, uint64_t* duration_without_first_ms, int* nerrors, int* nbuf, int* nfiles_total,
int ReadAllData(const Args& params, uint64_t* duration_ms, uint64_t* duration_without_first_ms, int* nerrors, int* nbuf,
int* nfiles_total,
asapo::NetworkConnectionType* connection_type) {
asapo::FileInfo fi;
std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
......@@ -229,7 +230,7 @@ int ReadAllData(const Args& params, uint64_t* duration_ms, uint64_t* duration_wi
ConnectionTypeToString(connection_types[i]) << "' but thread["
<< firstThreadThatActuallyProcessedData << "](processed "
<< nfiles[firstThreadThatActuallyProcessedData] << " files) is '" << ConnectionTypeToString(
*connection_type) << "'" << std::endl;
*connection_type) << "'" << std::endl;
}
}
}
......@@ -262,7 +263,7 @@ int main(int argc, char* argv[]) {
params.datasets = false;
if (argc != 8 && argc != 9) {
std::cout << "Usage: " + std::string{argv[0]}
+ " <server> <files_path> <run_name> <nthreads> <token> <timeout ms> <metaonly> [use datasets]"
+ " <server> <files_path> <run_name> <nthreads> <token> <timeout ms> <metaonly> [use datasets]"
<<
std::endl;
exit(EXIT_FAILURE);
......@@ -289,7 +290,8 @@ int main(int argc, char* argv[]) {
uint64_t duration_without_first_ms;
int nerrors, nbuf, nfiles_total;
asapo::NetworkConnectionType connectionType;
auto nfiles = ReadAllData(params, &duration_ms, &duration_without_first_ms, &nerrors, &nbuf, &nfiles_total, &connectionType);
auto nfiles = ReadAllData(params, &duration_ms, &duration_without_first_ms, &nerrors, &nbuf, &nfiles_total,
&connectionType);
std::cout << "Processed " << nfiles << (params.datasets ? " dataset(s)" : " file(s)") << std::endl;
if (params.datasets) {
std::cout << " with " << nfiles_total << " file(s)" << std::endl;
......
......@@ -185,7 +185,7 @@ int main(int argc, char* argv[]) {
std::cout << "[META] Check unknown host" << std::endl;
io->CreateAndConnectIPTCPSocket("some-host-that-might-not-exists.aa:1234", &err);
if(err != asapo::IOErrorTemplates::kAddressNotValid) {
if(err != asapo::IOErrorTemplates::kUnableToResolveHostname) {
ExitIfErrIsNotOk(&err, 303);
}
......
......@@ -11,12 +11,12 @@ void Check(const std::string& expected_ip_address, const std::string& hostname)
Error err;
auto io = std::unique_ptr<asapo::IO> {asapo::GenerateDefaultIO()};
std::string ip_address = io->ResolveHostnameToIp(hostname, &err);
M_AssertEq(expected_ip_address, ip_address);
if(expected_ip_address.empty()) {
M_AssertTrue(err != nullptr && asapo::IOErrorTemplates::kUnableToResolveHostname == err);
return;
M_AssertEq(asapo::IOErrorTemplates::kUnableToResolveHostname, err);
} else {
M_AssertEq(nullptr, err);
}
M_AssertTrue(err == nullptr);
M_AssertEq(expected_ip_address, ip_address);
}
int main(int argc, char* argv[]) {
......@@ -30,5 +30,9 @@ int main(int argc, char* argv[]) {
Check("", "some-address-that-does-not-exists.ff");
Check("", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ff");
// Fallthrough tests
Check("123.123.123.123", "123.123.123.123");
Check("8.8.8.8", "8.8.8.8");
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment