1
#include "tests/cilium_http_integration.h"
2

            
3
#include <fmt/base.h>
4
#include <fmt/format.h>
5
#include <spdlog/common.h>
6

            
7
#include <memory>
8
#include <string>
9

            
10
#include "envoy/http/codec.h" // IWYU pragma: keep
11
#include "envoy/network/address.h"
12

            
13
#include "source/common/common/base_logger.h"
14
#include "source/common/common/logger.h"
15
#include "source/common/http/codec_client.h"
16
#include "source/common/network/address_impl.h"
17

            
18
#include "test/integration/http_integration.h"
19
#include "test/test_common/environment.h"
20
#include "test/test_common/network_utility.h"
21

            
22
#include "tests/bpf_metadata.h"
23

            
24
namespace Envoy {
25

            
26
CiliumHttpIntegrationTest::CiliumHttpIntegrationTest(const std::string& config)
27
83
    : HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam(), config),
28
83
      accessLogServer_(TestEnvironment::unixDomainSocketPath("access_log.sock")) {
29
83
#if 1
30
5478
  for (Logger::Logger& logger : Logger::Registry::loggers()) {
31
5478
    logger.setLevel(spdlog::level::trace);
32
5478
  }
33
83
#endif
34
83
}
35

            
36
83
CiliumHttpIntegrationTest::~CiliumHttpIntegrationTest() = default;
37

            
38
73
void CiliumHttpIntegrationTest::createEnvoy() {
39
  // fake upstreams have been created by now, use the port from the 1st upstream
40
  // in policy.
41
73
  auto port = fake_upstreams_[0]->localAddress()->ip()->port();
42
73
  policy_config = fmt::format(fmt::runtime(testPolicyFmt()), port);
43
73
  sds_configs = testSecrets();
44
  // Pass the fake upstream address to the cilium bpf filter that will set it as
45
  // an "original destination address".
46
73
  if (GetParam() == Network::Address::IpVersion::v4) {
47
73
    original_dst_address = std::make_shared<Network::Address::Ipv4Instance>(
48
73
        Network::Test::getLoopbackAddressString(GetParam()), port);
49
73
  } else {
50
    original_dst_address = std::make_shared<Network::Address::Ipv6Instance>(
51
        Network::Test::getLoopbackAddressString(GetParam()), port);
52
  }
53
73
  HttpIntegrationTest::createEnvoy();
54
73
}
55

            
56
} // namespace Envoy