-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from scylladb/ci-tests
Continuous integration
- Loading branch information
Showing
7 changed files
with
192 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
env: | ||
SCYLLA_SUBNET: 192.168.100.0/24 | ||
SCYLLA_SRC_URI: 192.168.100.100 | ||
SCYLLA_DST_URI: 192.168.100.200 | ||
SCYLLA_IMAGE: scylladb/scylla | ||
|
||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: git checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.18.0 | ||
stable: true | ||
|
||
- name: go build | ||
run: go build -v ./... | ||
|
||
- name: go vet | ||
run: go vet -v ./... | ||
|
||
- name: start the Scylla nodes for the test | ||
run: | | ||
sudo sh -c "echo 2097152 >> /proc/sys/fs/aio-max-nr" | ||
docker-compose -f ./ci/docker-compose.yml up -d | ||
until docker-compose -f ./ci/docker-compose.yml exec -T source_node cqlsh -e "select * from system.local" ; do sleep 1; done | ||
until docker-compose -f ./ci/docker-compose.yml exec -T destination_node cqlsh -e "select * from system.local" ; do sleep 1; done | ||
- name: go test | ||
run: go test -v ./... | ||
|
||
- name: stop the Scylla nodes | ||
run: docker-compose -f ./ci/docker-compose.yml stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
version: "3.7" | ||
|
||
services: | ||
source_node: | ||
image: scylladb/scylla | ||
command: --seeds ${SCYLLA_SRC_URI} --skip-wait-for-gossip-to-settle 0 | ||
networks: | ||
public: | ||
ipv4_address: ${SCYLLA_SRC_URI} | ||
destination_node: | ||
image: scylladb/scylla | ||
command: --seeds ${SCYLLA_DST_URI} --skip-wait-for-gossip-to-settle 0 | ||
networks: | ||
public: | ||
ipv4_address: ${SCYLLA_DST_URI} | ||
|
||
networks: | ||
public: | ||
driver: bridge | ||
ipam: | ||
driver: default | ||
config: | ||
- subnet: ${SCYLLA_SUBNET} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package testutils | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"sync/atomic" | ||
"testing" | ||
"time" | ||
|
||
"github.com/gocql/gocql" | ||
) | ||
|
||
var ( | ||
testStartTimestamp time.Time | ||
currentTestNumber uint32 = 0 | ||
) | ||
|
||
func init() { | ||
testStartTimestamp = time.Now() | ||
} | ||
|
||
func GetUniqueName(prefix string) string { | ||
unixNano := testStartTimestamp.UnixNano() | ||
uniqueId := atomic.AddUint32(¤tTestNumber, 1) - 1 | ||
return fmt.Sprintf("%s_%d_%d", prefix, unixNano, uniqueId) | ||
} | ||
|
||
func GetSourceClusterContactPoint() string { | ||
uri := os.Getenv("SCYLLA_SRC_URI") | ||
if uri == "" { | ||
uri = "127.0.0.1" | ||
} | ||
return uri | ||
} | ||
|
||
func GetDestinationClusterContactPoint() string { | ||
uri := os.Getenv("SCYLLA_DST_URI") | ||
if uri == "" { | ||
uri = "127.0.0.2" | ||
} | ||
return uri | ||
} | ||
|
||
func CreateKeyspace(t *testing.T, contactPoint string, keyspaceName string) { | ||
cluster := gocql.NewCluster(contactPoint) | ||
session, err := cluster.CreateSession() | ||
if err != nil { | ||
t.Fatalf("failed to create session: %v", err) | ||
} | ||
|
||
defer session.Close() | ||
err = session.Query(fmt.Sprintf("CREATE KEYSPACE %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}", keyspaceName)).Exec() | ||
if err != nil { | ||
t.Fatalf("failed to create keyspace %s: %v", keyspaceName, err) | ||
} | ||
|
||
err = session.AwaitSchemaAgreement(context.Background()) | ||
if err != nil { | ||
t.Fatalf("awaiting schema agreement failed: %v", err) | ||
} | ||
} | ||
|
||
func CreateUniqueKeyspace(t *testing.T, contactPoint string) string { | ||
keyspaceName := GetUniqueName("test_keyspace") | ||
CreateKeyspace(t, contactPoint, keyspaceName) | ||
return keyspaceName | ||
} |
Oops, something went wrong.