Skip to content

Commit

Permalink
Skip core container creation for pubnet & testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
urvisavla committed Jul 24, 2023
1 parent 1f978e2 commit 04dc6a2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 19 deletions.
22 changes: 18 additions & 4 deletions services/horizon/internal/integration/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ const (
QUALITY="MEDIUM"`
)

func NewParameterTestSkipContainerCreation(t *testing.T, params map[string]string) *integration.Test {
return NewParameterTestWithEnvSkipContainerCreation(t, params, map[string]string{})
}

func NewParameterTestWithEnvSkipContainerCreation(t *testing.T, params, envvars map[string]string) *integration.Test {
config := integration.Config{
ProtocolVersion: 17,
SkipHorizonStart: true,
SkipContainerCreation: true,
HorizonIngestParameters: params,
HorizonEnvironment: envvars}
return integration.NewTest(t, config)
}

func NewParameterTest(t *testing.T, params map[string]string) *integration.Test {
return NewParameterTestWithEnv(t, params, map[string]string{})
}
Expand Down Expand Up @@ -150,7 +164,7 @@ func TestNetworkParameter(t *testing.T) {
localParams := integration.MergeMaps(networkParamArgs, map[string]string{
horizon.NetworkFlagName: horizon.StellarPubnet,
})
test := NewParameterTest(t, localParams)
test := NewParameterTestSkipContainerCreation(t, localParams)
err := test.StartHorizon()
time.Sleep(10 * time.Second)
assert.NoError(t, err)
Expand All @@ -162,7 +176,7 @@ func TestNetworkParameter(t *testing.T) {
localParams := integration.MergeMaps(networkParamArgs, map[string]string{
horizon.NetworkFlagName: horizon.StellarTestnet,
})
test := NewParameterTest(t, localParams)
test := NewParameterTestSkipContainerCreation(t, localParams)
err := test.StartHorizon()
time.Sleep(10 * time.Second)
assert.NoError(t, err)
Expand Down Expand Up @@ -194,7 +208,7 @@ func TestNetworkEnvironmentVariable(t *testing.T) {
}()

t.Run("NETWORK environment variable pubnet", func(t *testing.T) {
test := NewParameterTestWithEnv(t, networkParamArgs,
test := NewParameterTestWithEnvSkipContainerCreation(t, networkParamArgs,
map[string]string{"NETWORK": horizon.StellarPubnet})
err := test.StartHorizon()
time.Sleep(10 * time.Second)
Expand All @@ -204,7 +218,7 @@ func TestNetworkEnvironmentVariable(t *testing.T) {
})

t.Run("NETWORK environment variable testnet", func(t *testing.T) {
test := NewParameterTestWithEnv(t, networkParamArgs,
test := NewParameterTestWithEnvSkipContainerCreation(t, networkParamArgs,
map[string]string{"NETWORK": horizon.StellarTestnet})
err := test.StartHorizon()
time.Sleep(10 * time.Second)
Expand Down
41 changes: 26 additions & 15 deletions services/horizon/internal/test/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,32 @@ func NewTest(t *testing.T, config Config) *Test {
config.ProtocolVersion = maxSupportedCoreProtocolFromEnv
}
}

composePath := findDockerComposePath()
i := &Test{
t: t,
config: config,
composePath: composePath,
passPhrase: StandaloneNetworkPassphrase,
environment: NewEnvironmentManager(),
var i *Test
if !config.SkipContainerCreation {
composePath := findDockerComposePath()
i = &Test{
t: t,
config: config,
composePath: composePath,
passPhrase: StandaloneNetworkPassphrase,
environment: NewEnvironmentManager(),
}
i.configureCaptiveCore()
// Only run Stellar Core container and its dependencies.
i.runComposeCommand("up", "--detach", "--quiet-pull", "--no-color", "core")
} else {
i = &Test{
t: t,
config: config,
environment: NewEnvironmentManager(),
}
}

i.configureCaptiveCore()

// Only run Stellar Core container and its dependencies.
i.runComposeCommand("up", "--detach", "--quiet-pull", "--no-color", "core")
i.prepareShutdownHandlers()
i.coreClient = &stellarcore.Client{URL: "http://localhost:" + strconv.Itoa(stellarCorePort)}
i.waitForCore()
if !config.SkipContainerCreation {
i.waitForCore()
}

if !config.SkipHorizonStart {
if innerErr := i.StartHorizon(); innerErr != nil {
Expand Down Expand Up @@ -224,8 +233,10 @@ func (i *Test) prepareShutdownHandlers() {
if i.ingestNode != nil {
i.ingestNode.Close()
}
i.runComposeCommand("rm", "-fvs", "core")
i.runComposeCommand("rm", "-fvs", "core-postgres")
if !i.config.SkipContainerCreation {
i.runComposeCommand("rm", "-fvs", "core")
i.runComposeCommand("rm", "-fvs", "core-postgres")
}
},
i.environment.Restore,
)
Expand Down

0 comments on commit 04dc6a2

Please sign in to comment.