Created
April 27, 2015 16:48
-
-
Save RobinDaugherty/ed235b9a175fd85e3136 to your computer and use it in GitHub Desktop.
Cassandra timeout on CircleCI
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
#!/bin/bash | |
echo "describe cluster;" > /tmp/dc | |
for i in {1..5}; do | |
echo Attempt $i | |
if cassandra-cli -f /tmp/dc 2>&1 | grep "Cluster Information"; then | |
exit 0 | |
else | |
sudo service cassandra stop; sudo service cassandra start | |
sleep 10 | |
fi | |
done | |
exit 1 |
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
RSpec.configure do |config| | |
config.before :suite do | |
successful = false | |
start_time = Time.now | |
Timeout.timeout(5.minutes) do | |
begin | |
# Choose a Cequel record. Doesn't matter which one. | |
CequelRecordObject.create(id: '12345').destroy | |
successful = true | |
rescue Cassandra::Errors::WriteTimeoutError | |
puts "Cassandra is not yet available. Trying again..." | |
sleep 3 | |
end until successful | |
end | |
elapsed_time = Time.now - start_time | |
puts "Waited #{elapsed_time} seconds for Cassandra to become available." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment