Skip to content

Commit

Permalink
add missing model
Browse files Browse the repository at this point in the history
  • Loading branch information
TEAMOD committed Mar 12, 2009
1 parent a206aa9 commit 1d6a6e4
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Rakefile
@@ -0,0 +1,10 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))

require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

require 'tasks/rails'
78 changes: 78 additions & 0 deletions app/models/scheduler.rb
@@ -0,0 +1,78 @@
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'rufus/scheduler'

# Uses the rufus scheduler to check for builds that passed or failed. Performs X10 action with bottlerocket's 'br' command

class Scheduler
include Singleton

def start
@last = {}
@failing_builds = Set.new

scheduler = Rufus::Scheduler.start_new
scheduler.every "10s" do
parse(Conf.ruby1_url)
parse(Conf.build1_url)
end
end


def parse(url)
file = open(url);
doc = Hpricot.XML(file)
file.close
# name="2008-07-25-homepage" activity="Sleeping" lastBuildStatus="Failure" lastBuildLabel="" lastBuildTime="2008-10-01T20:51:46"
doc.search("/projects/project").each do |project|
project_name = project.attributes["name"]
status = project.attributes["lastBuildStatus"]
time = project.attributes["lastBuildTime"]

followed_builds = Conf.branches.split(",").map {|x| x.strip}

if followed_builds.include?(project_name)
previous_build = @last[project_name]
@last[project_name] = {"project" => project_name, "time" => time, "status" => status}

if status.include?("Fail")
@failing_builds << project_name
on_fail(project_name)
elsif !previous_build.nil? && (previous_build["time"] != time) && status.include?("Success")
@failing_builds.delete(project_name)
if (!previous_build["status"].include?("Fail"))
on_pass(project_name)
off_pass
off_pass
elsif @failing_builds.empty?
off_fail
end
end
end
end
end

def on_pass(project_name)
puts "#{project_name} Bubbles!!!!!"
system("br #{Conf.x10_house_code}#{Conf.x10_pass_device} ON")
sleep 3
end

def off_pass
puts "Bubbles Off"
system("br #{Conf.x10_house_code}#{Conf.x10_pass_device} OFF")
sleep 2
end

def on_fail(project_name)
puts "#{project_name} Red Light!!!"
system("br #{Conf.x10_house_code}#{Conf.x10_failure_device} ON")
end

def off_fail
puts "Light Off"
system("br #{Conf.x10_house_code}#{Conf.x10_failure_device} OFF")
end

end
1 change: 0 additions & 1 deletion app/models/scheduler.rb~
Expand Up @@ -4,7 +4,6 @@ require 'open-uri'
require 'rufus/scheduler'

# Uses the rufus scheduler to check for builds that passed or failed. Performs X10 action with bottlerocket's 'br' command
# Author: Patrick Foley

class Scheduler
include Singleton
Expand Down
6 changes: 6 additions & 0 deletions test/XmlStatusReport.aspx
@@ -0,0 +1,6 @@
<Projects>
<Project lastBuildTime="2008-04-24T17:07:29.0000000-00:00" name="CruiseControlRB" nextBuildTime="1970-01-01T00:00:00.000000-00:00" webUrl="http://cruisecontrolrb.thoughtworks.com/projects/CruiseControlRB" activity="CheckingModifications" category="" lastBuildStatus="Success" lastBuildLabel="623"/>
<Project lastBuildTime="2008-03-28T11:35:22.0000000-00:00" name="Plumbing" nextBuildTime="1970-01-01T00:00:00.000000-00:00" webUrl="http://cruisecontrolrb.thoughtworks.com/projects/Plumbing" activity="CheckingModifications" category="" lastBuildStatus="Success" lastBuildLabel="360"/>
<Project lastBuildTime="2008-04-10T13:18:56.0000000-00:00" name="RubyOnRails" nextBuildTime="1970-01-01T00:00:00.000000-00:00" webUrl="http://cruisecontrolrb.thoughtworks.com/projects/RubyOnRails" activity="Sleeping" category="" lastBuildStatus="Success" lastBuildLabel="9248"/>
<Project lastBuildTime="2008-02-22T14:14:30.0000000-00:00" name="RubyOnRails-2-0-stable" nextBuildTime="1970-01-01T00:00:00.000000-00:00" webUrl="http://cruisecontrolrb.thoughtworks.com/projects/RubyOnRails-2-0-stable" activity="Sleeping" category="" lastBuildStatus="Success" lastBuildLabel="8910"/>
</Projects>
15 changes: 15 additions & 0 deletions test/cctray.xml
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<Projects>
<Project name="cce-release-jdk1.4" activity="Sleeping" lastBuildStatus="Failure" lastBuildLabel="" lastBuildTime="2008-09-25T16:14:41" webUrl="http://cclive.thoughtworks.com/dashboard/build/detail/cce-release-jdk1.4"/>
<Project name="cce-release-jdk1.5" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="" lastBuildTime="2008-09-24T08:23:18" webUrl="http://cclive.thoughtworks.com/dashboard/build/detail/cce-release-jdk1.5"/>
<Project name="cce-release-jdk1.6" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="build.72" lastBuildTime="2008-08-12T08:20:22" webUrl="http://cclive.thoughtworks.com/dashboard/build/detail/cce-release-jdk1.6"/>
<Project name="cclive-release-jdk1.4" activity="Sleeping" lastBuildStatus="Failure" lastBuildLabel="" lastBuildTime="2008-09-24T06:36:56" webUrl="http://cclive.thoughtworks.com/dashboard/build/detail/cclive-release-jdk1.4"/>
<Project name="cclive-release-jdk1.5" activity="Sleeping" lastBuildStatus="Failure" lastBuildLabel="" lastBuildTime="2008-09-24T06:29:41" webUrl="http://cclive.thoughtworks.com/dashboard/build/detail/cclive-release-jdk1.5"/>
<Project name="cclive-release-jdk1.6" activity="Sleeping" lastBuildStatus="Failure" lastBuildLabel="" lastBuildTime="2008-09-24T07:21:15" webUrl="http://cclive.thoughtworks.com/dashboard/build/detail/cclive-release-jdk1.6"/>
<Project name="contrib-distributed-jdk1.5" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="build.23" lastBuildTime="2008-09-24T07:02:15" webUrl="http://cclive.thoughtworks.com/dashboard/build/detail/contrib-distributed-jdk1.5"/>
<Project name="contrib-distributed-jdk1.6" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="build.23" lastBuildTime="2008-09-24T07:21:58" webUrl="http://cclive.thoughtworks.com/dashboard/build/detail/contrib-distributed-jdk1.6"/>
<Project name="JC Test" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="build.32" lastBuildTime="2008-09-24T08:59:35" webUrl="http://cclive.thoughtworks.com/dashboard/build/detail/JC Test"/>
<Project name="test42" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="build.37" lastBuildTime="2008-09-24T09:06:05" webUrl="http://cclive.thoughtworks.com/dashboard/build/detail/test42"/>
<Project name="website-validation" activity="Sleeping" lastBuildStatus="Failure" lastBuildLabel="" lastBuildTime="2008-09-23T02:03:45" webUrl="http://cclive.thoughtworks.com/dashboard/build/detail/website-validation"/>

</Projects>
7 changes: 7 additions & 0 deletions test/fixtures/schedulers.yml
@@ -0,0 +1,7 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html

# one:
# column: value
#
# two:
# column: value
9 changes: 9 additions & 0 deletions test/performance/browsing_test.rb
@@ -0,0 +1,9 @@
require 'test_helper'
require 'performance_test_help'

# Profiling results for each test method are written to tmp/performance.
class BrowsingTest < ActionController::PerformanceTest
def test_homepage
get '/'
end
end
38 changes: 38 additions & 0 deletions test/test_helper.rb
@@ -0,0 +1,38 @@
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'

class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test database remains unchanged so your fixtures don't have to be reloaded
# between every test method. Fewer database queries means faster tests.
#
# Read Mike Clark's excellent walkthrough at
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
#
# Every Active Record database supports transactions except MyISAM tables
# in MySQL. Turn off transactional fixtures in this case; however, if you
# don't care one way or the other, switching from MyISAM to InnoDB tables
# is recommended.
#
# The only drawback to using transactional fixtures is when you actually
# need to test transactions. Since your test is bracketed by a transaction,
# any transactions started in your code will be automatically rolled back.
self.use_transactional_fixtures = true

# Instantiated fixtures are slow, but give you @david where otherwise you
# would need people(:david). If you don't want to migrate your existing
# test cases which use the @david style and don't mind the speed hit (each
# instantiated fixtures translates to a database query per test method),
# then set this back to true.
self.use_instantiated_fixtures = false

# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all

# Add more helper methods to be used by all tests here...
end

0 comments on commit 1d6a6e4

Please sign in to comment.