Skip to content

Adding a test of TCP with TLS termination (test-only change)#1183

Merged
mattklein123 merged 9 commits intoenvoyproxy:masterfrom
alyssawilk:tcp-tests
Jul 5, 2017
Merged

Adding a test of TCP with TLS termination (test-only change)#1183
mattklein123 merged 9 commits intoenvoyproxy:masterfrom
alyssawilk:tcp-tests

Conversation

@alyssawilk
Copy link
Copy Markdown
Contributor

This ended up getting a bit larger than I'd anticipated - please let me know if you'd prefer I split things up a bit. Roughly:

  • moved existing TCP tests to tcp_proxy_integration_test.cc, adding tcp_proxy.json
  • moved a bunch of code from ssl_integration_test.cc to ssl_utility.cc, refactored to not use class members
  • refactor read-until-expected-data-read filter from integration.cc to a standalone class in utility.cc
  • Finally added a TCP+TLS filter and the SendTlsToTlsListener

I have this theory wherein I start flow control backup with just the network layer (TCP/TLS) but I wanted some basic integration tests before I tack on flow control and make sure resumption works :-)

const std::string& data() { return data_; }

private:
Event::Dispatcher* dispatcher_;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Quick comment: In Envoy-style unless there is a null state a reference (const or non-const) is preferred to passing and storing a pointer which is a departure from the Google style guide. I think there a few spots like this line where a reference would be preferred.

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Looks great. Some of my comments below apply to the existing code you moved, so they are really a request to improve what was there before.

Json::ObjectSharedPtr loader = TestEnvironment::jsonLoadFromString(target);
ContextConfigImpl cfg(*loader);
static auto* client_stats_store = new Stats::TestIsolatedStoreImpl();
return context_manager.createSslClientContext(*client_stats_store, cfg);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@myidpt Can you rebase #1087 on this when it merges and generalize this utility function to allow reuse in your PR? If that works, we could reduce some of the boiler plate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If so, I will need to change this function to support TLS (non-mTLS) case as well. In terms of refactoring, I think it's better we have this PR focusing on it (and probably we can do it better here :) ).


Network::Address::InstanceConstSharedPtr getSslAddress(Network::Address::IpVersion version,
int port) {
std::string url =
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As a general preference, prefer const for any intermediate variable that is const.

}
)EOF";

std::string json_alpn_san = R"EOF(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

const, etc. above

#include "gtest/gtest.h"

namespace Envoy {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have this longstanding wish to have all tests in the anonymous namespace, but that's just an observation, I don't even do this consistently today.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FWIW I'm not a fan of this. It will make test much more verbose since all namespace references will need to be fully specified which is rarely the case when testing code within the same namespace. If there is a wish for this I would recommend opening up a separate discussion and not doing this in the current PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not suggesting we put it in the anonymous namespace at outer scope. I'm suggesting we add an additional anonymous namespace within the existing set of namespace scopes at inner scope. This doesn't imply additional verbosity, and is safer when we link into the single coverage binary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If we're going to bikeshed on this, I'd love to see
namespace Envoy {
namespace Test {
namespace {

where all the tests and tools are in the Envoy::Test namespace. That'd definitely be out of scope for this PR so I'll do at most the anonymous namespace here :-)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK. Either of this is fine with if you want to do the cleanup.

EXPECT_EQ("world", tcp_client->data());
}

TEST_P(TcpProxyIntegrationTest, TcpProxyDownstreamDisconnect) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add one liner comments above each TEST_P case to explain what's being checked?

@mattklein123
Copy link
Copy Markdown
Member

@alyssawilk
Copy link
Copy Markdown
Contributor Author

alyssawilk commented Jun 29, 2017 via email

@alyssawilk
Copy link
Copy Markdown
Contributor Author

alyssawilk commented Jun 30, 2017 via email

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM modulo small comments.

std::unique_lock<std::mutex> lock(lock_);
wrapped_scope_.reset();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think these should all be override rather than virtual

: lock_(lock), wrapped_scope_(std::move(wrapped_scope)) {}

virtual ~TestScopeWrapper() {
std::unique_lock<std::mutex> lock(lock_);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this needed? Won't this self-destruct?

ScopePtr createScope(const std::string& name) override {
std::unique_lock<std::mutex> lock(lock_);
return store_.createScope(name);
ScopePtr tmp = store_.createScope(name);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: Is the intermediate here needed?

@mattklein123 mattklein123 merged commit d961183 into envoyproxy:master Jul 5, 2017
@alyssawilk alyssawilk deleted the tcp-tests branch July 6, 2017 16:54
rshriram pushed a commit to rshriram/envoy that referenced this pull request Oct 30, 2018
Automatic merge from submit-queue.

Support bypassing JWT verification for some requests.

**What this PR does / why we need it**:

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
None
```
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Description: Replace the metrics sink from the envoy one to a custom one. The custom metrics sink comes with ack function on the grpc stream. This change is based on upstream envoy change: #13919
Risk Level: High
Testing: Local and ci unit tests and integration tests

Signed-off-by: Jingwei Hao <jingweih@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Description: Replace the metrics sink from the envoy one to a custom one. The custom metrics sink comes with ack function on the grpc stream. This change is based on upstream envoy change: #13919
Risk Level: High
Testing: Local and ci unit tests and integration tests

Signed-off-by: Jingwei Hao <jingweih@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.com>
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.

5 participants