Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions start
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ function validate_after_copy_defaults() {
function start() {
echo "Starting Stellar Quickstart"

# Extract stellar-core version for horizon configuration
export STELLAR_CORE_VERSION=$(stellar-core version 2>/dev/null | head -1 | xargs)

echo "versions:"
echo " quickstart: $REVISION"
echo " stellar-core:"
Expand Down Expand Up @@ -496,6 +499,7 @@ function init_horizon() {
cat << EOF >> etc/horizon.env
export CAPTIVE_CORE_CONFIG_PATH=$HORIZON_CAPTIVE_CORE_CFG
export CAPTIVE_CORE_STORAGE_PATH=$HZHOME/captive-core
export STELLAR_CORE_VERSION=$STELLAR_CORE_VERSION
EOF

run_silent "chown-horizon" chown -R stellar:stellar .
Expand Down
54 changes: 54 additions & 0 deletions tests/test_core_version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package main

import (
"encoding/json"
"log"
"net/http"
"os"
"time"
)

const timeout = 3 * time.Minute

type Root struct {
StellarCoreVersion string `json:"core_version"`
}

func main() {
startTime := time.Now()

for {
time.Sleep(5 * time.Second)
logLine("Waiting for Horizon to start and checking core_version")

if time.Since(startTime) > timeout {
logLine("Timeout")
os.Exit(-1)
}

resp, err := http.Get("http://localhost:8000")
if err != nil {
logLine(err)
continue
}

var root Root
decoder := json.NewDecoder(resp.Body)
err = decoder.Decode(&root)
if err != nil {
logLine(err)
continue
}

if root.StellarCoreVersion != "" {
logLine("SUCCESS: core_version is populated: " + root.StellarCoreVersion)
os.Exit(0)
} else {
logLine("core_version is still empty")
}
}
}

func logLine(text interface{}) {
log.Println("\033[33;1m[core_version_test]\033[0m", text)
}
Loading