Skip to content

Instantly share code, notes, and snippets.

@RobinDaugherty
Created April 27, 2015 16:48
Show Gist options
  • Save RobinDaugherty/ed235b9a175fd85e3136 to your computer and use it in GitHub Desktop.
Save RobinDaugherty/ed235b9a175fd85e3136 to your computer and use it in GitHub Desktop.
Cassandra timeout on CircleCI
#!/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
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