Skip to content

Commit

Permalink
chore_: start nwaku in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos committed May 29, 2024
1 parent 72ac2dc commit 3b5443f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
35 changes: 27 additions & 8 deletions _assets/ci/Jenkinsfile.tests
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ pipeline {
PLATFORM = 'tests'
DB_CONT = "status-go-test-db-${env.EXECUTOR_NUMBER.toInteger() + 1}"
DB_PORT = "${5432 + env.EXECUTOR_NUMBER.toInteger()}"
NWAKU1_CONT = "status-go-nwaku-${env.EXECUTOR_NUMBER.toInteger() + 1}"
NWAKU1_PORT = "${60000 + env.EXECUTOR_NUMBER.toInteger()}"
NWAKU1_REST_PORT = "${40000 + env.EXECUTOR_NUMBER.toInteger()}"
NWAKU2_CONT = "status-go-nwaku-${env.EXECUTOR_NUMBER.toInteger() + 2}"
NWAKU2_PORT = "${61000 + env.EXECUTOR_NUMBER.toInteger()}"
NWAKU2_REST_PORT = "${41000 + env.EXECUTOR_NUMBER.toInteger()}"
TMPDIR = "${WORKSPACE_TMP}"
GOPATH = "${WORKSPACE_TMP}/go"
GOCACHE = "${WORKSPACE_TMP}/gocache"
Expand Down Expand Up @@ -116,26 +122,39 @@ pipeline {
stage('Unit Tests') {
environment {
TEST_POSTGRES_PORT = "${env.DB_PORT}"

}
steps { script {
db = docker.image('postgres:9.6-alpine').withRun([
"--name=${DB_CONT}",
"--env=POSTGRES_HOST_AUTH_METHOD=trust",
"--publish=${DB_PORT}:${DB_PORT}",
].join(' '), "-p ${DB_PORT}") { c ->
nix.shell('make generate-handlers', pure: true)
withCredentials([
string(
credentialsId: 'codeclimate-test-reporter-id',
variable: 'CC_TEST_REPORTER_ID'
),
]) {
nix.shell('make test-unit V=1', pure: false)
nwaku1 = docker.image('harbor.status.im/wakuorg/nwaku:v0.28.0').withRun([
"--name=${NWAKU1_CONT}",
"--publish=${NWAKU1_PORT}:${NWAKU1_PORT}",
].join(' '), "-p ${NWAKU1_PORT} --store --rest-port=${NWAKU1_REST_PORT} --nodekey=1122334455667788990011223344556677889900112233445566778899001122") { n1 ->
nwaku2 = docker.image('harbor.status.im/wakuorg/nwaku:v0.28.0').withRun([
"--name=${NWAKU2_CONT}",
"--publish=${NWAKU2_PORT}:${NWAKU2_PORT}",
].join(' '), "-p ${NWAKU2_PORT} --store --rest-port=${NWAKU2_REST_PORT} --nodekey=1122334455667788990011223344556677889900112233445566778899003344") { n2 ->
nix.shell('make generate-handlers', pure: true)
withCredentials([
string(
credentialsId: 'codeclimate-test-reporter-id',
variable: 'CC_TEST_REPORTER_ID'
),
]) {
nix.shell('make test-unit V=1', pure: false)
}
}
}
}
} }
post { cleanup { /* Leftover DB containers. */
sh "docker rm ${DB_CONT} || true"
sh "docker rm ${NWAKU1_CONT} || true"
sh "docker rm ${NWAKU2_CONT} || true"
} }
}
} // stages
Expand Down
32 changes: 8 additions & 24 deletions protocol/messenger_storenode_comunity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package protocol
import (
"context"
"fmt"
"os"
"testing"
"time"

Expand Down Expand Up @@ -44,9 +45,7 @@ type MessengerStoreNodeCommunitySuite struct {
bob *Messenger
bobWaku types.Waku

storeNode *waku2.Waku
storeNodeAddress string
communityStoreNode *waku2.Waku
communityStoreNodeAddress string

collectiblesServiceMock *CollectiblesServiceMock
Expand All @@ -61,21 +60,20 @@ func (s *MessengerStoreNodeCommunitySuite) SetupTest() {

s.collectiblesServiceMock = &CollectiblesServiceMock{}

s.storeNode, s.storeNodeAddress = s.createStore("store-1")
s.communityStoreNode, s.communityStoreNodeAddress = s.createStore("store-community")
nwaku1Port := os.Getenv("NWAKU1_PORT")
nwaku2Port := os.Getenv("NWAKU2_PORT")
nwaku1PeerID := "16Uiu2HAmMGhfSTUzKbsjMWxc6T1X4wiTWSF1bEWSLjAukCm7KiHV" // --nodekey=1122334455667788990011223344556677889900112233445566778899001122
nwaku2PeerID := "16Uiu2HAkyZuLQy4sPRte7khemYHmkQewzjdTPRXZcxPH6NgjhR97" // --nodekey=1122334455667788990011223344556677889900112233445566778899003344

s.storeNodeAddress = fmt.Sprintf("/ip4/127.0.0.1/tcp/%d/p2p/%s", nwaku1Port, nwaku1PeerID)
s.communityStoreNodeAddress = fmt.Sprintf("/ip4/127.0.0.1/tcp/%d/p2p/%s", nwaku2Port, nwaku2PeerID)

s.owner, s.ownerWaku = s.newMessenger("owner", s.storeNodeAddress)
s.bob, s.bobWaku = s.newMessenger("bob", s.storeNodeAddress)
}

func (s *MessengerStoreNodeCommunitySuite) TearDown() {
close(s.cancel)
if s.storeNode != nil {
s.Require().NoError(s.storeNode.Stop())
}
if s.communityStoreNode != nil {
s.Require().NoError(s.communityStoreNode.Stop())
}
if s.owner != nil {
TearDownMessenger(&s.Suite, s.owner)
}
Expand All @@ -84,20 +82,6 @@ func (s *MessengerStoreNodeCommunitySuite) TearDown() {
}
}

func (s *MessengerStoreNodeCommunitySuite) createStore(name string) (*waku2.Waku, string) {
cfg := testWakuV2Config{
logger: s.logger.Named(name),
enableStore: true,
useShardAsDefaultTopic: false,
clusterID: shard.UndefinedShardValue,
}

storeNode := NewTestWakuV2(&s.Suite, cfg)
addresses := storeNode.ListenAddresses()
s.Require().GreaterOrEqual(len(addresses), 1, "no storenode listen address")
return storeNode, addresses[0]
}

func (s *MessengerStoreNodeCommunitySuite) newMessenger(name, storenodeAddress string) (*Messenger, types.Waku) {
localMailserverID := "local-mailserver-007"
localFleet := "local-fleet-007"
Expand Down

0 comments on commit 3b5443f

Please sign in to comment.