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

fuzz: make temporary path and port handling less flaky for server fuz… #4202

Merged
merged 2 commits into from
Aug 20, 2018

Conversation

htuch
Copy link
Member

@htuch htuch commented Aug 20, 2018

…z tests.

  • Avoid reusing temporary paths across tests.

  • Force port zero binding on server_fuzz_test.

  • Force server_fuzz_test not to write access log to random places on FS.

I don't think this is the last we'll see on the server_fuzz_test flake test, since this particular
fuzz test is inherently non-hermetic. So, this seems to be the high payoff whackamole for now.

Risk level: Low.
Testing: Ran server_fuzz_test test under Bazel and oss-fuzz Docker image.

Signed-off-by: Harvey Tuch htuch@google.com

…z tests.

* Avoid reusing temporary paths across tests.

* Force port zero binding on server_fuzz_test.

* Force server_fuzz_test not to write access log to random places on FS.

I don't think this is the last we'll see on the server_fuzz_test flake test, since this particular
fuzz test is inherently non-hermetic. So, this seems to be the high payoff whackamole for now.

Risk level: Low.
Testing: Ran server_fuzz_test test under Bazel and oss-fuzz Docker image.

Signed-off-by: Harvey Tuch <htuch@google.com>
@htuch htuch requested a review from zuercher August 20, 2018 19:23
std::string temporaryPath(const std::string& path) const { return test_tmpdir_ + "/" + path; }

private:
std::string test_tmpdir_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: You could make test_tmpdir_ const and initialize in the ctor initializer list:

PerTestEnvironment::PerTestEnvironment() : test_tmpdir_([](){
  const std::string fuzz_path = TestEnvironment::temporaryPath("fuzz_XXXXXX");
  char test_tmpdir[fuzz_path.size() + 1];
  StringUtil::strlcpy(test_tmpdir, fuzz_path.data(), fuzz_path.size() + 1);
  RELEASE_ASSERT(::mkdtemp(test_tmpdir) != nullptr, "");
  return std::string(test_tmpdir);
}()) {}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had people point out to me in the past that this makes C++ look like JavaScript spaghetti, but sure, why not :)

makeHermeticPathsAndPorts(Fuzz::PerTestEnvironment& test_env,
const envoy::config::bootstrap::v2::Bootstrap& input) {
envoy::config::bootstrap::v2::Bootstrap output;
output.MergeFrom(input);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just envoy::config::bootstrap::v2::Bootstrap output(input) to get the initial state? Isn't this equivalent?

Signed-off-by: Harvey Tuch <htuch@google.com>
@htuch htuch removed the request for review from zuercher August 20, 2018 20:43
@htuch htuch assigned dnoe and unassigned zuercher Aug 20, 2018
@htuch htuch merged commit 5c058a8 into envoyproxy:master Aug 20, 2018
@htuch htuch deleted the server-fuzz-hermetic branch August 20, 2018 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants