|
|
|
@ -88,8 +88,8 @@ namespace grpc { |
|
|
|
|
namespace testing { |
|
|
|
|
namespace { |
|
|
|
|
|
|
|
|
|
void RunServer(std::vector<int> grpc_ports, std::set<int> xds_ports, |
|
|
|
|
std::set<int> tls_ports) { |
|
|
|
|
void RunServer(const std::set<int>& grpc_ports, const std::set<int>& xds_ports, |
|
|
|
|
const std::set<int>& tls_ports) { |
|
|
|
|
// Get hostname
|
|
|
|
|
std::string hostname; |
|
|
|
|
char* hostname_p = grpc_gethostname(); |
|
|
|
@ -140,10 +140,6 @@ void RunServer(std::vector<int> grpc_ports, std::set<int> xds_ports, |
|
|
|
|
if (has_xds_listeners) { |
|
|
|
|
xds_server = xds_builder.BuildAndStart(); |
|
|
|
|
} |
|
|
|
|
// 3333 is the magic port that the istio testing for k8s health checks. And
|
|
|
|
|
// it only needs TCP. So also make the gRPC server to listen on 3333.
|
|
|
|
|
builder.AddListeningPort(grpc_core::JoinHostPort("0.0.0.0", 3333), |
|
|
|
|
grpc::InsecureServerCredentials()); |
|
|
|
|
std::unique_ptr<Server> server(builder.BuildAndStart()); |
|
|
|
|
server->Wait(); |
|
|
|
|
} |
|
|
|
@ -153,12 +149,12 @@ void RunServer(std::vector<int> grpc_ports, std::set<int> xds_ports, |
|
|
|
|
} // namespace grpc
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv) { |
|
|
|
|
// Preprocess argv, for two things:
|
|
|
|
|
// 1. merge duplciate flags. So "--grpc=8080 --grpc=9090" becomes
|
|
|
|
|
// "--grpc=8080,9090".
|
|
|
|
|
// 2. replace '-' to '_'. So "--istio-version=123" becomes
|
|
|
|
|
// "--istio_version=123".
|
|
|
|
|
// 3. remove --version since that is specially interpretted by absl
|
|
|
|
|
// Preprocess argv, for two things:
|
|
|
|
|
// 1. merge duplciate flags. So "--grpc=8080 --grpc=9090" becomes
|
|
|
|
|
// "--grpc=8080,9090".
|
|
|
|
|
// 2. replace '-' to '_'. So "--istio-version=123" becomes
|
|
|
|
|
// "--istio_version=123".
|
|
|
|
|
// 3. remove --version since that is specially interpretted by absl
|
|
|
|
|
std::map<std::string, std::vector<std::string>> argv_dict; |
|
|
|
|
for (int i = 0; i < argc; i++) { |
|
|
|
|
std::string arg(argv[i]); |
|
|
|
@ -195,10 +191,10 @@ int main(int argc, char** argv) { |
|
|
|
|
grpc::testing::TestEnvironment env(&new_argc, new_argv); |
|
|
|
|
grpc::testing::InitTest(&new_argc, &new_argv, true); |
|
|
|
|
// Turn gRPC ports from a string vector to an int vector.
|
|
|
|
|
std::vector<int> grpc_ports; |
|
|
|
|
std::set<int> grpc_ports; |
|
|
|
|
for (const auto& p : absl::GetFlag(FLAGS_grpc)) { |
|
|
|
|
int grpc_port = std::stoi(p); |
|
|
|
|
grpc_ports.push_back(grpc_port); |
|
|
|
|
grpc_ports.insert(grpc_port); |
|
|
|
|
} |
|
|
|
|
// Create a map of which ports are supposed to use xds
|
|
|
|
|
std::set<int> xds_ports; |
|
|
|
@ -209,6 +205,10 @@ int main(int argc, char** argv) { |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
xds_ports.insert(port); |
|
|
|
|
// If the port does not exist in gRPC ports set, add it.
|
|
|
|
|
if (grpc_ports.find(port) == grpc_ports.end()) { |
|
|
|
|
grpc_ports.insert(port); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// Create a map of which ports are supposed to use tls
|
|
|
|
|
std::set<int> tls_ports; |
|
|
|
|