Fix test failures due to ipv4/ipv6 mismatch

This commit is contained in:
Adam Liddell 2023-09-08 11:38:51 +01:00
parent e58969fd93
commit 798a95fca2
5 changed files with 6 additions and 8 deletions

View File

@ -220,7 +220,7 @@ class RouteGuideClient {
};
int main(int argc, char** argv) {
std::string server_address = routeguide::GetServerAddress();
std::string server_address = "127.0.0.1:" + routeguide::GetServerPort();
std::cout << "Server Address: " << server_address << std::endl;

View File

@ -44,14 +44,12 @@ std::string GetDbFileContent(int argc, char** argv) {
return db.str();
}
std::string GetServerAddress() {
std::string server_host("0.0.0.0");
std::string GetServerPort() {
std::string server_port("50051");
if (std::getenv("SERVER_PORT")) {
server_port = std::getenv("SERVER_PORT");
}
std::string server_address = server_host + ":" + server_port;
return server_address;
return server_port;
}
// A simple parser for the json db file. It requires the db file to have the

View File

@ -27,7 +27,7 @@ class Feature;
std::string GetDbFileContent(int argc, char** argv);
std::string GetServerAddress();
std::string GetServerPort();
void ParseDb(const std::string& db, std::vector<Feature>* feature_list);

View File

@ -168,7 +168,7 @@ class RouteGuideImpl final : public RouteGuide::Service {
};
void RunServer(const std::string& db_path) {
std::string server_address = routeguide::GetServerAddress();
std::string server_address = "[::]:" + routeguide::GetServerPort();
RouteGuideImpl service(db_path);

View File

@ -137,7 +137,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Err(_e) => 50051,
};
let addr = format!("[::1]:{}", port).parse().unwrap();
let addr = format!("[::]:{}", port).parse().unwrap();
println!("RouteGuideServer listening on: {}", addr);