Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

services/horizon: Move integration tests away from stellar/quickstart. #3143

Merged
merged 46 commits into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b8bda97
Use Protocol 14 in standalone core setup
Shaptic Oct 20, 2020
2ba097b
Attempt to get tests to use Docker Compose over stellar/quickstart
Shaptic Oct 20, 2020
ede737e
Fix shadowed variable (thx go vet)
Shaptic Oct 20, 2020
068b06a
Update Go modules to latest versions
Shaptic Oct 20, 2020
11800e6
Add some small cleanups & comments
Shaptic Oct 20, 2020
104de46
Avoid directory traversal entirely, preferring absolute paths
Shaptic Oct 20, 2020
0cd8f9a
Allow protocol version to be configurable
Shaptic Oct 20, 2020
c0399b6
Should fix the CI name resolution error & improves env setup
Shaptic Oct 20, 2020
843c346
Reduce verbosity
Shaptic Oct 20, 2020
d38381d
Make version check more generic
Shaptic Oct 20, 2020
86b0453
Merge branch 'master' into no-more-quickstart
Shaptic Oct 21, 2020
246e625
Drop unnecessary method
Shaptic Oct 22, 2020
22197a8
Clean up errors, path handling, and hostname resolution
Shaptic Oct 22, 2020
52a5a23
Drop more unneeded docker stuff
Shaptic Oct 22, 2020
0833a95
Undo the changes to module dependencies
Shaptic Oct 22, 2020
71b9a0a
Okay so not *every*thing docker related is useless
Shaptic Oct 22, 2020
6c2e103
Drop docker dependencies entirely
Shaptic Oct 26, 2020
7d59244
Merge branch 'master' into no-more-quickstart
Shaptic Oct 26, 2020
22bd660
wow this is complicated
Shaptic Oct 26, 2020
87a6a03
Fix integration test commands
tamirms Oct 27, 2020
94cc6b9
Merge branch 'master' into no-more-quickstart
tamirms Oct 27, 2020
9d90135
Handle captive-core runs a little more graciously
Shaptic Oct 27, 2020
dcbd30e
Merge branch 'master' into no-more-quickstart
tamirms Oct 28, 2020
1991398
Add manual close configuration for docker-compose
tamirms Oct 28, 2020
1c4aca5
go mod tidy
tamirms Oct 28, 2020
cb5b186
update go.list
tamirms Oct 28, 2020
daaf14b
Fix static check
tamirms Oct 28, 2020
2c99d4f
log failures to close core ledger
tamirms Oct 28, 2020
fa5a658
Merge branch 'master' into no-more-quickstart
tamirms Oct 28, 2020
3cfa97b
Fix failures
tamirms Oct 29, 2020
1a7039c
Merge branch 'master' into no-more-quickstart
Shaptic Oct 29, 2020
a80c521
Whoops, resolved the `master` merge conflicts the wrong way
Shaptic Oct 29, 2020
ed67c5f
Simplify tests by using dedicated yaml config for integration tests
tamirms Oct 30, 2020
016c91e
fix Still Ingesting errors
tamirms Oct 30, 2020
2545834
Fix dump ledger state script (#3177)
tamirms Oct 30, 2020
0c0d0b7
Update comments, enhance compose file lookup, and move it to a helper
Shaptic Nov 3, 2020
a5096f4
Merge branch 'master' into no-more-quickstart
Shaptic Nov 3, 2020
1223613
Appease `go vet` like the Allies did
Shaptic Nov 3, 2020
34c5830
Add logs to debug still ingesting error
tamirms Nov 3, 2020
027a48c
Clear ledgerstate between test runs
tamirms Nov 3, 2020
44370a3
Use protocol 15 in docker-compose standalone config
tamirms Nov 3, 2020
854d694
Merge branch 'master' into no-more-quickstart
tamirms Nov 4, 2020
c6623f0
Merge branch 'master' into no-more-quickstart
tamirms Nov 4, 2020
7332b14
Update services/horizon/docker/docker-compose.standalone.yml
tamirms Nov 5, 2020
1d00fe3
Set ports to integers not strings
tamirms Nov 5, 2020
8deece7
Merge branch 'master' into no-more-quickstart
tamirms Nov 5, 2020
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: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ commands:
# Pulling the image helps with test running time
command: |
cd ~/go/src/github.com/stellar/go
docker pull stellar/quickstart:testing
<<# parameters.enable-captive-core >>HORIZON_INTEGRATION_ENABLE_CAPTIVE_CORE=true<</ parameters.enable-captive-core >> go test -timeout 25m -v ./services/horizon/internal/integration/...

#-----------------------------------------------------------------------------#
Expand Down Expand Up @@ -433,6 +432,9 @@ jobs:
command: |
echo "export HORIZON_INTEGRATION_TESTS=true" >> $BASH_ENV
echo "export HORIZON_BIN_DIR=~/go/src/github.com/stellar/go" >> $BASH_ENV
- run:
name: Pull latest Stellar Core image
command: docker pull stellar/stellar-core
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would pin this to a specific version

Copy link
Contributor

Choose a reason for hiding this comment

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

It's worth checking the latest version to confirm it tests work with the latest core version.

- install_golang
- build_horizon
# run the integration tests ...
Expand Down
26 changes: 26 additions & 0 deletions clients/stellarcore/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"
"net/url"
"path"
"strconv"
"strings"
"time"

Expand All @@ -26,6 +27,31 @@ type Client struct {
URL string
}

// Upgrade upgrades the protocol version running on the stellar core instance
func (c *Client) Upgrade(ctx context.Context, version int) error {
queryParams := url.Values{}
queryParams.Add("mode", "set")
queryParams.Add("upgradetime", "1970-01-01T00:00:00Z")
queryParams.Add("protocolversion", strconv.Itoa(version))

req, err := c.simpleGet(ctx, "upgrades", queryParams)
if err != nil {
return errors.Wrap(err, "failed to create request")
}

hresp, err := c.http().Do(req)
if err != nil {
return errors.Wrap(err, "http request errored")
}
defer hresp.Body.Close()

if !(hresp.StatusCode >= 200 && hresp.StatusCode < 300) {
return errors.New("http request failed with non-200 status code")
}

return nil
}

// Info calls the `info` command on the connected stellar core and returns the
// provided response
func (c *Client) Info(ctx context.Context) (resp *proto.InfoResponse, err error) {
Expand Down
5 changes: 0 additions & 5 deletions go.list
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973
github.com/client9/misspell v0.3.4
github.com/davecgh/go-spew v1.1.1
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/docker/distribution v2.7.1+incompatible
github.com/docker/docker v1.13.1
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.4.0
github.com/eapache/go-resiliency v1.1.0
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21
github.com/eapache/queue v1.1.0
Expand Down Expand Up @@ -85,7 +81,6 @@ github.com/moul/http2curl v0.0.0-20161031194548-4e24498b31db
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223
github.com/onsi/ginkgo v1.7.0
github.com/onsi/gomega v1.4.3
github.com/opencontainers/go-digest v1.0.0
github.com/opentracing/opentracing-go v1.1.0
github.com/openzipkin/zipkin-go v0.1.6
github.com/pierrec/lz4 v2.0.5+incompatible
Expand Down
5 changes: 0 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ require (
github.com/asaskevich/govalidator v0.0.0-20180319081651-7d2e70ef918f
github.com/aws/aws-sdk-go v1.25.25
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/docker v1.13.1
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.4.0 // indirect
github.com/elazarl/go-bindata-assetfs v1.0.0
github.com/fatih/structs v1.0.0 // indirect
github.com/gavv/monotime v0.0.0-20161010190848-47d58efa6955 // indirect
Expand Down Expand Up @@ -51,7 +47,6 @@ require (
github.com/moul/http2curl v0.0.0-20161031194548-4e24498b31db // indirect
github.com/onsi/ginkgo v1.7.0
github.com/onsi/gomega v1.4.3
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opentracing/opentracing-go v1.1.0 // indirect
github.com/pkg/errors v0.8.1
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829
Expand Down
10 changes: 0 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug=
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo=
github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
Expand Down Expand Up @@ -156,8 +148,6 @@ github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
Expand Down
25 changes: 25 additions & 0 deletions services/horizon/docker/docker-compose.integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '3'
tamirms marked this conversation as resolved.
Show resolved Hide resolved
services:
core-postgres:
image: postgres:9.6.17-alpine
restart: on-failure
environment:
- POSTGRES_PASSWORD=mysecretpassword
- POSTGRES_DB=stellar
ports:
- "5641:5641"
command: ["-p", "5641"]
core:
image: stellar/stellar-core
depends_on:
- core-postgres
restart: on-failure
ports:
- "11625:11625"
- "11626:11626"
# add extra port for history archive server
- "1570:1570"
command: /start standalone
volumes:
- ./stellar-core-integration-tests.cfg:/stellar-core.cfg
- ./core-start.sh:/start
6 changes: 3 additions & 3 deletions services/horizon/docker/docker-compose.standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ services:
environment:
- HISTORY_ARCHIVE_URLS=http://host.docker.internal:1570
- NETWORK_PASSPHRASE=Standalone Network ; February 2017
# this container will invoke a request to upgrade stellar core to protocol 13
# this container will invoke a request to upgrade stellar core to protocol 14 (by default)
tamirms marked this conversation as resolved.
Show resolved Hide resolved
core-upgrade:
restart: on-failure
image: curlimages/curl:7.69.1
command: ["-v", "-f", "http://host.docker.internal:11626/upgrades?mode=set&upgradetime=1970-01-01T00:00:00Z&protocolversion=13"]
command: ["-v", "-f", "http://host.docker.internal:11626/upgrades?mode=set&upgradetime=1970-01-01T00:00:00Z&protocolversion=${PROTOCOL_VERSION:-15}"]
network_mode: '${NETWORK_MODE:-bridge}'

28 changes: 28 additions & 0 deletions services/horizon/docker/stellar-core-integration-tests.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# simple configuration for a standalone test "network"
# see stellar-core_example.cfg for a description of the configuration parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you consider using a template instead of having multiple configuration files?

Copy link
Contributor

Choose a reason for hiding this comment

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

could you elaborate on how we could use a template here (e.g. what templating engine would we use, how would we invoke the template to generate the actual configuration we need) ?

Copy link
Contributor

@2opremio 2opremio Oct 30, 2020

Choose a reason for hiding this comment

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

e.g. https://golang.org/pkg/text/template/ would probably be enough , you would need to use Go (e.g. from the integration tests) to fill it in.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, I think we'll definitely take this approach if we need to generate several stellar core configurations for the different integration test cases. for now it seems that this stellar core configuration will work for all the integration test cases


RUN_STANDALONE=false
MANUAL_CLOSE=true

NETWORK_PASSPHRASE="Standalone Network ; February 2017"

PEER_PORT=11625
HTTP_PORT=11626
PUBLIC_HTTP_PORT=true

NODE_SEED="SACJC372QBSSKJYTV5A7LWT4NXWHTQO6GHG4QDAVC2XDPX6CNNXFZ4JK"

NODE_IS_VALIDATOR=true
UNSAFE_QUORUM=true
FAILURE_SAFETY=0

DATABASE="postgresql://user=postgres password=mysecretpassword host=core-postgres port=5641 dbname=stellar"

[QUORUM_SET]
THRESHOLD_PERCENT=100
VALIDATORS=["GD5KD2KEZJIGTC63IGW6UMUSMVUVG5IHG64HUTFWCHVZH2N2IBOQN7PS"]

[HISTORY.vs]
get="cp history/vs/{0} {1}"
put="cp {0} history/vs/{1}"
mkdir="mkdir -p history/vs/{0}"
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestProtocol14StateVerifier(t *testing.T) {

// Reach the first checkpoint ledger
// Core will push to history archives *after* checkpoint ledger
itest.CloseCoreLedgersUntilSequence(firstCheckpoint + 1)
err = itest.CloseCoreLedgersUntilSequence(firstCheckpoint + 1)
assert.NoError(t, err)
for !itest.LedgerIngested(firstCheckpoint) {
time.Sleep(time.Second)
Expand All @@ -118,16 +118,17 @@ func TestProtocol14StateVerifier(t *testing.T) {
}

// Trigger state rebuild to check if ingesting from history archive works
itest.RunHorizonCLICommand("expingest", "trigger-state-rebuild")
err = itest.Horizon().HistoryQ().UpdateExpIngestVersion(0)
assert.NoError(t, err)

// Wait for the second checkpoint ledger and state rebuild
// Core will push to history archives *after* checkpoint ledger
itest.CloseCoreLedgersUntilSequence(secondCheckpoint + 1)
err = itest.CloseCoreLedgersUntilSequence(secondCheckpoint + 1)
assert.NoError(t, err)

// Wait for the third checkpoint ledger and state verification trigger
// Core will push to history archives *after* checkpoint ledger
itest.CloseCoreLedgersUntilSequence(thirdCheckpoint + 1)
err = itest.CloseCoreLedgersUntilSequence(thirdCheckpoint + 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

assert.NoError(t, err)
for !itest.LedgerIngested(thirdCheckpoint) {
time.Sleep(time.Second)
Expand Down
10 changes: 5 additions & 5 deletions services/horizon/internal/integration/protocol14_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ func TestHappyClaimableBalances(t *testing.T) {
a, b, c := keys[0], keys[1], keys[2]
accountA, accountB, accountC := accounts[0], accounts[1], accounts[2]

/*
* Each sub-test is completely self-contained: at the end of the test, we
* start with a clean slate for each account. This lets us check with
* equality for things like "number of operations," etc.
*/
//
// Each sub-test is completely self-contained: at the end of the test, we
// start with a clean slate for each account. This lets us check with
// equality for things like "number of operations," etc.
//

// We start simple: native asset, single destination, no predicate.
t.Run("Simple/Native", func(t *testing.T) {
Expand Down
Loading