From 34bf6a5d216bcf8c6f888032f24f1bae74699713 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Thu, 8 Oct 2020 19:30:01 +0200 Subject: [PATCH] Allow using captive core in integration tests (#3107) To do so, you need to set the `HORIZON_INTEGRATION_ENABLE_CAPTIVE_CORE` env variable to any value (e.g. `true`). --- services/horizon/internal/test/integration.go | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/services/horizon/internal/test/integration.go b/services/horizon/internal/test/integration.go index 0856c08b43..b417e3a794 100644 --- a/services/horizon/internal/test/integration.go +++ b/services/horizon/internal/test/integration.go @@ -274,16 +274,26 @@ func createTestContainer(i *IntegrationTest, image string) error { t.Log("Creating container...") ctx, cancel = context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() + containerConfig := &container.Config{ + Image: image, + Cmd: []string{ + "--standalone", + "--protocol-version", strconv.FormatInt(int64(i.config.ProtocolVersion), 10), + }, + ExposedPorts: nat.PortSet{"8000": struct{}{}, "6060": struct{}{}}, + } + + if os.Getenv("HORIZON_INTEGRATION_ENABLE_CAPTIVE_CORE") != "" { + containerConfig.Env = append(containerConfig.Env, + "ENABLE_CAPTIVE_CORE_INGESTION=true", + "STELLAR_CORE_BINARY_PATH=/opt/stellar/core/bin/start", + "STELLAR_CORE_CONFIG_PATH=/opt/stellar/core/etc/stellar-core.cfg", + ) + } + i.container, err = i.cli.ContainerCreate( ctx, - &container.Config{ - Image: image, - Cmd: []string{ - "--standalone", - "--protocol-version", strconv.FormatInt(int64(i.config.ProtocolVersion), 10), - }, - ExposedPorts: nat.PortSet{"8000": struct{}{}, "6060": struct{}{}}, - }, + containerConfig, &container.HostConfig{ PortBindings: map[nat.Port][]nat.PortBinding{ nat.Port("8000"): {{HostIP: "127.0.0.1", HostPort: "8000"}},