-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathtest.sh
executable file
·73 lines (54 loc) · 2.26 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
PLATFORM=`uname`
CASSANDRA_VERSION=3.3
CASS1="cassandra-migration-test-container-1"
CASS2="cassandra-migration-test-container-2"
PORT=9042
KEYSPACE='versioning'
CFG_FILE='migrations.json'
DOCKER_CMD="docker"
$DOCKER_CMD kill $CASS1
$DOCKER_CMD rm $CASS1
$DOCKER_CMD run --name=$CASS1 -P -d cassandra:$CASSANDRA_VERSION
CASS1_IP=`${DOCKER_CMD} inspect -f '{{ .NetworkSettings.IPAddress }}' ${CASS1}`
echo "Cassandra 1 IP: ${CASS1_IP}"
$DOCKER_CMD kill $CASS2
$DOCKER_CMD rm $CASS2
$DOCKER_CMD run --name=$CASS2 -P -e CASSANDRA_SEEDS="${CASS1_IP}" -d cassandra:$CASSANDRA_VERSION
CASS2_IP=`${DOCKER_CMD} inspect -f '{{ .NetworkSettings.IPAddress }}' ${CASS2}`
echo "Cassandra 2 IP: ${CASS2_IP}"
echo "Waiting for node 1 to come online..."
node_modules/wait-for-cassandra/bin/wait-for-cassandra --host=$CASS1_IP --port=$PORT
echo "Waiting for node 2 to come online..."
node_modules/wait-for-cassandra/bin/wait-for-cassandra --host=$CASS2_IP --port=$PORT
echo "{" > $CFG_FILE
echo " \"migrationsDir\": \"test\"," >> $CFG_FILE
echo " \"cassandra\": {" >> $CFG_FILE
echo " \"contactPoints\": [\"${CASS1_IP}\", \"${CASS2_IP}\"]," >> $CFG_FILE
echo " \"protocolOptions\": {" >> $CFG_FILE
echo " \"port\": ${PORT}" >> $CFG_FILE
echo " }," >> $CFG_FILE
echo " \"keyspace\": \"${KEYSPACE}\"" >> $CFG_FILE
echo " }," >> $CFG_FILE
echo " \"auth\": {" >> $CFG_FILE
echo " \"username\": \"cassandra\"," >> $CFG_FILE
echo " \"password\": \"cassandra\"" >> $CFG_FILE
echo " }" >> $CFG_FILE
echo "}" >> $CFG_FILE
node keyspace.js
echo "Cluster status from node 1:"
$DOCKER_CMD exec $CASS1 nodetool status $KEYSPACE
echo ""
echo "Cluster status from node 2:"
$DOCKER_CMD exec $CASS2 nodetool status $KEYSPACE
# Apply migrations up to version 1
./node_modules/.bin/coffee src/index.coffee -d -t 1 $CFG_FILE
# Apply the remaining migrations
./node_modules/.bin/coffee src/index.coffee -d $CFG_FILE
echo "Version table from node 1:"
$DOCKER_CMD exec $CASS1 cqlsh --execute "SELECT * FROM versioning.schema_version"
echo ""
echo "Version table from node 2:"
$DOCKER_CMD exec $CASS2 cqlsh --execute "SELECT * FROM versioning.schema_version"
#$DOCKER_CMD exec -it $CASS1 cqlsh -u cassandra -p cassandra localhost
$DOCKER_CMD exec -it $CASS2 cqlsh -u cassandra -p cassandra localhost