Skip to content

Commit 00a7f1b

Browse files
committed
testcontainers-go integration
1 parent 34fdeeb commit 00a7f1b

File tree

6 files changed

+675
-179
lines changed

6 files changed

+675
-179
lines changed

.github/workflows/main.yml

Lines changed: 186 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
go: [ '1.19', '1.20' ]
19+
go: [ '1.20' ]
2020
steps:
2121
- uses: actions/checkout@v3
2222
- uses: actions/setup-go@v4
@@ -25,177 +25,201 @@ jobs:
2525
- run: go vet
2626
- name: Run unit tests
2727
run: go test -v -tags unit -race
28-
integration-cassandra:
29-
timeout-minutes: 15
30-
needs:
31-
- build
32-
name: Integration Tests
28+
# integration-cassandra:
29+
# timeout-minutes: 15
30+
# needs:
31+
# - build
32+
# name: Integration Tests
33+
# runs-on: ubuntu-latest
34+
# strategy:
35+
# fail-fast: false
36+
# matrix:
37+
# go: [ '1.19', '1.20' ]
38+
# cassandra_version: [ '4.0.8', '4.1.1' ]
39+
# auth: [ "false" ]
40+
# compressor: [ "snappy" ]
41+
# tags: [ "cassandra", "integration", "ccm" ]
42+
# steps:
43+
# - uses: actions/checkout@v2
44+
# - uses: actions/setup-go@v2
45+
# with:
46+
# go-version: ${{ matrix.go }}
47+
# - uses: actions/cache@v2
48+
# id: gomod-cache
49+
# with:
50+
# path: ~/go/pkg/mod
51+
# key: ${{ runner.os }}-go-${{ hashFiles('go.mod') }}
52+
# restore-keys: |
53+
# ${{ runner.os }}-go-
54+
# - name: Install CCM
55+
# run: pip install "git+https://github.com/riptano/ccm.git@${CCM_VERSION}"
56+
# - name: Start cassandra nodes
57+
# run: |
58+
# VERSION=${{ matrix.cassandra_version }}
59+
# keypath="$(pwd)/testdata/pki"
60+
# conf=(
61+
# "client_encryption_options.enabled: true"
62+
# "client_encryption_options.keystore: $keypath/.keystore"
63+
# "client_encryption_options.keystore_password: cassandra"
64+
# "client_encryption_options.require_client_auth: true"
65+
# "client_encryption_options.truststore: $keypath/.truststore"
66+
# "client_encryption_options.truststore_password: cassandra"
67+
# "concurrent_reads: 2"
68+
# "concurrent_writes: 2"
69+
# "write_request_timeout_in_ms: 5000"
70+
# "read_request_timeout_in_ms: 5000"
71+
# )
72+
#
73+
# if [[ $VERSION == 3.*.* ]]; then
74+
# conf+=(
75+
# "rpc_server_type: sync"
76+
# "rpc_min_threads: 2"
77+
# "rpc_max_threads: 2"
78+
# "enable_user_defined_functions: true"
79+
# "enable_materialized_views: true"
80+
# )
81+
# elif [[ $VERSION == 4.0.* ]]; then
82+
# conf+=(
83+
# "enable_user_defined_functions: true"
84+
# "enable_materialized_views: true"
85+
# )
86+
# else
87+
# conf+=(
88+
# "user_defined_functions_enabled: true"
89+
# "materialized_views_enabled: true"
90+
# )
91+
# fi
92+
#
93+
# ccm remove test || true
94+
#
95+
# ccm create test -v $VERSION -n 3 -d --vnodes --jvm_arg="-Xmx256m -XX:NewSize=100m"
96+
# ccm updateconf "${conf[@]}"
97+
#
98+
# export JVM_EXTRA_OPTS=" -Dcassandra.test.fail_writes_ks=test -Dcassandra.custom_query_handler_class=org.apache.cassandra.cql3.CustomPayloadMirroringQueryHandler"
99+
#
100+
# ccm start --wait-for-binary-proto --verbose
101+
# ccm status
102+
# ccm node1 nodetool status
103+
#
104+
# args="-gocql.timeout=60s -runssl -proto=4 -rf=3 -clusterSize=3 -autowait=2000ms -compressor=${{ matrix.compressor }} -gocql.cversion=$VERSION -cluster=$(ccm liveset) ./..."
105+
#
106+
# echo "args=$args" >> $GITHUB_ENV
107+
# echo "JVM_EXTRA_OPTS=$JVM_EXTRA_OPTS" >> $GITHUB_ENV
108+
# - name: Integration tests
109+
# run: |
110+
# export JVM_EXTRA_OPTS="${{env.JVM_EXTRA_OPTS}}"
111+
# go test -v -tags "${{ matrix.tags }} gocql_debug" -timeout=5m -race ${{ env.args }}
112+
# - name: 'Save ccm logs'
113+
# if: 'failure()'
114+
# uses: actions/upload-artifact@v3
115+
# with:
116+
# name: ccm-cluster
117+
# path: /home/runner/.ccm/test
118+
# retention-days: 5
119+
# integration-auth-cassandra:
120+
# timeout-minutes: 15
121+
# needs:
122+
# - build
123+
# name: Integration Tests with auth
124+
# runs-on: ubuntu-latest
125+
# strategy:
126+
# fail-fast: false
127+
# matrix:
128+
# go: [ '1.19', '1.20' ]
129+
# cassandra_version: [ '4.0.8' ]
130+
# compressor: [ "snappy" ]
131+
# tags: [ "integration" ]
132+
#
133+
# steps:
134+
# - uses: actions/checkout@v3
135+
# - uses: actions/setup-go@v4
136+
# with:
137+
# go-version: ${{ matrix.go }}
138+
# - name: Install CCM
139+
# run: pip install "git+https://github.com/riptano/ccm.git@${CCM_VERSION}"
140+
# - name: Start cassandra nodes
141+
# run: |
142+
# VERSION=${{ matrix.cassandra_version }}
143+
# keypath="$(pwd)/testdata/pki"
144+
# conf=(
145+
# "client_encryption_options.enabled: true"
146+
# "client_encryption_options.keystore: $keypath/.keystore"
147+
# "client_encryption_options.keystore_password: cassandra"
148+
# "client_encryption_options.require_client_auth: true"
149+
# "client_encryption_options.truststore: $keypath/.truststore"
150+
# "client_encryption_options.truststore_password: cassandra"
151+
# "concurrent_reads: 2"
152+
# "concurrent_writes: 2"
153+
# "write_request_timeout_in_ms: 5000"
154+
# "read_request_timeout_in_ms: 5000"
155+
# "authenticator: PasswordAuthenticator"
156+
# "authorizer: CassandraAuthorizer"
157+
# "enable_user_defined_functions: true"
158+
# )
159+
#
160+
# if [[ $VERSION == 3.*.* ]]; then
161+
# conf+=(
162+
# "rpc_server_type: sync"
163+
# "rpc_min_threads: 2"
164+
# "rpc_max_threads: 2"
165+
# "enable_user_defined_functions: true"
166+
# "enable_materialized_views: true"
167+
# )
168+
# elif [[ $VERSION == 4.0.* ]]; then
169+
# conf+=(
170+
# "enable_user_defined_functions: true"
171+
# "enable_materialized_views: true"
172+
# )
173+
# else
174+
# conf+=(
175+
# "user_defined_functions_enabled: true"
176+
# "materialized_views_enabled: true"
177+
# )
178+
# fi
179+
#
180+
# ccm remove test || true
181+
#
182+
# ccm create test -v $VERSION -n 1 -d --vnodes --jvm_arg="-Xmx256m -XX:NewSize=100m"
183+
# ccm updateconf "${conf[@]}"
184+
#
185+
# rm -rf $HOME/.ccm/test/node1/data/system_auth
186+
#
187+
# export JVM_EXTRA_OPTS=" -Dcassandra.test.fail_writes_ks=test -Dcassandra.custom_query_handler_class=org.apache.cassandra.cql3.CustomPayloadMirroringQueryHandler"
188+
#
189+
# ccm start --wait-for-binary-proto --verbose
190+
# ccm status
191+
# ccm node1 nodetool status
192+
#
193+
# args="-gocql.timeout=60s -runssl -proto=4 -rf=3 -clusterSize=1 -autowait=2000ms -compressor=${{ matrix.compressor }} -gocql.cversion=$VERSION -cluster=$(ccm liveset) ./..."
194+
#
195+
# echo "args=$args" >> $GITHUB_ENV
196+
# echo "JVM_EXTRA_OPTS=$JVM_EXTRA_OPTS" >> $GITHUB_ENV
197+
# sleep 30s
198+
# - name: Integration tests
199+
# run: |
200+
# export JVM_EXTRA_OPTS="${{env.JVM_EXTRA_OPTS}}"
201+
# go test -v -run=TestAuthentication -tags "${{ matrix.tags }} gocql_debug" -timeout=15s -runauth ${{ env.args }}
202+
#
203+
integration-testscontainers:
204+
needs: build
33205
runs-on: ubuntu-latest
206+
name: testcontainers-go
34207
strategy:
35-
fail-fast: false
36208
matrix:
37-
go: [ '1.19', '1.20' ]
209+
go: [ '1.20' ]
38210
cassandra_version: [ '4.0.8', '4.1.1' ]
39211
auth: [ "false" ]
40212
compressor: [ "snappy" ]
41-
tags: [ "cassandra", "integration", "ccm" ]
213+
tags: [ "cassandra", "integration"]
42214
steps:
43215
- uses: actions/checkout@v2
44216
- uses: actions/setup-go@v2
45217
with:
46218
go-version: ${{ matrix.go }}
47-
- uses: actions/cache@v2
48-
id: gomod-cache
49-
with:
50-
path: ~/go/pkg/mod
51-
key: ${{ runner.os }}-go-${{ hashFiles('go.mod') }}
52-
restore-keys: |
53-
${{ runner.os }}-go-
54-
- name: Install CCM
55-
run: pip install "git+https://github.com/riptano/ccm.git@${CCM_VERSION}"
56-
- name: Start cassandra nodes
219+
- name: setup
57220
run: |
58-
VERSION=${{ matrix.cassandra_version }}
59-
keypath="$(pwd)/testdata/pki"
60-
conf=(
61-
"client_encryption_options.enabled: true"
62-
"client_encryption_options.keystore: $keypath/.keystore"
63-
"client_encryption_options.keystore_password: cassandra"
64-
"client_encryption_options.require_client_auth: true"
65-
"client_encryption_options.truststore: $keypath/.truststore"
66-
"client_encryption_options.truststore_password: cassandra"
67-
"concurrent_reads: 2"
68-
"concurrent_writes: 2"
69-
"write_request_timeout_in_ms: 5000"
70-
"read_request_timeout_in_ms: 5000"
71-
)
72-
73-
if [[ $VERSION == 3.*.* ]]; then
74-
conf+=(
75-
"rpc_server_type: sync"
76-
"rpc_min_threads: 2"
77-
"rpc_max_threads: 2"
78-
"enable_user_defined_functions: true"
79-
"enable_materialized_views: true"
80-
)
81-
elif [[ $VERSION == 4.0.* ]]; then
82-
conf+=(
83-
"enable_user_defined_functions: true"
84-
"enable_materialized_views: true"
85-
)
86-
else
87-
conf+=(
88-
"user_defined_functions_enabled: true"
89-
"materialized_views_enabled: true"
90-
)
91-
fi
92-
93-
ccm remove test || true
94-
95-
ccm create test -v $VERSION -n 3 -d --vnodes --jvm_arg="-Xmx256m -XX:NewSize=100m"
96-
ccm updateconf "${conf[@]}"
97-
98-
export JVM_EXTRA_OPTS=" -Dcassandra.test.fail_writes_ks=test -Dcassandra.custom_query_handler_class=org.apache.cassandra.cql3.CustomPayloadMirroringQueryHandler"
99-
100-
ccm start --wait-for-binary-proto --verbose
101-
ccm status
102-
ccm node1 nodetool status
103-
104-
args="-gocql.timeout=60s -runssl -proto=4 -rf=3 -clusterSize=3 -autowait=2000ms -compressor=${{ matrix.compressor }} -gocql.cversion=$VERSION -cluster=$(ccm liveset) ./..."
105-
221+
args="-gocql.timeout=60s -runssl -proto=4 -rf=3 -clusterSize=3 -autowait=2000ms -compressor=${{ matrix.compressor }} -gocql.cversion=${{ matrix.cassandra_version }} ./..."
106222
echo "args=$args" >> $GITHUB_ENV
107-
echo "JVM_EXTRA_OPTS=$JVM_EXTRA_OPTS" >> $GITHUB_ENV
108-
- name: Integration tests
109-
run: |
110-
export JVM_EXTRA_OPTS="${{env.JVM_EXTRA_OPTS}}"
111-
go test -v -tags "${{ matrix.tags }} gocql_debug" -timeout=5m -race ${{ env.args }}
112-
- name: 'Save ccm logs'
113-
if: 'failure()'
114-
uses: actions/upload-artifact@v3
115-
with:
116-
name: ccm-cluster
117-
path: /home/runner/.ccm/test
118-
retention-days: 5
119-
integration-auth-cassandra:
120-
timeout-minutes: 15
121-
needs:
122-
- build
123-
name: Integration Tests with auth
124-
runs-on: ubuntu-latest
125-
strategy:
126-
fail-fast: false
127-
matrix:
128-
go: [ '1.19', '1.20' ]
129-
cassandra_version: [ '4.0.8' ]
130-
compressor: [ "snappy" ]
131-
tags: [ "integration" ]
132-
133-
steps:
134-
- uses: actions/checkout@v3
135-
- uses: actions/setup-go@v4
136-
with:
137-
go-version: ${{ matrix.go }}
138-
- name: Install CCM
139-
run: pip install "git+https://github.com/riptano/ccm.git@${CCM_VERSION}"
140-
- name: Start cassandra nodes
141-
run: |
142-
VERSION=${{ matrix.cassandra_version }}
143-
keypath="$(pwd)/testdata/pki"
144-
conf=(
145-
"client_encryption_options.enabled: true"
146-
"client_encryption_options.keystore: $keypath/.keystore"
147-
"client_encryption_options.keystore_password: cassandra"
148-
"client_encryption_options.require_client_auth: true"
149-
"client_encryption_options.truststore: $keypath/.truststore"
150-
"client_encryption_options.truststore_password: cassandra"
151-
"concurrent_reads: 2"
152-
"concurrent_writes: 2"
153-
"write_request_timeout_in_ms: 5000"
154-
"read_request_timeout_in_ms: 5000"
155-
"authenticator: PasswordAuthenticator"
156-
"authorizer: CassandraAuthorizer"
157-
"enable_user_defined_functions: true"
158-
)
159-
160-
if [[ $VERSION == 3.*.* ]]; then
161-
conf+=(
162-
"rpc_server_type: sync"
163-
"rpc_min_threads: 2"
164-
"rpc_max_threads: 2"
165-
"enable_user_defined_functions: true"
166-
"enable_materialized_views: true"
167-
)
168-
elif [[ $VERSION == 4.0.* ]]; then
169-
conf+=(
170-
"enable_user_defined_functions: true"
171-
"enable_materialized_views: true"
172-
)
173-
else
174-
conf+=(
175-
"user_defined_functions_enabled: true"
176-
"materialized_views_enabled: true"
177-
)
178-
fi
179-
180-
ccm remove test || true
181-
182-
ccm create test -v $VERSION -n 1 -d --vnodes --jvm_arg="-Xmx256m -XX:NewSize=100m"
183-
ccm updateconf "${conf[@]}"
184-
185-
rm -rf $HOME/.ccm/test/node1/data/system_auth
186-
187-
export JVM_EXTRA_OPTS=" -Dcassandra.test.fail_writes_ks=test -Dcassandra.custom_query_handler_class=org.apache.cassandra.cql3.CustomPayloadMirroringQueryHandler"
188-
189-
ccm start --wait-for-binary-proto --verbose
190-
ccm status
191-
ccm node1 nodetool status
192-
193-
args="-gocql.timeout=60s -runssl -proto=4 -rf=3 -clusterSize=1 -autowait=2000ms -compressor=${{ matrix.compressor }} -gocql.cversion=$VERSION -cluster=$(ccm liveset) ./..."
194-
195-
echo "args=$args" >> $GITHUB_ENV
196-
echo "JVM_EXTRA_OPTS=$JVM_EXTRA_OPTS" >> $GITHUB_ENV
197-
sleep 30s
198-
- name: Integration tests
199-
run: |
200-
export JVM_EXTRA_OPTS="${{env.JVM_EXTRA_OPTS}}"
201-
go test -v -run=TestAuthentication -tags "${{ matrix.tags }} gocql_debug" -timeout=15s -runauth ${{ env.args }}
223+
- name: run
224+
run: |
225+
go test -v -tags "${{ matrix.tags }} gocql_debug" -timeout=5m -race ${{ env.args }}

cassandra_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,14 +3005,12 @@ func TestDiscoverViaProxy(t *testing.T) {
30053005
session := createSessionFromCluster(cluster, t)
30063006
defer session.Close()
30073007

3008-
// we shouldnt need this but to be safe
3009-
time.Sleep(1 * time.Second)
3010-
30113008
session.pool.mu.RLock()
3009+
30123010
for _, host := range clusterHosts {
30133011
found := false
30143012
for _, hi := range session.pool.hostConnPools {
3015-
if hi.host.ConnectAddress().String() == host {
3013+
if hi.host.RPCAddress().String() == host {
30163014
found = true
30173015
break
30183016
}

0 commit comments

Comments
 (0)