Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

more releaseops goodness. add coverage tasks. informal notes.

  • Loading branch information...
commit d02de00eb3d322c59447b61d8ffa2dd804783dbf 1 parent d2c240c
@slyphon slyphon authored
View
1  .gitignore
@@ -9,3 +9,4 @@ html
Gemfile.*
wiki
zookeeper
+coverage/
View
4 .travis.yml
@@ -6,6 +6,10 @@ notifications:
env:
- SPAWN_ZOOKEEPER='true'
+# pull in releaseops submodule
+before_install:
+ - git submodule update --init --recursive
+
rvm:
- 1.9.3
- 1.9.2
View
4 Gemfile
@@ -20,6 +20,10 @@ group :docs do
end
end
+platform :mri_19 do
+ gem 'simplecov', :group => :coverage, :require => false
+end
+
group :test do
gem 'rspec', '~> 2.8.0'
gem 'flexmock', '~> 0.8.10'
View
38 Rakefile
@@ -1,32 +1,26 @@
-RELEASE_OPS_PATH = File.expand_path('../releaseops/lib', __FILE__)
+release_ops_path = File.expand_path('../releaseops/lib', __FILE__)
# if the special submodule is availabe, use it
-if File.exists?(RELEASE_OPS_PATH)
- $stderr.puts "RELEASE_OPS_PATH: #{RELEASE_OPS_PATH}"
- $LOAD_PATH.unshift(RELEASE_OPS_PATH).uniq!
- require 'releaseops'
+# we use a submodule because it doesn't depend on anything else (*cough* bundler)
+# and can be shared across projects
+#
+if File.exists?(release_ops_path)
+ require File.join(release_ops_path, 'releaseops')
+ # sets up the multi-ruby zk:test_all rake tasks
ReleaseOps::TestTasks.define_for(*%w[1.8.7 1.9.2 jruby rbx ree 1.9.3])
- ReleaseOps::YardTasks.define
- task :clean => 'yard:clean'
-end
+ # sets up the task :default => 'spec:run' and defines a simple
+ # "run the specs with the current rvm profile" task
+ ReleaseOps::TestTasks.define_simple_default_for_travis
-namespace :spec do
- task :define do
- require 'rubygems'
- require 'bundler/setup'
- require 'rspec/core/rake_task'
+ # Define a task to run code coverage tests
+ ReleaseOps::TestTasks.define_simplecov_tasks
- RSpec::Core::RakeTask.new('spec:runner') do |t|
- t.rspec_opts = '-f d' if ENV['TRAVIS']
- end
- end
+ # set up yard:server, yard:gems, and yard:clean tasks
+ # for doing documentation stuff
+ ReleaseOps::YardTasks.define
- task :run => :define do
- Rake::Task['spec:runner'].invoke
- end
+ task :clean => 'yard:clean'
end
-task :default => 'spec:run'
-
View
20 notes/documentation-notes
@@ -0,0 +1,20 @@
+A Day at the Races
+
+* What are race conditions?
+ * Simple example with changing a node
+ * Simple example with a node being deleted
+* What pattern do we use in ZK to manage this problem?
+
+```ruby
+def block_until_node_deleted(zk, abs_node_path)
+ node_deletion_cb = lambda do |event|
+ if event.node_deleted?
+ queue.enq(:deleted)
+ else
+ queue.enq(:deleted) unless exists?(abs_node_path, :watch => true)
+ end
+ end
+
+subs << event_handler.register(abs_node_path, &node_deletion_cb)
+```
+
View
39 notes/voting-notes.txt
@@ -0,0 +1,39 @@
+overall subject of voting is '/blah'
+
+all nodes denote presence create('/blah/nodes/id', '', :ephemeral => true)
+
+coordinator notes children('/blah/nodes/id', watch: true)
+
+if any presence nodes are deleted, the transaction is aborted
+
+nodes children('/blah/tx', watch: true)
+
+coordinator voteseq = create('/blah/tx/vote', 'proposal', sequential: true) # beginning of election
+
+coordinator children('/blah/tx/voteseq', watch: true) # loop until all nodes checked in
+
+nodes children('/blah/tx')
+nodes children('/blah/tx/voteseq', watch: true) # all nodes voted, then commit
+nodes get('/blah/tx/voteseq', watch: true) # if data == 'abort' then delete id node
+nodes get('/blah/tx/votes_uuid/result' watch: true) # result will be placed here?
+nodes create('/blah/tx/voteseq/id', up_or_down, ephemeral: true) # any node votes down, abort
+
+# coordinator sees all votes have been cast
+
+# NOTE: is this step necessary? the coordinator confirming?
+
+coordinator create('/blah/tx/voteseq/result', up_or_down, ephemeral: true)
+
+# nodes tear down
+
+node delete('/blah/tx/voteseq/id')
+
+# when just result node is left
+
+coordinator rm_rf('/blah/tx/voteseq')
+
+
+# at many points we need a timer to see if things are taking too long
+
+
+
2  releaseops
@@ -1 +1 @@
-Subproject commit b8293f06f153ad935ae7c7cc711ab05175a71b89
+Subproject commit 207a3c5444432493cb97eab586a574e29f37521b
View
9 spec/spec_helper.rb
@@ -1,7 +1,14 @@
require 'rubygems'
require 'bundler/setup'
-# $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
+# not a constant so we don't pollute global namespace
+release_ops_path = File.expand_path('../../releaseops/lib', __FILE__)
+
+if File.exists?(release_ops_path)
+ require File.join(release_ops_path, 'releaseops')
+ ReleaseOps::SimpleCov.maybe_start
+end
+
Bundler.require(:development, :test)
Please sign in to comment.
Something went wrong with that request. Please try again.