Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: tweaks to uds_integration_test (--runs_per_test) #3784

Merged
merged 2 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 11 additions & 17 deletions test/integration/uds_integration_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "gtest/gtest.h"

namespace Envoy {

class UdsUpstreamIntegrationTest
: public HttpIntegrationTest,
public testing::TestWithParam<std::tuple<Network::Address::IpVersion, bool>> {
Expand All @@ -23,8 +24,9 @@ class UdsUpstreamIntegrationTest
abstract_namespace_(std::get<1>(GetParam())) {}

void createUpstreams() override {
fake_upstreams_.emplace_back(
new FakeUpstream(getSocketName(), FakeHttpConnection::Type::HTTP1));
fake_upstreams_.emplace_back(new FakeUpstream(
TestEnvironment::unixDomainSocketPath("udstest.1.sock", abstract_namespace_),
FakeHttpConnection::Type::HTTP1));

config_helper_.addConfigModifier(
[&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void {
Expand All @@ -33,17 +35,13 @@ class UdsUpstreamIntegrationTest
auto* cluster = static_resources->mutable_clusters(i);
for (int j = 0; j < cluster->hosts_size(); ++j) {
cluster->mutable_hosts(j)->clear_socket_address();
cluster->mutable_hosts(j)->mutable_pipe()->set_path(getSocketName());
cluster->mutable_hosts(j)->mutable_pipe()->set_path(
TestEnvironment::unixDomainSocketPath("udstest.1.sock", abstract_namespace_));
}
}
});
}

std::string getSocketName() {
return abstract_namespace_ ? "@/my/udstest"
: TestEnvironment::unixDomainSocketPath("udstest.1.sock");
}

protected:
const bool abstract_namespace_;
};
Expand All @@ -58,17 +56,13 @@ class UdsListenerIntegrationTest

void initialize() override;

std::string getSocketName(const std::string& path) {
const std::string name = TestEnvironment::unixDomainSocketPath(path);
if (!abstract_namespace_) {
return name;
}
return "@" + name;
std::string getAdminSocketName() {
return TestEnvironment::unixDomainSocketPath("admin.sock", abstract_namespace_);
}

std::string getAdminSocketName() { return getSocketName("admin.sock"); }

std::string getListenerSocketName() { return getSocketName("listener_0.sock"); }
std::string getListenerSocketName() {
return TestEnvironment::unixDomainSocketPath("listener_0.sock", abstract_namespace_);
}

protected:
HttpIntegrationTest::ConnectionCreationFunction createConnectionFn();
Expand Down
6 changes: 4 additions & 2 deletions test/test_common/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ class TestEnvironment {
/**
* Prefix a given path with the Unix Domain Socket temporary directory.
* @param path path suffix.
* @param abstract_namespace true if an abstract namespace should be returned.
* @return std::string path qualified with the Unix Domain Socket temporary directory.
*/
static std::string unixDomainSocketPath(const std::string& path) {
return unixDomainSocketDirectory() + "/" + path;
static std::string unixDomainSocketPath(const std::string& path,
bool abstract_namespace = false) {
return (abstract_namespace ? "@" : "") + unixDomainSocketDirectory() + "/" + path;
}

/**
Expand Down