You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(3) |
Feb
(15) |
Mar
|
Apr
(9) |
May
|
Jun
(6) |
Jul
|
Aug
|
Sep
(23) |
Oct
(25) |
Nov
(44) |
Dec
(9) |
2010 |
Jan
(14) |
Feb
|
Mar
(4) |
Apr
(1) |
May
|
Jun
(3) |
Jul
|
Aug
(4) |
Sep
|
Oct
(10) |
Nov
(4) |
Dec
(22) |
2011 |
Jan
(14) |
Feb
|
Mar
(3) |
Apr
(7) |
May
(16) |
Jun
(4) |
Jul
(6) |
Aug
(3) |
Sep
|
Oct
(4) |
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
(10) |
Apr
(24) |
May
|
Jun
|
Jul
(2) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <jh...@us...> - 2010-01-20 23:55:32
|
Revision: 193 http://etch.svn.sourceforge.net/etch/?rev=193&view=rev Author: jheiss Date: 2010-01-20 23:55:26 +0000 (Wed, 20 Jan 2010) Log Message: ----------- Minor change in save_history to eliminate excess useless warnings. Remove executable flag from etchclient.rb. I think that's a leftover from the distant past. Modified Paths: -------------- trunk/client/etchclient.rb Property Changed: ---------------- trunk/client/etchclient.rb Modified: trunk/client/etchclient.rb =================================================================== --- trunk/client/etchclient.rb 2010-01-20 23:05:05 UTC (rev 192) +++ trunk/client/etchclient.rb 2010-01-20 23:55:26 UTC (rev 193) @@ -1771,7 +1771,9 @@ newcurrent = current+'.new' if File.file?(file) && !File.symlink?(file) puts "Updating history log: #{file} -> #{current}" - remove_file(newcurrent) + if File.exist?(newcurrent) + remove_file(newcurrent) + end FileUtils.copy(file, newcurrent) if (!@dryrun) else puts "Updating history log with 'ls -ld' output: #{file} -> #{current}" Property changes on: trunk/client/etchclient.rb ___________________________________________________________________ Deleted: svn:executable - * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2010-01-20 23:05:13
|
Revision: 192 http://etch.svn.sourceforge.net/etch/?rev=192&view=rev Author: jheiss Date: 2010-01-20 23:05:05 +0000 (Wed, 20 Jan 2010) Log Message: ----------- Rename all of the files with tests to match what Rake::TestTask expects by default, allowing us to clean up the Rakefile a bit. Modified Paths: -------------- trunk/Rakefile Added Paths: ----------- trunk/test/test_actions.rb trunk/test/test_attributes.rb trunk/test/test_auth.rb trunk/test/test_commands.rb trunk/test/test_delete.rb trunk/test/test_depend.rb trunk/test/test_file.rb trunk/test/test_history.rb trunk/test/test_link.rb trunk/test/test_local_requests.rb trunk/test/test_nodegroups.rb trunk/test/test_options.rb trunk/test/test_outputcapture.rb trunk/test/test_scripts.rb trunk/test/test_transitions.rb Removed Paths: ------------- trunk/test/actions.rb trunk/test/attributes.rb trunk/test/auth.rb trunk/test/commands.rb trunk/test/delete.rb trunk/test/depend.rb trunk/test/file.rb trunk/test/history.rb trunk/test/link.rb trunk/test/local_requests.rb trunk/test/nodegroups.rb trunk/test/options.rb trunk/test/outputcapture.rb trunk/test/scripts.rb trunk/test/transitions.rb Modified: trunk/Rakefile =================================================================== --- trunk/Rakefile 2010-01-20 22:43:55 UTC (rev 191) +++ trunk/Rakefile 2010-01-20 23:05:05 UTC (rev 192) @@ -9,6 +9,4 @@ end t.verbose = true - #t.pattern = 'test/*.rb' - t.test_files = Dir.glob('test/*.rb').reject {|test| test =~ /etchtest.rb/} end Deleted: trunk/test/actions.rb =================================================================== --- trunk/test/actions.rb 2010-01-20 22:43:55 UTC (rev 191) +++ trunk/test/actions.rb 2010-01-20 23:05:05 UTC (rev 192) @@ -1,472 +0,0 @@ -#!/usr/bin/ruby -w - -# -# Test etch's handling of various actions: pre, post, setup, test, etc. -# - -require File.join(File.dirname(__FILE__), 'etchtest') - -class EtchActionTests < Test::Unit::TestCase - include EtchTests - - def setup - # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path - #puts "Using #{@targetfile} as target file" - - # Generate a directory for our test repository - @repodir = initialize_repository - @server = get_server(@repodir) - - # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" - - # Generate another file to use as our link target - @destfile = Tempfile.new('etchtest').path - #puts "Using #{@destfile} as link destination file" - end - - def test_actions - - # - # Basic tests to ensure that actions are performed under normal - # circumstances - # - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <server_setup> - <exec>echo server_setup >> #{@repodir}/server_setup</exec> - </server_setup> - <setup> - <exec>echo setup >> #{@repodir}/setup</exec> - </setup> - <pre> - <exec>echo pre >> #{@repodir}/pre</exec> - </pre> - <file> - <warning_file/> - <source> - <plain>source</plain> - </source> - </file> - <test_before_post> - <exec>echo test_before_post >> #{@repodir}/test_before_post</exec> - </test_before_post> - <post> - <exec_once>echo exec_once >> #{@repodir}/exec_once</exec_once> - <exec_once_per_run>echo exec_once_per_run >> #{@repodir}/exec_once_per_run</exec_once_per_run> - <exec_once_per_run>echo exec_once_per_run >> #{@repodir}/exec_once_per_run</exec_once_per_run> - <exec>echo post >> #{@repodir}/post</exec> - </post> - <test> - <exec>echo test >> #{@repodir}/test</exec> - </test> - </config> - EOF - end - - sourcecontents = "This is a test\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running initial action test" - run_etch(@server, @testbase) - - # Verify that the actions were executed - # The setup actions will get run several times as we loop - # back and forth with the server sending original sums and - # contents. So just verify that they were run at least once. - assert_match("server_setup\n", get_file_contents("#{@repodir}/server_setup"), 'server_setup') - assert_match("setup\n", get_file_contents("#{@repodir}/setup"), 'setup') - assert_equal("pre\n", get_file_contents("#{@repodir}/pre"), 'pre') - assert_equal( - "exec_once\n", get_file_contents("#{@repodir}/exec_once"), 'exec_once') - assert_equal( - "exec_once_per_run\n", - get_file_contents("#{@repodir}/exec_once_per_run"), - 'exec_once_per_run') - assert_equal( - "test_before_post\n", - get_file_contents("#{@repodir}/test_before_post"), - 'test_before_post') - assert_equal("post\n", get_file_contents("#{@repodir}/post"), 'post') - assert_equal("test\n", get_file_contents("#{@repodir}/test"), 'test') - - # Run etch again and make sure that the exec_once command wasn't run - # again - run_etch(@server, @testbase) - - assert_equal("exec_once\n", get_file_contents("#{@repodir}/exec_once"), 'exec_once_2nd_check') - end - - def test_failed_setup - # - # Test a failed setup command to ensure etch aborts - # - - # Put some text into the original file so that we can make sure it - # is not touched. - origcontents = "This is the original text\n" - File.delete(@targetfile) - File.open(@targetfile, 'w') do |file| - file.write(origcontents) - end - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <setup> - <exec>false</exec> - </setup> - <file> - <warning_file/> - <source> - <plain>source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "This is a test\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running initial action test" - run_etch(@server, @testbase, true) - - # Verify that the file was not touched - assert_equal(origcontents, get_file_contents(@targetfile), 'failed setup') - end - - def test_failed_pre - # - # Test a failed pre command to ensure etch aborts - # - - # Put some text into the original file so that we can make sure it - # is not touched. - origcontents = "This is the original text\n" - File.delete(@targetfile) - File.open(@targetfile, 'w') do |file| - file.write(origcontents) - end - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <pre> - <exec>false</exec> - </pre> - <file> - <warning_file/> - <source> - <plain>source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "This is a test\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running failed pre test" - run_etch(@server, @testbase, true) - - # Verify that the file was not touched - assert_equal(origcontents, get_file_contents(@targetfile), 'failed pre') - end - - def test_failed_test - # - # Run a test where the test action fails, ensure that the original - # target file is restored and any post actions re-run afterwards - # - - # Put some text into the original file so that we can make sure it - # is restored. - origcontents = "This is the original text\n" - File.delete(@targetfile) - File.open(@targetfile, 'w') do |file| - file.write(origcontents) - end - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <overwrite_directory/> - <source> - <plain>source</plain> - </source> - </file> - <post> - <exec>echo post >> #{@repodir}/post</exec> - </post> - <test> - <exec>false</exec> - </test> - </config> - EOF - end - - # Change the source file so that we can see whether the original was - # restored or not - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write("Testing a failed test\n") - end - - # Run etch - #puts "Running failed test test" - run_etch(@server, @testbase) - - # Verify that the original was restored, and that post was run twice - assert_equal(origcontents, get_file_contents(@targetfile), 'failed test target') - assert_equal("post\npost\n", get_file_contents("#{@repodir}/post"), 'failed test post') - end - - def test_failed_test_before_post - # - # Run a test where the test_before_post action fails, ensure that - # post is not run - # - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <overwrite_directory/> - <source> - <plain>source</plain> - </source> - </file> - <test_before_post> - <exec>false</exec> - </test_before_post> - <post> - <exec>echo post >> #{@repodir}/post</exec> - </post> - </config> - EOF - end - - # Run etch - #puts "Running failed test_before_post test" - run_etch(@server, @testbase, true) - - # Verify that post was not run - assert(!File.exist?("#{@repodir}/post"), 'failed test_before_post post') - - # - # Run a test where the test action fails, and the original target file - # is a symlink. Ensure that the symlink is restored. - # - - # Prepare the target - File.delete(@targetfile) if File.exist?(@targetfile) - File.symlink(@destfile, @targetfile) - - # Run etch - #puts "Running failed test symlink test" - run_etch(@server, @testbase, true) - - # Verify that the original symlink was restored - assert_equal(@destfile, File.readlink(@targetfile), 'failed test symlink') - - # - # Run a test where the test action fails, and the original target file - # is a directory. Ensure that the directory is restored. - # - - # Prepare the target - File.delete(@targetfile) if File.exist?(@targetfile) - Dir.mkdir(@targetfile) - File.open("#{@targetfile}/testfile", 'w') { |file| } - - # Run etch - #puts "Running failed test directory test" - run_etch(@server, @testbase, true) - - # Verify that the original directory was restored - assert(File.directory?(@targetfile), 'failed test directory') - assert(File.file?("#{@targetfile}/testfile"), 'failed test directory contents') - - # - # Run a test where the test action fails, and there is no original - # target file. Ensure that the end result is that there is no file left - # behind. - # - - # We can reuse the config.xml from the previous test - - # Clean up from previous runs - if File.exist?(@targetfile) || File.symlink?(@targetfile) - FileUtils.rm_rf(@targetfile) - end - File.delete("#{@repodir}/post") if File.exist?("#{@repodir}/post") - - # Run etch - #puts "Running failed test no original file test" - run_etch(@server, @testbase, true) - - # Verify that the lack of an original file was restored - assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), 'failed test no original file') - end - - def test_nested_target - # - # Run a test where a test action is defined and the target file is in a - # directory that does not exist yet, thus requiring that we make the - # directory before creating the backup (or rather the NOORIG marker in - # this case). We had a bug where that failed, as the code to make the - # directory structure was after the code to make the backup. - # - # I.e. configuration to create /etc/foo/bar, but /etc/foo does not exist. - # The backup that is created when a test is defined (so that we can roll - # back if the test fails) is made as /etc/foo/bar.XXXXX, which requires - # that /etc/foo exist first. - # - - nestedtargetdir = Tempfile.new('etchtest').path - File.delete(nestedtargetdir) - nestedtargetfile = File.join(nestedtargetdir, 'etchnestedtest') - - FileUtils.mkdir_p("#{@repodir}/source/#{nestedtargetfile}") - File.open("#{@repodir}/source/#{nestedtargetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain>source</plain> - </source> - </file> - <test> - <exec>true</exec> - </test> - </config> - EOF - end - - sourcecontents = "Testing a nested target\n" - File.open("#{@repodir}/source/#{nestedtargetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running nested target with test test" - run_etch(@server, @testbase) - - # Verify that the file was created properly - assert_equal(sourcecontents, get_file_contents(nestedtargetfile), 'nested target with test') - end - - def test_action_with_xml_escape - # - # Test an action requiring XML escape - # The XML spec says that < and & must be escaped almost anywhere - # outside of their use as markup. That includes the character data of - # actions. - # http://www.w3.org/TR/2006/REC-xml-20060816/#syntax - # So if the user wants to use something like && in an action they must - # escape the & with & - # - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain>source</plain> - </source> - </file> - <post> - <exec>true && echo post >> #{@repodir}/post_with_escape</exec> - </post> - </config> - EOF - end - - sourcecontents = "This is a test of a post with XML escapes\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running XML escape test" - run_etch(@server, @testbase) - - # Verify that the action was executed - assert_equal("post\n", get_file_contents("#{@repodir}/post_with_escape"), 'post with escape') - end - - def test_action_with_env - # - # Test an action involving passing an environment variable - # - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain>source</plain> - </source> - </file> - <post> - <exec>TESTVAR=testvalue #{@repodir}/post_with_env</exec> - </post> - </config> - EOF - end - - sourcecontents = "This is a test of a post with an environment variable\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - File.open("#{@repodir}/post_with_env", 'w') do |file| - file.write <<EOF -#!/bin/sh -echo $TESTVAR >> #{@repodir}/post_with_env_output -EOF - end - File.chmod(0755, "#{@repodir}/post_with_env") - - # Run etch - #puts "Running environment variable test" - run_etch(@server, @testbase) - - # Verify that the action was executed - assert_equal("testvalue\n", get_file_contents("#{@repodir}/post_with_env_output"), 'post with environment variable') - end - - def teardown - remove_repository(@repodir) - FileUtils.rm_rf(@testbase) - FileUtils.rm_rf(@targetfile) - FileUtils.rm_f(@destfile) - end -end Deleted: trunk/test/attributes.rb =================================================================== --- trunk/test/attributes.rb 2010-01-20 22:43:55 UTC (rev 191) +++ trunk/test/attributes.rb 2010-01-20 23:05:05 UTC (rev 192) @@ -1,633 +0,0 @@ -#!/usr/bin/ruby -w - -# -# Test etch's handling of attribute filtering in config.xml files -# - -require File.join(File.dirname(__FILE__), 'etchtest') -require 'rubygems' # Might be needed to find facter -require 'facter' - -class EtchAttributeTests < Test::Unit::TestCase - include EtchTests - - def setup - # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path - #puts "Using #{@targetfile} as target file" - - # Generate a directory for our test repository - @repodir = initialize_repository - @server = get_server(@repodir) - - # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" - end - - def test_group_attributes - # - # Simple group name comparison with the node in 0 groups - # - testname = 'node group comparison, 0 groups' - - # Put some text into the original file so that we can make sure it is - # not touched. - origcontents = "This is the original text\n" - File.chmod(0644, @targetfile) - File.open(@targetfile, 'w') do |file| - file.write(origcontents) - end - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain group="testgroup">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was not modified - assert_equal(origcontents, get_file_contents(@targetfile), testname) - - # - # Negate the simple group name comparison with the node in 0 groups - # - testname = 'negate node group comparison, 0 groups' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain group="!testgroup">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was created properly - assert_equal(sourcecontents, get_file_contents(@targetfile), testname) - - # - # Put the node in one group for the next series of tests - # - hostname = `facter fqdn`.chomp - File.open(File.join(@repodir, 'nodes.xml'), 'w') do |file| - file.puts <<-EOF - <nodes> - <node name="#{hostname}"> - <group>testgroup</group> - </node> - </nodes> - EOF - end - - # - # Simple group name comparison with the node in 1 group - # - testname = 'node group comparison, 1 group' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain group="testgroup">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was created properly - assert_equal(sourcecontents, get_file_contents(@targetfile), testname) - - # - # Negate the simple group name comparison with the node in 1 group - # - testname = 'negate node group comparison, 1 group' - - # Put some text into the original file so that we can make sure it is - # not touched. - origcontents = "This is the original text\n" - File.chmod(0644, @targetfile) - File.open(@targetfile, 'w') do |file| - file.write(origcontents) - end - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain group="!testgroup">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was not modified - assert_equal(origcontents, get_file_contents(@targetfile), testname) - - # - # Regex group name comparison with the node in 1 group - # - testname = 'regex node group comparison, 1 group' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain group="/test/">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was created properly - assert_equal(sourcecontents, get_file_contents(@targetfile), testname) - - # - # Put the node in two groups for the next series of tests - # - hostname = `facter fqdn`.chomp - File.open(File.join(@repodir, 'nodes.xml'), 'w') do |file| - file.puts <<-EOF - <nodes> - <node name="#{hostname}"> - <group>testgroup</group> - <group>second</group> - </node> - </nodes> - EOF - end - - # - # Simple group name comparison with the node in 2 groups - # - testname = 'node group comparison, 2 groups' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain group="testgroup">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was created properly - assert_equal(sourcecontents, get_file_contents(@targetfile), testname) - - # - # Negate the simple group name comparison with the node in 2 groups - # - testname = 'negate node group comparison, 2 groups' - - # Put some text into the original file so that we can make sure it is - # not touched. - origcontents = "This is the original text\n" - File.chmod(0644, @targetfile) - File.open(@targetfile, 'w') do |file| - file.write(origcontents) - end - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain group="!testgroup">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was not modified - assert_equal(origcontents, get_file_contents(@targetfile), testname) - - # - # Regex group name comparison with the node in 2 groups - # - testname = 'regex node group comparison, 2 groups' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain group="/test/">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was created properly - assert_equal(sourcecontents, get_file_contents(@targetfile), testname) - end - - def test_fact_attributes - Facter.loadfacts - os = Facter['operatingsystem'].value - # Facter frequently leaves extraneous whitespace on this fact, thus - # the strip - osrel = Facter['operatingsystemrelease'].value.strip - - # - # Simple fact comparison - # - testname = 'fact comparison' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain operatingsystem="#{os}">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was created properly - assert_equal(sourcecontents, get_file_contents(@targetfile), testname) - - # - # Negate fact comparison - # - testname = 'negate fact comparison' - - # Put some text into the original file so that we can make sure it is - # not touched. - origcontents = "This is the original text\n" - File.chmod(0644, @targetfile) - File.open(@targetfile, 'w') do |file| - file.write(origcontents) - end - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain operatingsystem="!#{os}">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was not modified - assert_equal(origcontents, get_file_contents(@targetfile), testname) - - # - # Regex fact comparison - # - testname = 'regex fact comparison' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain operatingsystem="/#{os[0,2]}/">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was created properly - assert_equal(sourcecontents, get_file_contents(@targetfile), testname) - - # - # Negate regex fact comparison - # - testname = 'negate regex fact comparison' - - # Put some text into the original file so that we can make sure it is - # not touched. - origcontents = "This is the original text\n" - File.chmod(0644, @targetfile) - File.open(@targetfile, 'w') do |file| - file.write(origcontents) - end - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain operatingsystem="!/#{os[0,2]}/">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was not modified - assert_equal(origcontents, get_file_contents(@targetfile), testname) - - # - # Version fact operator comparison - # - testname = 'version fact operator comparison' - - # Try to make up a subset of operatingsystemrelease so that we really - # test the operator functionality and not just equality. I.e. if osrel - # is 2.5.1 we'd like to extract 2.5 - osrelsubset = osrel - osrelparts = osrel.split('.') - if osrelparts.length > 1 - osrelparts.pop - osrelsubset = osrelparts.join('.') - end - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain operatingsystemrelease=">=#{osrelsubset}">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was created properly - assert_equal(sourcecontents, get_file_contents(@targetfile), testname) - - # - # Negate version fact operator comparison - # - testname = 'negate fact comparison' - - # Put some text into the original file so that we can make sure it is - # not touched. - origcontents = "This is the original text\n" - File.chmod(0644, @targetfile) - File.open(@targetfile, 'w') do |file| - file.write(origcontents) - end - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain operatingsystemrelease="!>=#{osrel}">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was not modified - assert_equal(origcontents, get_file_contents(@targetfile), testname) - - # - # Version fact operator comparison requiring XML escape - # The XML spec says that < and & must be escaped almost anywhere - # outside of their use as markup. That includes inside attribute values. - # http://www.w3.org/TR/2006/REC-xml-20060816/#syntax - # So if the user wants to use the < or <= operators they must escape - # the < with < - # - testname = 'version fact operator comparison requiring XML escape' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain operatingsystemrelease="<=#{osrel}">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was created properly - assert_equal(sourcecontents, get_file_contents(@targetfile), testname) - - # - # Multiple fact comparison - # - testname = 'multiple fact comparison' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain operatingsystem="#{os}" operatingsystemrelease="#{osrel}">source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was created properly - assert_equal(sourcecontents, get_file_contents(@targetfile), testname) - - end - - def teardown - remove_repository(@repodir) - FileUtils.rm_rf(@testbase) - FileUtils.rm_rf(@targetfile) - end -end - Deleted: trunk/test/auth.rb =================================================================== --- trunk/test/auth.rb 2010-01-20 22:43:55 UTC (rev 191) +++ trunk/test/auth.rb 2010-01-20 23:05:05 UTC (rev 192) @@ -1,258 +0,0 @@ -#!/usr/bin/ruby -w - -# -# Test etch's handling of client authentication -# - -require File.join(File.dirname(__FILE__), 'etchtest') -require 'net/http' -require 'rexml/document' -require 'facter' - -class EtchAuthTests < Test::Unit::TestCase - include EtchTests - - def setup - # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path - #puts "Using #{@targetfile} as target file" - - # Generate a directory for our test repository - @repodir = initialize_repository - # These tests set an etchserver.conf. The server only reads that file - # once and caches the settings, so we need to start up new server - # instances for these tests rather than reusing the global test server. - @server = start_server(@repodir) - - # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" - - # Make sure the server will initially think this is a new client - hostname = Facter['fqdn'].value - Net::HTTP.start('localhost', @server[:port]) do |http| - # Find our client id - response = http.get("/clients.xml?name=#{hostname}") - if !response.kind_of?(Net::HTTPSuccess) - response.error! - end - response_xml = REXML::Document.new(response.body) - client_id = nil - if response_xml.elements['/clients/client/id'] - client_id = response_xml.elements['/clients/client/id'].text - end - # Delete our client entry - if client_id - response = http.delete("/clients/#{client_id}.xml") - if !response.kind_of?(Net::HTTPSuccess) - response.error! - end - end - end - end - - # Test authentication when new clients are allowed - def test_auth_allow_new_clients - File.open(File.join(@repodir, 'etchserver.conf'), 'w') do |file| - file.puts 'auth_enabled=true' - file.puts 'auth_deny_new_clients=false' - end - - # - # New client, should work - # - testname = 'auth, allow new clients, new client' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain>source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was created properly - assert_equal(sourcecontents, get_file_contents(@targetfile), testname) - - # - # Existing client, should work - # - testname = 'auth, allow new clients, existing client' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain>source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was created properly - assert_equal(sourcecontents, get_file_contents(@targetfile), testname) - - # - # Existing client, bad signature, should be denied - # - testname = 'auth, allow new clients, existing client, bad signature' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain>source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Put some text into the original file so that we can make sure it - # is not touched. - origcontents = "This is the original text\n" - File.delete(@targetfile) - File.open(@targetfile, 'w') do |file| - file.write(origcontents) - end - - # Run etch with the wrong key to force a bad signature - #puts "Running '#{testname}' test" - run_etch(@server, @testbase, true, "--key=#{File.join(File.dirname(__FILE__), 'keys', 'testkey2')}") - - # Verify that the file was not touched - assert_equal(origcontents, get_file_contents(@targetfile), testname) - end - # Test authentication when new clients are denied - def test_auth_deny_new_clients - File.open(File.join(@repodir, 'etchserver.conf'), 'w') do |file| - file.puts 'auth_enabled=true' - file.puts 'auth_deny_new_clients=true' - end - - # - # New client, should fail - # - testname = 'auth, deny new clients, new client' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain>source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Put some text into the original file so that we can make sure it - # is not touched. - origcontents = "This is the original text\n" - File.open(@targetfile, 'w') do |file| - file.write(origcontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase, true) - - # Verify that the file was not touched - assert_equal(origcontents, get_file_contents(@targetfile), testname) - - # - # Add this client to the server so that it will now be considered - # an existing client - # - puts "# Starting a second copy of the server and adding this client to the database" - sleep 3 - repodir2 = initialize_repository - server2 = start_server(repodir2) - run_etch(server2, @testbase) - stop_server(server2) - remove_repository(repodir2) - - # - # Existing client, should work - # - testname = 'auth, deny new clients, existing client' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain>source</plain> - </source> - </file> - </config> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was created properly - assert_equal(sourcecontents, get_file_contents(@targetfile), testname) - end - - def teardown - stop_server(@server) - remove_repository(@repodir) - FileUtils.rm_rf(@testbase) - FileUtils.rm_rf(@targetfile) - end -end - Deleted: trunk/test/commands.rb =================================================================== --- trunk/test/commands.rb 2010-01-20 22:43:55 UTC (rev 191) +++ trunk/test/commands.rb 2010-01-20 23:05:05 UTC (rev 192) @@ -1,375 +0,0 @@ -#!/usr/bin/ruby -w - -# -# Test etch's handling of configuration commands -# - -require File.join(File.dirname(__FILE__), 'etchtest') - -class EtchCommandTests < Test::Unit::TestCase - include EtchTests - - def setup - # Generate a file to use as a target in commands - @targetfile = Tempfile.new('etchtest').path - #puts "Using #{@targetfile} as target file" - - # Generate a directory for our test repository - @repodir = initialize_repository - @server = get_server(@repodir) - - # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" - end - - def test_commands_basic - # - # Guard initially fails, command fixes it - # - testname = 'guard initially fails, command fixes it' - - FileUtils.mkdir_p("#{@repodir}/commands/etchtest") - File.open("#{@repodir}/commands/etchtest/commands.xml", 'w') do |file| - file.puts <<-EOF - <commands> - <step> - <guard> - <exec>grep '#{testname}' #{@targetfile}</exec> - </guard> - <command> - <exec>printf '#{testname}' >> #{@targetfile}</exec> - </command> - </step> - </commands> - EOF - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was created properly - assert_equal(testname, get_file_contents(@targetfile), testname) - end - - def test_commands_failure - # - # Guard initially fails, command doesn't fix it - # - testname = 'guard initially fails, command doesnt fix it' - - FileUtils.mkdir_p("#{@repodir}/commands/etchtest") - File.open("#{@repodir}/commands/etchtest/commands.xml", 'w') do |file| - file.puts <<-EOF - <commands> - <step> - <guard> - <exec>grep '#{testname}' #{@targetfile}</exec> - </guard> - <command> - <exec>echo '#{testname}'</exec> - </command> - </step> - </commands> - EOF - end - - # Run etch - # The assertion here is handled by run_etch as we're passing it an - # argument indicating that we expect failure. - #puts "Running '#{testname}' test" - run_etch(@server, @testbase, true) - end - - def test_commands_guard_succeeds - # - # Guard initially succeeds - # - testname = 'guard initially succeeds' - - FileUtils.mkdir_p("#{@repodir}/commands/etchtest") - File.open("#{@repodir}/commands/etchtest/commands.xml", 'w') do |file| - file.puts <<-EOF - <commands> - <step> - <guard> - <exec>grep '#{testname}' #{@targetfile}</exec> - </guard> - <command> - <exec>echo failure >> #{@targetfile}</exec> - </command> - </step> - </commands> - EOF - end - - File.open(@targetfile, 'w') { |file| file.print(testname) } - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was not touched - assert_equal(testname, get_file_contents(@targetfile), testname) - end - - def test_commands_multiple_steps - # - # Multiple steps - # - testname = 'multiple steps' - - FileUtils.mkdir_p("#{@repodir}/commands/etchtest") - File.open("#{@repodir}/commands/etchtest/commands.xml", 'w') do |file| - file.puts <<-EOF - <commands> - <step> - <guard> - <exec>grep firststep #{@targetfile}</exec> - </guard> - <command> - <exec>echo firststep >> #{@targetfile}</exec> - </command> - </step> - <step> - <guard> - <exec>grep secondstep #{@targetfile}</exec> - </guard> - <command> - <exec>echo secondstep >> #{@targetfile}</exec> - </command> - </step> - </commands> - EOF - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that both steps ran and in the proper order - assert_equal("firststep\nsecondstep\n", get_file_contents(@targetfile), testname) - end - - def test_commands_multiple_commands - # - # Multiple commands - # - testname = 'multiple commands' - - FileUtils.mkdir_p("#{@repodir}/commands/etchtest") - File.open("#{@repodir}/commands/etchtest/commands.xml", 'w') do |file| - file.puts <<-EOF - <commands> - <step> - <guard> - <exec>grep firstcmd #{@targetfile}</exec> - </guard> - <command> - <exec>echo firstcmd >> #{@targetfile}</exec> - </command> - </step> - </commands> - EOF - end - FileUtils.mkdir_p("#{@repodir}/commands/etchtest2") - File.open("#{@repodir}/commands/etchtest2/commands.xml", 'w') do |file| - file.puts <<-EOF - <commands> - <step> - <guard> - <exec>grep secondcmd #{@targetfile}</exec> - </guard> - <command> - <exec>echo secondcmd >> #{@targetfile}</exec> - </command> - </step> - </commands> - EOF - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that both commands ran, ordering doesn't matter - assert_equal(['firstcmd', 'secondcmd'], get_file_contents(@targetfile).split("\n").sort, testname) - end - - def test_commands_depend - # - # Multiple commands with dependency - # - testname = 'multiple commands with dependency' - - FileUtils.mkdir_p("#{@repodir}/commands/etchtest") - File.open("#{@repodir}/commands/etchtest/commands.xml", 'w') do |file| - file.puts <<-EOF - <commands> - <step> - <guard> - <exec>grep firstcmd #{@targetfile}</exec> - </guard> - <command> - <exec>echo firstcmd >> #{@targetfile}</exec> - </command> - </step> - </commands> - EOF - end - FileUtils.mkdir_p("#{@repodir}/commands/etchtest2") - File.open("#{@repodir}/commands/etchtest2/commands.xml", 'w') do |file| - file.puts <<-EOF - <commands> - <depend>etchtest</depend> - <step> - <guard> - <exec>grep secondcmd #{@targetfile}</exec> - </guard> - <command> - <exec>echo secondcmd >> #{@targetfile}</exec> - </command> - </step> - </commands> - EOF - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that both commands ran and in the proper order - assert_equal("firstcmd\nsecondcmd\n", get_file_contents(@targetfile), testname) - end - - def test_commands_dependfile - # - # Command with dependency on a file - # - testname = 'command with file dependency' - - targetfile2 = Tempfile.new('etchtest').path - FileUtils.mkdir_p("#{@repodir}/source/#{targetfile2}") - File.open("#{@repodir}/source/#{targetfile2}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <file> - <warning_file/> - <source> - <plain>source</plain> - </source> - </file> - <post> - <exec>sleep 3</exec> - </post> - </config> - EOF - end - - FileUtils.mkdir_p("#{@repodir}/commands/etchtest") - File.open("#{@repodir}/commands/etchtest/commands.xml", 'w') do |file| - file.puts <<-EOF - <commands> - <dependfile>#{targetfile2}</dependfile> - <step> - <guard> - <exec>grep '#{testname}' #{@targetfile}</exec> - </guard> - <command> - <exec>printf '#{testname}' >> #{@targetfile}</exec> - </command> - </step> - </commands> - EOF - end - - sourcecontents = "Test #{testname}\n" - File.open("#{@repodir}/source/#{targetfile2}/source", 'w') do |file| - file.write(sourcecontents) - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the command-generated file and the regular file were created - # properly - assert_equal(testname, get_file_contents(@targetfile), testname + ' command contents') - assert_equal(sourcecontents, get_file_contents(targetfile2), testname + ' file contents') - # And verify that they were created in the right order - assert(File.stat(@targetfile).mtime > File.stat(targetfile2).mtime, testname + ' ordering') - end - - def test_commands_filtering - # - # Attribute filtering - # Filtering of commands.xml uses the same methods as are used for the - # filtering of config.xml, which is heavily tested. So we just do a - # simple test to make sure that it basically works. - # - testname = 'command attribute filtering' - - FileUtils.mkdir_p("#{@repodir}/commands/etchtest") - File.open("#{@repodir}/commands/etchtest/commands.xml", 'w') do |file| - file.puts <<-EOF - <commands> - <step group="!testgroup"> - <guard> - <exec>grep notingroup #{@targetfile}</exec> - </guard> - <command> - <exec>echo notingroup >> #{@targetfile}</exec> - </command> - </step> - <step group="testgroup"> - <guard> - <exec>grep yesingroup #{@targetfile}</exec> - </guard> - <command> - <exec>echo yesingroup >> #{@targetfile}</exec> - </command> - </step> - </commands> - EOF - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that only the desired step executed - assert_equal("notingroup\n", get_file_contents(@targetfile), testname) - end - - def test_commands_dtd_failure - # - # commands.xml doesn't match DTD - # - testname = 'command DTD failure' - - FileUtils.mkdir_p("#{@repodir}/commands/etchtest") - File.open("#{@repodir}/commands/etchtest/commands.xml", 'w') do |file| - file.puts <<-EOF - <commands> - <step> - <bogus/> - </step> - </commands> - EOF - end - - # Run etch - # The assertion here is handled by run_etch as we're passing it an - # argument indicating that we expect failure. - #puts "Running '#{testname}' test" - run_etch(@server, @testbase, true) - end - - def teardown - remove_repository(@repodir) - FileUtils.rm_rf(@testbase) - FileUtils.rm_rf(@targetfile) - end -end - Deleted: trunk/test/delete.rb =================================================================== --- trunk/test/delete.rb 2010-01-20 22:43:55 UTC (rev 191) +++ trunk/test/delete.rb 2010-01-20 23:05:05 UTC (rev 192) @@ -1,237 +0,0 @@ -#!/usr/bin/ruby -w - -# -# Test etch's handling of deleting files -# - -require File.join(File.dirname(__FILE__), 'etchtest') - -class EtchDeleteTests < Test::Unit::TestCase - include EtchTests - - def setup - # Generate a file to use as our etch target/destination - @targetfile = Tempfile.new('etchtest').path - #puts "Using #{@targetfile} as target file" - - # Generate a directory for our test repository - @repodir = initialize_repository - @server = get_server(@repodir) - - # Create a directory to use as a working directory for the client - @testbase = tempdir - #puts "Using #{@testbase} as client working directory" - - # Generate another file to use as our link target - @destfile = Tempfile.new('etchtest').path - #puts "Using #{@destfile} as link destination file" - end - - def test_delete - - # - # Delete a file - # - testname = 'delete file' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <delete> - <proceed/> - </delete> - </config> - EOF - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the file was deleted - assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), testname) - - # - # Delete a link - # - testname = 'delete link' - - # Create the link - File.symlink(@destfile, @targetfile) - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <delete> - <proceed/> - </delete> - </config> - EOF - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the link was deleted - assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), testname) - - # - # Delete a directory - # - testname = 'delete directory w/o overwrite_directory' - - # Create the directory with a file inside just to make sure the - # delete handles that properly - Dir.mkdir(@targetfile) if (!File.directory?(@targetfile)) - File.open("#{@targetfile}/testfile", 'w') { |file| } - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <delete> - <proceed/> - </delete> - </config> - EOF - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase, true) - - # Verify that the directory was not deleted - assert(File.directory?(@targetfile), testname) - - # - # Delete a directory w/ overwrite_directory - # - testname = 'delete directory w/ overwrite_directory' - - # Create the directory with a file inside just to make sure the - # delete handles that properly - Dir.mkdir(@targetfile) if (!File.directory?(@targetfile)) - File.open("#{@targetfile}/testfile", 'w') { |file| } - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <delete> - <overwrite_directory/> - <proceed/> - </delete> - </config> - EOF - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that the directory was deleted - assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), testname) - - # - # Delete a non-existent file - # - testname = 'delete non-existent file' - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <delete> - <proceed/> - </delete> - </config> - EOF - end - - # Run etch - #puts "Running '#{testname}' test" - run_etch(@server, @testbase) - - # Verify that we still don't have a file. That's rather unlikely, - # this is really more a test that etch doesn't throw an error if - # told to delete something that doesn't exist, which is captured by - # the assert within run_etch. - assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), testname) - - # - # Test duplicate script instructions - # - - FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") - File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| - file.puts <<-EOF - <config> - <delete> - <script>source</script> - <script>source</script> - </delete> - </config> - EOF - end - - File.open(@targetfile, 'w') do |file| - file.puts('Original contents') - end - - File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| - file.puts("@contents << 'true'") - end - - # Run etch - #puts "Running duplicate script instructions test" - run_et... [truncated message content] |
From: <jh...@us...> - 2010-01-20 22:44:03
|
Revision: 191 http://etch.svn.sourceforge.net/etch/?rev=191&view=rev Author: jheiss Date: 2010-01-20 22:43:55 +0000 (Wed, 20 Jan 2010) Log Message: ----------- Remove dependency on RCS now that history logs are stored as individual files. Modified Paths: -------------- trunk/client/control trunk/client/depend trunk/client/etch-client.spec trunk/client/etch.spec Modified: trunk/client/control =================================================================== --- trunk/client/control 2010-01-20 22:41:41 UTC (rev 190) +++ trunk/client/control 2010-01-20 22:43:55 UTC (rev 191) @@ -2,6 +2,6 @@ Version: %VER%-1 Maintainer: etc...@li... Architecture: all -Depends: ruby facter rcs +Depends: ruby facter Description: Etch client Modified: trunk/client/depend =================================================================== --- trunk/client/depend 2010-01-20 22:41:41 UTC (rev 190) +++ trunk/client/depend 2010-01-20 22:43:55 UTC (rev 191) @@ -1,4 +1,3 @@ P CSWruby P CSWfacter -P CSWrcs Modified: trunk/client/etch-client.spec =================================================================== --- trunk/client/etch-client.spec 2010-01-20 22:41:41 UTC (rev 190) +++ trunk/client/etch-client.spec 2010-01-20 22:43:55 UTC (rev 191) @@ -5,7 +5,7 @@ Group: Applications/System License: MIT buildarch: noarch -Requires: ruby, facter, rcs, crontabs +Requires: ruby, facter, crontabs BuildRoot: %{_builddir}/%{name}-buildroot %description Etch client Modified: trunk/client/etch.spec =================================================================== --- trunk/client/etch.spec 2010-01-20 22:41:41 UTC (rev 190) +++ trunk/client/etch.spec 2010-01-20 22:43:55 UTC (rev 191) @@ -10,7 +10,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: rubygem-rake -Requires: ruby(abi) = 1.8, facter, rcs +Requires: ruby(abi) = 1.8, facter # Per http://fedoraproject.org/wiki/Packaging:Ruby %{!?ruby_sitelib: %global ruby_sitelib %(ruby -rrbconfig -e 'puts Config::CONFIG["sitelibdir"] ')} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2010-01-20 22:41:54
|
Revision: 190 http://etch.svn.sourceforge.net/etch/?rev=190&view=rev Author: jheiss Date: 2010-01-20 22:41:41 +0000 (Wed, 20 Jan 2010) Log Message: ----------- Store history logs as individual files rather than in RCS. RCS results in a very cumbersome UI for viewing the history logs, making it unlikely they'll be used. Individual files allows for easy viewing and inspection using standard Unix tools like ls, diff, grep, etc. History logs in the old RCS format are converted automatically to the new format. Add any exception message to the message that is reported to the etch server. Otherwise we just report a non-zero status with no message, which is difficult to debug. We were printing the exception message to stderr, but most users run etch in a cron job that sends stderr to /dev/null. Update the history log after performing a revert so that we capture that activity. Perform another bit of code cleanup in the revert action. Add nonrecursive_copy and nonrecursive_copy_and_rename methods to complement the recursive versions we had already. Modified Paths: -------------- trunk/client/etchclient.rb trunk/test/history.rb Modified: trunk/client/etchclient.rb =================================================================== --- trunk/client/etchclient.rb 2010-01-20 22:30:45 UTC (rev 189) +++ trunk/client/etchclient.rb 2010-01-20 22:41:41 UTC (rev 190) @@ -403,7 +403,9 @@ rescue Exception => e status = 1 $stderr.puts e.message + message << e.message $stderr.puts e.backtrace.join("\n") if @debug + message << e.backtrace.join("\n") if @debug end # begin/rescue end # catch @@ -540,8 +542,10 @@ # original file. if config.elements['/config/revert'] origpathbase = File.join(@origbase, file) + origpath = nil # Restore the original file if it is around + revert_occurred = false if File.exist?("#{origpathbase}.ORIG") origpath = "#{origpathbase}.ORIG" origdir = File.dirname(origpath) @@ -553,10 +557,7 @@ puts "Restoring #{origpath} to #{file}" recursive_copy_and_rename(origdir, origbase, file) if (!@dryrun) - - # Now remove the backed-up original so that future runs - # don't do anything - remove_file(origpath) if (!@dryrun) + revert_occurred = true elsif File.exist?("#{origpathbase}.TAR") origpath = "#{origpathbase}.TAR" filedir = File.dirname(file) @@ -566,19 +567,24 @@ puts "Restoring #{file} from #{origpath}" system("cd #{filedir} && tar xf #{origpath}") if (!@dryrun) - - # Now remove the backed-up original so that future runs - # don't do anything - remove_file(origpath) if (!@dryrun) + revert_occurred = true elsif File.exist?("#{origpathbase}.NOORIG") origpath = "#{origpathbase}.NOORIG" puts "Original #{file} didn't exist, restoring that state" # Remove anything we might have written out for this file remove_file(file) if (!@dryrun) + revert_occurred = true + end - # Now remove the backed-up original so that future runs - # don't do anything + # Update the history log + if revert_occurred + save_history(file) + end + + # Now remove the backed-up original so that future runs + # don't do anything + if origpath remove_file(origpath) if (!@dryrun) end @@ -1696,109 +1702,110 @@ origpath end - + # This subroutine maintains a revision history for the file in @historybase def save_history(file) - histpath = File.join(@historybase, "#{file}.HISTORY") + histdir = File.join(@historybase, "#{file}.HISTORY") + current = File.join(histdir, 'current') + + # Migrate old RCS history + if File.file?(histdir) && File.directory?(File.join(File.dirname(histdir), 'RCS')) + if !@dryrun + puts "Migrating old RCS history to new format" + rcsmax = nil + IO.popen("rlog #{histdir}") do |pipe| + pipe.each do |line| + if line =~ /^head: 1.(.*)/ + rcsmax = $1.to_i + break + end + end + end + if !rcsmax + raise "Failed to parse RCS history rlog output" + end + tmphistdir = tempdir(histdir) + 1.upto(rcsmax) do |rcsrev| + rcsrevcontents = `co -q -p1.#{rcsrev} #{histdir}` + # rcsrev-1 because RCS starts revisions at 1.1 and we start files + # at 0000 + File.open(File.join(tmphistdir, sprintf('%04d', rcsrev-1)), 'w') do |rcsrevfile| + rcsrevfile.write(rcsrevcontents) + end + end + FileUtils.copy(histdir, File.join(tmphistdir, 'current')) + File.delete(histdir) + File.rename(tmphistdir, histdir) + end + end # Make sure the directory tree for this file exists in the # directory we save history in. - histdir = File.dirname(histpath) - if !File.directory?(histdir) - puts "Making directory tree #{histdir}" + if !File.exist?(histdir) + puts "Making history directory #{histdir}" FileUtils.mkpath(histdir) if (!@dryrun) end - # Make sure the corresponding RCS directory exists as well. - histrcsdir = File.join(histdir, 'RCS') - if !File.directory?(histrcsdir) - puts "Making directory tree #{histrcsdir}" - FileUtils.mkpath(histrcsdir) if (!@dryrun) - end - - # If the history log doesn't exist and we didn't just create the - # original backup, that indicates that the original backup was made - # previously but the history log was not started at the same time. - # There are a variety of reasons why this might be the case (the - # original was saved by a previous version of etch that didn't have - # the history log feature, or the original was saved manually by - # someone) but whatever the reason is we want to use the original - # backup to start the history log before updating the history log - # with the current file. - if !File.exist?(histpath) && !@first_update[file] + + # If the history log doesn't exist and we didn't just create the original + # backup then that indicates that the original backup was made previously + # but the history log was not started at the same time. There are a + # variety of reasons why this might be the case (the most likely is that + # the original was saved manually by someone) but whatever the reason is + # we want to use the original backup to start the history log before + # updating the history log with the current file. + if !File.exist?(File.join(histdir, 'current')) && !@first_update[file] origpath = save_orig(file) if File.file?(origpath) && !File.symlink?(origpath) puts "Starting history log with saved original file: " + - "#{origpath} -> #{histpath}" - FileUtils.copy(origpath, histpath) if (!@dryrun) + "#{origpath} -> #{current}" + FileUtils.copy(origpath, current) if (!@dryrun) else puts "Starting history log with 'ls -ld' output for " + - "saved original file: #{origpath} -> #{histpath}" - system("ls -ld #{origpath} > #{histpath} 2>&1") if (!@dryrun) + "saved original file: #{origpath} -> #{current}" + system("ls -ld #{origpath} > #{current} 2>&1") if (!@dryrun) end - # Check the newly created history file into RCS - histbase = File.basename(histpath) - puts "Checking initial history log into RCS: #{histpath}" - if !@dryrun - # The -m flag shouldn't be needed, but it won't hurt - # anything and if something is out of sync and an RCS file - # already exists it will prevent ci from going interactive. - system( - "cd #{histdir} && " + - "ci -q -t-'Original of an etch modified file' " + - "-m'Update of an etch modified file' #{histbase} && " + - "co -q -r -kb #{histbase}") - end set_history_permissions(file) end - - # Copy current file - - # If the file already exists in RCS we need to check out a locked - # copy before updating it - histbase = File.basename(histpath) - rcsstatus = false - if !@dryrun - rcsstatus = system("cd #{histdir} && rlog -R #{histbase} > /dev/null 2>&1") - end - if rcsstatus - # set_history_permissions may set the checked-out file - # writeable, which normally causes co to abort. Thus the -f - # flag. - system("cd #{histdir} && co -q -l -f #{histbase}") if !@dryrun - end - + + # Make temporary copy of file + newcurrent = current+'.new' if File.file?(file) && !File.symlink?(file) - puts "Updating history log: #{file} -> #{histpath}" - FileUtils.copy(file, histpath) if (!@dryrun) + puts "Updating history log: #{file} -> #{current}" + remove_file(newcurrent) + FileUtils.copy(file, newcurrent) if (!@dryrun) else - puts "Updating history log with 'ls -ld' output: " + - "#{histpath}" - system("ls -ld #{file} > #{histpath} 2>&1") if (!@dryrun) + puts "Updating history log with 'ls -ld' output: #{file} -> #{current}" + system("ls -ld #{file} > #{newcurrent} 2>&1") if (!@dryrun) end - - # Check the history file into RCS - puts "Checking history log update into RCS: #{histpath}" - if !@dryrun - # We only need one of the -t or -m flags depending on whether - # the history log already exists or not, rather than try to - # keep track of which one we need just specify both and let RCS - # pick the one it needs. - system( - "cd #{histdir} && " + - "ci -q -t-'Original of an etch modified file' " + - "-m'Update of an etch modified file' #{histbase} && " + - "co -q -r -kb #{histbase}") + + # Roll current to next XXXX if current != XXXX + if File.exist?(current) + nextfile = '0000' + maxfile = Dir.entries(histdir).select{|e|e=~/^\d+/}.max + if maxfile + if compare_file_contents(File.join(histdir, maxfile), File.read(current)) + nextfile = nil + else + nextfile = sprintf('%04d', maxfile.to_i + 1) + end + end + if nextfile + File.rename(current, File.join(histdir, nextfile)) if (!@dryrun) + end end - + + # Move temporary copy to current + File.rename(current+'.new', current) if (!@dryrun) + set_history_permissions(file) end - + # Ensures that the history log file has appropriate permissions to avoid # leaking information. def set_history_permissions(file) origpath = File.join(@origbase, "#{file}.ORIG") - histpath = File.join(@historybase, "#{file}.HISTORY") - + histdir = File.join(@historybase, "#{file}.HISTORY") + # We set the permissions to the more restrictive of the original # file permissions and the current file permissions. origperms = 0777 @@ -1813,17 +1820,15 @@ # Mask off the file type fileperms = st.mode & 07777 end - histperms = origperms & fileperms - - File.chmod(histperms, histpath) if (!@dryrun) - - # Set the permissions on the RCS file too - histbase = File.basename(histpath) - histdir = File.dirname(histpath) - histrcsdir = "#{histdir}/RCS" - histrcspath = "#{histrcsdir}/#{histbase},v" - File.chmod(histperms, histrcspath) if (!@dryrun) + + if File.directory?(histdir) + Dir.foreach(histdir) do |histfile| + next if histfile == '.' + next if histfile == '..' + File.chmod(histperms, File.join(histdir, histfile)) if (!@dryrun) + end + end end def get_local_requests(file) @@ -2202,8 +2207,10 @@ # Note that cp -p will follow symlinks. GNU cp has a -d option to # prevent that, but Solaris cp does not, so we resort to cpio. # GNU cpio has a --quiet option, but Solaris cpio does not. Sigh. + # GNU find and cpio also have -print0/--null to handle filenames with + # spaces or special characters, but that's not standard either. system("cd #{sourcedir} && find #{sourcefile} | cpio -pdum #{destdir}") or - raise "Copy #{sourcedir}/#{sourcefile} to #{destdir} failed" + raise "Recursive copy #{sourcedir}/#{sourcefile} to #{destdir} failed" end def recursive_copy_and_rename(sourcedir, sourcefile, destname) tmpdir = tempdir(destname) @@ -2211,7 +2218,17 @@ File.rename(File.join(tmpdir, sourcefile), destname) Dir.delete(tmpdir) end - + def nonrecursive_copy(sourcedir, sourcefile, destdir) + system("cd #{sourcedir} && echo #{sourcefile} | cpio -pdum #{destdir}") or + raise "Non-recursive copy #{sourcedir}/#{sourcefile} to #{destdir} failed" + end + def nonrecursive_copy_and_rename(sourcedir, sourcefile, destname) + tmpdir = tempdir(destname) + nonrecursive_copy(sourcedir, sourcefile, tmpdir) + File.rename(File.join(tmpdir, sourcefile), destname) + Dir.delete(tmpdir) + end + def lock_file(file) lockpath = File.join(@lockbase, "#{file}.LOCK") Modified: trunk/test/history.rb =================================================================== --- trunk/test/history.rb 2010-01-20 22:30:45 UTC (rev 189) +++ trunk/test/history.rb 2010-01-20 22:41:41 UTC (rev 190) @@ -22,6 +22,9 @@ # Create a directory to use as a working directory for the client @testbase = tempdir #puts "Using #{@testbase} as client working directory" + + @origfile = File.join(@testbase, 'orig', "#{@targetfile}.ORIG") + @historydir = File.join(@testbase, 'history', "#{@targetfile}.HISTORY") end def test_history @@ -29,10 +32,6 @@ # Ensure original file is backed up and history log started # - origfile = File.join(@testbase, 'orig', "#{@targetfile}.ORIG") - historyfile = File.join(@testbase, 'history', "#{@targetfile}.HISTORY") - historydir = File.dirname(historyfile) - # Put some text into the original file so that we can make sure it was # properly backed up. origcontents = "This is the original text\n" @@ -63,15 +62,9 @@ #puts "Running initial history test" run_etch(@server, @testbase) - assert_equal(origcontents, get_file_contents(origfile), 'original backup of file') - system("cd #{historydir} && co -q -f -r1.1 #{historyfile}") - #system("ls -l #{historyfile}") - assert_equal(origcontents, get_file_contents(historyfile), 'history log started in rcs') - system("cd #{historydir} && co -q -f #{historyfile}") - #system("ls -l #{historyfile}") - assert_equal(sourcecontents, get_file_contents(historyfile), 'history log of file started and updated') - rcsexit = system("cd #{historydir} && rlog -h #{historyfile} | grep '^head: 1.2'") - assert(rcsexit, 'history log started and updated in rcs') + assert_equal(origcontents, get_file_contents(@origfile), 'original backup of file') + assert_equal(origcontents, get_file_contents(File.join(@historydir, '0000')), '0000 history file') + assert_equal(sourcecontents, get_file_contents(File.join(@historydir, 'current')), 'current history file') # # Ensure history log is updated and original file does not change @@ -86,10 +79,10 @@ #puts "Running update test" run_etch(@server, @testbase) - assert_equal(origcontents, get_file_contents(origfile), 'original backup of file unchanged') - assert_equal(updatedsourcecontents, get_file_contents(historyfile), 'history log of file updated') - rcsexit = system("cd #{historydir} && rlog -h #{historyfile} | grep '^head: 1.3'") - assert(rcsexit, 'history log updated in rcs') + assert_equal(origcontents, get_file_contents(@origfile), 'original backup of file unchanged') + assert_equal(origcontents, get_file_contents(File.join(@historydir, '0000')), '0000 history file') + assert_equal(sourcecontents, get_file_contents(File.join(@historydir, '0001')), '0001 history file') + assert_equal(updatedsourcecontents, get_file_contents(File.join(@historydir, 'current')), 'updated current history file') # # Test revert feature @@ -117,6 +110,11 @@ run_etch(@server, @testbase) assert_equal(origcontents, get_file_contents(@targetfile), 'original contents reverted') + assert(!File.exist?(@origfile), 'reverted original file') + assert_equal(origcontents, get_file_contents(File.join(@historydir, '0000')), '0000 history file') + assert_equal(sourcecontents, get_file_contents(File.join(@historydir, '0001')), '0001 history file') + assert_equal(updatedsourcecontents, get_file_contents(File.join(@historydir, '0002')), '0002 history file') + assert_equal(origcontents, get_file_contents(File.join(@historydir, 'current')), 'reverted current history file') # # Update the contents of a reverted file and make sure etch doesn't @@ -133,6 +131,8 @@ run_etch(@server, @testbase) assert_equal(updatedorigcontents, get_file_contents(@targetfile), 'Updated original contents unchanged') + assert(!File.exist?(@origfile), 'reverted original file') + assert_equal(origcontents, get_file_contents(File.join(@historydir, 'current')), 'Updated reverted current history file') end def test_history_setup @@ -150,7 +150,6 @@ # original contents. # - origfile = File.join(@testbase, 'orig', "#{@targetfile}.ORIG") origcontents = "This is the original text" FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") @@ -180,7 +179,7 @@ #puts "Running history setup test" run_etch(@server, @testbase) - assert_equal(origcontents + "\n", get_file_contents(origfile), 'original backup of file via setup') + assert_equal(origcontents + "\n", get_file_contents(@origfile), 'original backup of file via setup') assert_equal(sourcecontents + origcontents + "\n", get_file_contents(@targetfile), 'contents using original backup of file via setup') end @@ -220,7 +219,6 @@ #puts "Running '#{testname}' test" run_etch(@server, @testbase) - origfile = File.join(@testbase, 'orig', "#{@targetfile}.ORIG") origcontents = "This is the original text for #{testname}" FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") @@ -249,7 +247,7 @@ #puts "Running '#{testname}' test" run_etch(@server, @testbase) - assert_equal(origcontents + "\n", get_file_contents(origfile), testname) + assert_equal(origcontents + "\n", get_file_contents(@origfile), testname) end def test_history_link @@ -257,10 +255,6 @@ # Ensure original file is backed up when it is a link # - origfile = File.join(@testbase, 'orig', "#{@targetfile}.ORIG") - historyfile = File.join(@testbase, 'history', "#{@targetfile}.HISTORY") - historydir = File.dirname(historyfile) - # Generate another file to use as our link target @destfile = Tempfile.new('etchtest').path @@ -291,9 +285,8 @@ #puts "Running history link test" run_etch(@server, @testbase) - assert_equal(@destfile, File.readlink(origfile), 'original backup of link') - system("cd #{historydir} && co -q -f -r1.1 #{historyfile}") - assert_match("#{@targetfile} -> #{@destfile}", get_file_contents(historyfile), 'history backup of link') + assert_equal(@destfile, File.readlink(@origfile), 'original backup of link') + assert_match("#{@targetfile} -> #{@destfile}", get_file_contents(File.join(@historydir, '0000')), '0000 history file of link') end def test_history_directory @@ -301,10 +294,6 @@ # Ensure original file is backed up when it is a directory # - origfile = File.join(@testbase, 'orig', "#{@targetfile}.ORIG") - historyfile = File.join(@testbase, 'history', "#{@targetfile}.HISTORY") - historydir = File.dirname(historyfile) - # Make the original target a directory File.delete(@targetfile) Dir.mkdir(@targetfile) @@ -341,14 +330,14 @@ #puts "Running history directory test" run_etch(@server, @testbase) - assert(File.directory?(origfile), 'original backup of directory') + assert(File.directory?(@origfile), 'original backup of directory') # Verify that etch backed up the original directory properly - assert_equal(before_uid, File.stat(origfile).uid, 'original directory uid') - assert_equal(before_gid, File.stat(origfile).gid, 'original directory gid') - assert_equal(before_mode, File.stat(origfile).mode, 'original directory mode') + assert_equal(before_uid, File.stat(@origfile).uid, 'original directory uid') + assert_equal(before_gid, File.stat(@origfile).gid, 'original directory gid') + assert_equal(before_mode, File.stat(@origfile).mode, 'original directory mode') # Check that the history log looks reasonable, it should contain an # 'ls -ld' of the directory - assert_match(" #{@targetfile}", get_file_contents(historyfile), 'history backup of directory') + assert_match(" #{@targetfile}", get_file_contents(File.join(@historydir, '0000')), '0000 history file of directory') end def test_history_directory_contents @@ -358,10 +347,7 @@ # differently in that case # - #origfile = File.join(@testbase, 'orig', "#{@targetfile}.ORIG") - origfile = File.join(@testbase, 'orig', "#{@targetfile}.TAR") - historyfile = File.join(@testbase, 'history', "#{@targetfile}.HISTORY") - historydir = File.dirname(historyfile) + origtarfile = File.join(@testbase, 'orig', "#{@targetfile}.TAR") # Make the original target a directory File.delete(@targetfile) @@ -394,12 +380,78 @@ # In this case, because we converted a directory to something else the # original will be a tarball of the directory - assert(File.file?(origfile), 'original backup of directory converted to file') + assert(File.file?(origtarfile), 'original backup of directory converted to file') # The tarball should have two entries, the directory and the 'testfile' # we put inside it - assert_equal('2', `tar tf #{origfile} | wc -l`.chomp.strip, 'original backup of directory contents') + assert_equal('2', `tar tf #{origtarfile} | wc -l`.chomp.strip, 'original backup of directory contents') end - + + def test_history_conversion + # + # Test the conversion of old RCS history logs to the new format + # + + # Mock up an original file and RCS history log + mockorigcontents = "This is the original text\n" + FileUtils.mkdir_p(File.dirname(@origfile)) + File.open(@origfile, 'w') do |file| + file.write(mockorigcontents) + end + historyparent = File.dirname(@historydir) + FileUtils.mkdir_p(historyparent) + File.open(@historydir, 'w') do |file| + file.write(mockorigcontents) + end + histrcsdir = File.join(historyparent, 'RCS') + FileUtils.mkdir_p(histrcsdir) + histbase = File.basename(@historydir) + system( + "cd #{historyparent} && " + + "ci -q -t-'Original of an etch modified file' " + + "-m'Update of an etch modified file' #{histbase} && " + + "co -q -r -kb #{histbase}") + mocksourcecontents = "This is the contents in the RCS history log\n" + system("cd #{historyparent} && co -q -l #{histbase}") + File.open(@historydir, 'w') do |file| + file.write(mocksourcecontents) + end + system( + "cd #{historyparent} && " + + "ci -q -t-'Original of an etch modified file' " + + "-m'Update of an etch modified file' #{histbase} && " + + "co -q -r -kb #{histbase}") + File.open(@targetfile, 'w') do |file| + file.write(mocksourcecontents) + end + + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") + File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| + file.puts <<-EOF + <config> + <file> + <warning_file/> + <source> + <plain>source</plain> + </source> + </file> + </config> + EOF + end + + sourcecontents = "This is a test\n" + File.open("#{@repodir}/source/#{@targetfile}/source", 'w') do |file| + file.write(sourcecontents) + end + + # Run etch + #puts "Running history conversion test" + run_etch(@server, @testbase) + + assert_equal(mockorigcontents, get_file_contents(File.join(@historydir, '0000')), 'RCS conv 0000 history file') + assert_equal(mocksourcecontents, get_file_contents(File.join(@historydir, '0001')), 'RCS conv 0001 history file') + assert_equal(sourcecontents, get_file_contents(File.join(@historydir, 'current')), 'RCS conv current history file') + end + def teardown remove_repository(@repodir) FileUtils.rm_rf(@testbase) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2010-01-20 22:30:55
|
Revision: 189 http://etch.svn.sourceforge.net/etch/?rev=189&view=rev Author: jheiss Date: 2010-01-20 22:30:45 +0000 (Wed, 20 Jan 2010) Log Message: ----------- Remove unnecessary File.delete Modified Paths: -------------- trunk/test/auth.rb Modified: trunk/test/auth.rb =================================================================== --- trunk/test/auth.rb 2010-01-19 00:30:46 UTC (rev 188) +++ trunk/test/auth.rb 2010-01-20 22:30:45 UTC (rev 189) @@ -193,7 +193,6 @@ # Put some text into the original file so that we can make sure it # is not touched. origcontents = "This is the original text\n" - File.delete(@targetfile) File.open(@targetfile, 'w') do |file| file.write(origcontents) end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2010-01-19 00:30:53
|
Revision: 188 http://etch.svn.sourceforge.net/etch/?rev=188&view=rev Author: jheiss Date: 2010-01-19 00:30:46 +0000 (Tue, 19 Jan 2010) Log Message: ----------- Update script to better handle a freshly setup server. Modified Paths: -------------- trunk/server/config/repo_update Modified: trunk/server/config/repo_update =================================================================== --- trunk/server/config/repo_update 2010-01-05 01:23:56 UTC (rev 187) +++ trunk/server/config/repo_update 2010-01-19 00:30:46 UTC (rev 188) @@ -3,13 +3,17 @@ require 'fileutils' require 'tempfile' -Dir.mkdir('/etc/etchserver') if !File.directory?('/etc/etchserver') -Dir.mkdir('/etc/etchserver/orig') if !File.directory?('/etc/etchserver/orig') +if !File.directory('/etc/etchserver/trunk') + abort "Please check out an etch config repo in /etc/etchserver/trunk" +end + +FileUtils.mkdir_p('/etc/etchserver/orig') FileUtils.chown('nobody', nil, '/etc/etchserver/orig') Dir.chdir('/etc/etchserver') system('svn update --quiet') # Create hourly tag +FileUtils.mkdir_p('/etc/etchserver/tags') currenttag = Time.now.strftime('etchautotag-%Y%m%d-%H00') tagdir = File.join('tags', currenttag) if !File.directory?(tagdir) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2010-01-05 01:24:05
|
Revision: 187 http://etch.svn.sourceforge.net/etch/?rev=187&view=rev Author: jheiss Date: 2010-01-05 01:23:56 +0000 (Tue, 05 Jan 2010) Log Message: ----------- Fix setting of CLIENTDIR and SERVERDIR to better handle relative paths. Modified Paths: -------------- trunk/test/etchtest.rb Modified: trunk/test/etchtest.rb =================================================================== --- trunk/test/etchtest.rb 2009-12-17 04:36:21 UTC (rev 186) +++ trunk/test/etchtest.rb 2010-01-05 01:23:56 UTC (rev 187) @@ -8,8 +8,8 @@ module EtchTests # Roughly ../server and ../client - SERVERDIR = "#{File.dirname(File.dirname(__FILE__))}/server" - CLIENTDIR = "#{File.dirname(File.dirname(__FILE__))}/client" + SERVERDIR = "#{File.dirname(File.dirname(File.expand_path(__FILE__)))}/server" + CLIENTDIR = "#{File.dirname(File.dirname(File.expand_path(__FILE__)))}/client" # Haven't found a Ruby method for creating temporary directories, # so create a temporary file and replace it with a directory. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-12-17 04:36:29
|
Revision: 186 http://etch.svn.sourceforge.net/etch/?rev=186&view=rev Author: jheiss Date: 2009-12-17 04:36:21 +0000 (Thu, 17 Dec 2009) Log Message: ----------- Update with the changes made by the MacPorts folks when they added the port to the official repo. Modified Paths: -------------- trunk/client/Portfile Modified: trunk/client/Portfile =================================================================== --- trunk/client/Portfile 2009-12-10 23:52:19 UTC (rev 185) +++ trunk/client/Portfile 2009-12-17 04:36:21 UTC (rev 186) @@ -2,6 +2,7 @@ # $Id$ PortSystem 1.0 +PortGroup ruby 1.0 name etch version %VER% @@ -29,15 +30,12 @@ rmd160 %RMD160% depends_build port:rb-rake -depends_run port:ruby \ - port:facter +depends_run port:facter -PortGroup ruby 1.0 - +worksrcdir ${worksrcdir}/client use_configure no build {} -test.run no -destroot.cmd cd client && rake +destroot.cmd ${prefix}/bin/rake destroot.target install\[${destroot}\] -destroot.destdir "" +destroot.destdir This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-12-10 23:52:29
|
Revision: 185 http://etch.svn.sourceforge.net/etch/?rev=185&view=rev Author: jheiss Date: 2009-12-10 23:52:19 +0000 (Thu, 10 Dec 2009) Log Message: ----------- Add separate task to delete old results. Modified Paths: -------------- trunk/server/lib/tasks/etch.rake Modified: trunk/server/lib/tasks/etch.rake =================================================================== --- trunk/server/lib/tasks/etch.rake 2009-12-10 23:16:42 UTC (rev 184) +++ trunk/server/lib/tasks/etch.rake 2009-12-10 23:52:19 UTC (rev 185) @@ -1,12 +1,30 @@ namespace :etch do - desc 'Clean stale clients out of database' + desc 'Clean stale clients and old results out of database' task :dbclean, [:hours] => [:environment] do |t, args| - if args.hours - Client.find(:all, :conditions => ['updated_at < ?', args.hours.to_i.hours.ago]).each do |client| - puts "Deleting #{client.name}" - client.destroy + Rake::Task['etch:dbclean:clients'].invoke(args.hours) + Rake::Task['etch:dbclean:results'].invoke(args.hours) + end + + namespace :dbclean do + desc 'Clean stale clients out of database' + task :clients, [:hours] => [:environment] do |t, args| + if args.hours + Client.find(:all, :conditions => ['updated_at < ?', args.hours.to_i.hours.ago]).each do |client| + puts "Deleting #{client.name}" + client.destroy + end end end + + desc 'Clean older results out of database' + task :results, [:hours] => [:environment] do |t, args| + if args.hours + Result.find(:all, :conditions => ['created_at < ?', args.hours.to_i.hours.ago]).each do |result| + puts "Deleting result" + result.destroy + end + end + end end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-12-10 23:16:50
|
Revision: 184 http://etch.svn.sourceforge.net/etch/?rev=184&view=rev Author: jheiss Date: 2009-12-10 23:16:42 +0000 (Thu, 10 Dec 2009) Log Message: ----------- Add comment about rake task. Modified Paths: -------------- trunk/server/config/dbclean Modified: trunk/server/config/dbclean =================================================================== --- trunk/server/config/dbclean 2009-12-10 23:09:58 UTC (rev 183) +++ trunk/server/config/dbclean 2009-12-10 23:16:42 UTC (rev 184) @@ -1,5 +1,9 @@ #!/usr/bin/ruby -w +# The etch:dbclean rake task is a simpler way of accomplishing the same goal +# as this script. Consider this script an example of how to program against +# the REST API. + # This script can be used as a cron job to clean stale clients out of # the database. It takes one required parameter, a number of hours. # Clients which have not checked in within that many hours will be This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-12-10 23:10:08
|
Revision: 183 http://etch.svn.sourceforge.net/etch/?rev=183&view=rev Author: jheiss Date: 2009-12-10 23:09:58 +0000 (Thu, 10 Dec 2009) Log Message: ----------- A rake task to clean stale clients out of the database. Added Paths: ----------- trunk/server/lib/tasks/etch.rake Added: trunk/server/lib/tasks/etch.rake =================================================================== --- trunk/server/lib/tasks/etch.rake (rev 0) +++ trunk/server/lib/tasks/etch.rake 2009-12-10 23:09:58 UTC (rev 183) @@ -0,0 +1,12 @@ +namespace :etch do + desc 'Clean stale clients out of database' + task :dbclean, [:hours] => [:environment] do |t, args| + if args.hours + Client.find(:all, :conditions => ['updated_at < ?', args.hours.to_i.hours.ago]).each do |client| + puts "Deleting #{client.name}" + client.destroy + end + end + end +end + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-12-10 22:29:56
|
Revision: 182 http://etch.svn.sourceforge.net/etch/?rev=182&view=rev Author: jheiss Date: 2009-12-10 22:29:47 +0000 (Thu, 10 Dec 2009) Log Message: ----------- Script to clean stale clients out of the database. Added Paths: ----------- trunk/server/config/dbclean Added: trunk/server/config/dbclean =================================================================== --- trunk/server/config/dbclean (rev 0) +++ trunk/server/config/dbclean 2009-12-10 22:29:47 UTC (rev 182) @@ -0,0 +1,106 @@ +#!/usr/bin/ruby -w + +# This script can be used as a cron job to clean stale clients out of +# the database. It takes one required parameter, a number of hours. +# Clients which have not checked in within that many hours will be +# deleted. I.e. if run as "dbclean 168" then clients which haven't +# updated in the last week (7 * 24 hours) will be deleted. + +require 'net/https' +require 'rexml/document' +require 'optparse' + +# +# Parse the command line options +# + +options = {} +options[:server] = 'https://etch' + +opts = OptionParser.new(nil, 24, ' ') +opts.banner = 'Usage: dbclean [options] hours' +opts.on('--dry-run', '-n', 'Make no changes.') do |opt| + options[:dryrun] = opt +end +opts.on('--interactive', 'Prompt for confirmation before each change.') do |opt| + options[:interactive] = opt +end +opts.on('--server SERVER', 'Point to an alternate etch server.') do |opt| + options[:server] = opt +end +opts.on('--debug', 'Print lots of messages about what etch is doing.') do |opt| + options[:debug] = opt +end +opts.on_tail('-h', '--help', 'Show this message.') do + puts opts + exit +end + +leftovers = opts.parse(ARGV) +hours = leftovers.shift + +# Display a usage message if the user did not specify hours or specified +# something that isn't numeric +if !hours || hours.to_i == 0 + puts opts + exit +end + +# Make sure the server URL ends in a / so that we can append paths +# to it using URI.join +if options[:server] !~ %r{/$} + options[:server] << '/' +end + +# +# Do stuff +# + +clientsuri = URI.join(options[:server], "clients.xml?not_updated_since=#{hours}") + +http = Net::HTTP.new(clientsuri.host, clientsuri.port) +if clientsuri.scheme == "https" + # Eliminate the OpenSSL "using default DH parameters" warning + if File.exist?(File.join('etc', 'etch', 'dhparams')) + dh = OpenSSL::PKey::DH.new(IO.read(File.join('etc', 'etch', 'dhparams'))) + Net::HTTP.ssl_context_accessor(:tmp_dh_callback) + http.tmp_dh_callback = proc { dh } + end + http.use_ssl = true + if File.exist?(File.join('etc', 'etch', 'ca.pem')) + http.ca_file = File.join('etc', 'etch', 'ca.pem') + http.verify_mode = OpenSSL::SSL::VERIFY_PEER + elsif File.directory?(File.join('etc', 'etch', 'ca')) + http.ca_path = File.join('etc', 'etch', 'ca') + http.verify_mode = OpenSSL::SSL::VERIFY_PEER + end +end +http.start + +puts "GET #{clientsuri}" if (options[:debug]) +response = http.get(clientsuri.request_uri) +if !response.kind_of?(Net::HTTPSuccess) + $stderr.puts response.body + # error! raises an exception + response.error! +end +puts "Response from server:\n'#{response.body}'" if (options[:debug]) +if !response.body.nil? && !response.body.empty? + response_xml = REXML::Document.new(response.body) + response_xml.elements.each('/clients/client') do |client| + if options[:interactive] + # FIXME + end + clienturi = URI.join(options[:server], "clients/#{client.elements['id'].text}.xml") + puts "DELETE #{clienturi}" if (options[:debug]) + if !options[:dryrun] + delresponse = http.delete(clienturi.request_uri) + if !delresponse.kind_of?(Net::HTTPSuccess) + $stderr.puts response.body + # error! raises an exception + response.error! + end + end + end +end + Property changes on: trunk/server/config/dbclean ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-12-10 22:26:39
|
Revision: 181 http://etch.svn.sourceforge.net/etch/?rev=181&view=rev Author: jheiss Date: 2009-12-10 22:26:28 +0000 (Thu, 10 Dec 2009) Log Message: ----------- Add updated_since and not_updated_since parameters to allow searching for clients last updated before or after a given point. Previously searching against the updated_at field was limited to searching for hosts last updated at an exact time, which doesn't seem very useful. Modified Paths: -------------- trunk/server/app/controllers/clients_controller.rb Modified: trunk/server/app/controllers/clients_controller.rb =================================================================== --- trunk/server/app/controllers/clients_controller.rb 2009-12-10 21:10:38 UTC (rev 180) +++ trunk/server/app/controllers/clients_controller.rb 2009-12-10 22:26:28 UTC (rev 181) @@ -47,6 +47,12 @@ elsif key == 'name_substring' conditions_query << "name LIKE ?" conditions_values << '%' + value + '%' + elsif key == 'updated_since' + conditions_query << "updated_at >= ?" + conditions_values << value.to_i.hours.ago + elsif key == 'not_updated_since' + conditions_query << "updated_at < ?" + conditions_values << value.to_i.hours.ago elsif allowed_queries.include?(key) conditions_query << "#{key} = ?" conditions_values << value This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-12-10 21:10:52
|
Revision: 180 http://etch.svn.sourceforge.net/etch/?rev=180&view=rev Author: jheiss Date: 2009-12-10 21:10:38 +0000 (Thu, 10 Dec 2009) Log Message: ----------- Add delete link Modified Paths: -------------- trunk/server/app/views/clients/show.html.erb Modified: trunk/server/app/views/clients/show.html.erb =================================================================== --- trunk/server/app/views/clients/show.html.erb 2009-12-04 23:54:08 UTC (rev 179) +++ trunk/server/app/views/clients/show.html.erb 2009-12-10 21:10:38 UTC (rev 180) @@ -58,7 +58,8 @@ <p class="metadata"> <strong>Created at:</strong> <%= h(@client.created_at) %><br /> - <strong>Updated at:</strong> <%= h(@client.updated_at) %> + <strong>Updated at:</strong> <%= h(@client.updated_at) %><br /> + <%= link_to 'Delete', client_path(@client), :confirm => 'Are you sure?', :method => :delete %></p> </p> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-12-04 23:54:14
|
Revision: 179 http://etch.svn.sourceforge.net/etch/?rev=179&view=rev Author: jheiss Date: 2009-12-04 23:54:08 +0000 (Fri, 04 Dec 2009) Log Message: ----------- Update per demise of alltests.rb Add LICENSE file to distribution. Modified Paths: -------------- Rakefile Modified: Rakefile =================================================================== --- Rakefile 2009-12-03 23:01:12 UTC (rev 178) +++ Rakefile 2009-12-04 23:54:08 UTC (rev 179) @@ -5,20 +5,20 @@ desc 'Run test suite in trunk' task :test_trunk do - system('./trunk/test/alltests.rb') + system('cd trunk/client && rake test') end desc 'Run test suite in current tag' task :test_tag do - system("./#{TAGDIR}/test/alltests.rb") + system("cd #{TAGDIR}/client && rake test") end desc 'Build distribution files for new release' -#task :dist => :test_tag do +#task :dist => [:tag, :test_tag] do task :dist do rm_rf(DIST) mkdir(DIST) - system("(cd #{TAGDIR} && find client server test etchserver-* README VERSION | grep -v '\.svn' | cpio -pdum ../../#{DIST})") + system("(cd #{TAGDIR} && find client server test etchserver-* LICENSE README VERSION | grep -v '\.svn' | cpio -pdum ../../#{DIST})") system("tar czf #{DIST}.tar.gz #{DIST}") rm_rf(DIST) system("openssl md5 #{DIST}.tar.gz > #{DIST}.tar.gz.md5") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-12-03 23:01:22
|
Revision: 178 http://etch.svn.sourceforge.net/etch/?rev=178&view=rev Author: jheiss Date: 2009-12-03 23:01:12 +0000 (Thu, 03 Dec 2009) Log Message: ----------- Replace alltests.rb with a rake task so that we're a little more standard. Requires updating file paths in a lot of the test code so that tests can be run from a different directory. Rather than starting a new instance of the etch server for every test start one only if needed and reuse it. Cuts the time to run the entire test suite in half. Modified Paths: -------------- trunk/test/README trunk/test/actions.rb trunk/test/attributes.rb trunk/test/auth.rb trunk/test/commands.rb trunk/test/delete.rb trunk/test/depend.rb trunk/test/etchtest.rb trunk/test/file.rb trunk/test/history.rb trunk/test/link.rb trunk/test/local_requests.rb trunk/test/nodegroups.rb trunk/test/options.rb trunk/test/outputcapture.rb trunk/test/scripts.rb trunk/test/transitions.rb Added Paths: ----------- trunk/Rakefile Removed Paths: ------------- trunk/test/alltests.rb Added: trunk/Rakefile =================================================================== --- trunk/Rakefile (rev 0) +++ trunk/Rakefile 2009-12-03 23:01:12 UTC (rev 178) @@ -0,0 +1,14 @@ +require 'rake/testtask' + +# rake test +Rake::TestTask.new do |t| + # If the user hasn't already set the xmllib environment variable then set it + # to use LibXML so that the tests involving DTD validation are run. + if !ENV['xmllib'] + ENV['xmllib'] = 'libxml' + end + + t.verbose = true + #t.pattern = 'test/*.rb' + t.test_files = Dir.glob('test/*.rb').reject {|test| test =~ /etchtest.rb/} +end Modified: trunk/test/README =================================================================== --- trunk/test/README 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/README 2009-12-03 23:01:12 UTC (rev 178) @@ -1,7 +1,8 @@ -To execute all tests run alltests.rb +To execute all tests run "rake test". +To execute the tests in a specific file run "rake test TEST=test/file.rb". +To execute a specific test method run + "rake test TEST=test/file.rb TESTOPTS='--name=test_files'" -You can also run the individual .rb test files to test specific areas. - To force a particular XML library set xmllib=libxml or xmllib=rexml in your environment before running the tests. Modified: trunk/test/actions.rb =================================================================== --- trunk/test/actions.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/actions.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -4,10 +4,7 @@ # Test etch's handling of various actions: pre, post, setup, test, etc. # -require 'test/unit' -require 'etchtest' -require 'tempfile' -require 'fileutils' +require File.join(File.dirname(__FILE__), 'etchtest') class EtchActionTests < Test::Unit::TestCase include EtchTests @@ -19,7 +16,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port, @pid = start_server(@repodir) + @server = get_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -79,7 +76,7 @@ # Run etch #puts "Running initial action test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the actions were executed # The setup actions will get run several times as we loop @@ -103,7 +100,7 @@ # Run etch again and make sure that the exec_once command wasn't run # again - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert_equal("exec_once\n", get_file_contents("#{@repodir}/exec_once"), 'exec_once_2nd_check') end @@ -145,7 +142,7 @@ # Run etch #puts "Running initial action test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that the file was not touched assert_equal(origcontents, get_file_contents(@targetfile), 'failed setup') @@ -188,7 +185,7 @@ # Run etch #puts "Running failed pre test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that the file was not touched assert_equal(origcontents, get_file_contents(@targetfile), 'failed pre') @@ -237,7 +234,7 @@ # Run etch #puts "Running failed test test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the original was restored, and that post was run twice assert_equal(origcontents, get_file_contents(@targetfile), 'failed test target') @@ -273,7 +270,7 @@ # Run etch #puts "Running failed test_before_post test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that post was not run assert(!File.exist?("#{@repodir}/post"), 'failed test_before_post post') @@ -289,7 +286,7 @@ # Run etch #puts "Running failed test symlink test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that the original symlink was restored assert_equal(@destfile, File.readlink(@targetfile), 'failed test symlink') @@ -306,7 +303,7 @@ # Run etch #puts "Running failed test directory test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that the original directory was restored assert(File.directory?(@targetfile), 'failed test directory') @@ -328,7 +325,7 @@ # Run etch #puts "Running failed test no original file test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that the lack of an original file was restored assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), 'failed test no original file') @@ -376,7 +373,7 @@ # Run etch #puts "Running nested target with test test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(nestedtargetfile), 'nested target with test') @@ -417,7 +414,7 @@ # Run etch #puts "Running XML escape test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the action was executed assert_equal("post\n", get_file_contents("#{@repodir}/post_with_escape"), 'post with escape') @@ -460,14 +457,13 @@ # Run etch #puts "Running environment variable test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the action was executed assert_equal("testvalue\n", get_file_contents("#{@repodir}/post_with_env_output"), 'post with environment variable') end def teardown - stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Deleted: trunk/test/alltests.rb =================================================================== --- trunk/test/alltests.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/alltests.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -1,20 +0,0 @@ -#!/usr/bin/ruby -w - -# Some of the tests involve DTD validation. For that we need LibXML. -ENV['xmllib'] = 'libxml' - -# -# Run all of the etch test cases -# - -require 'test/unit' -Dir.chdir(File.dirname(__FILE__)) -Dir.foreach('.') do |entry| - next unless entry =~ /\.rb$/ - # Skip this file - next if entry == 'alltests.rb' - # And the shared file - next if entry == 'etchtest.rb' - - require entry -end Modified: trunk/test/attributes.rb =================================================================== --- trunk/test/attributes.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/attributes.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -4,10 +4,7 @@ # Test etch's handling of attribute filtering in config.xml files # -require 'test/unit' -require 'etchtest' -require 'tempfile' -require 'fileutils' +require File.join(File.dirname(__FILE__), 'etchtest') require 'rubygems' # Might be needed to find facter require 'facter' @@ -21,7 +18,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port, @pid = start_server(@repodir) + @server = get_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -63,7 +60,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was not modified assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -94,7 +91,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -139,7 +136,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -178,7 +175,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was not modified assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -209,7 +206,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -255,7 +252,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -294,7 +291,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was not modified assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -325,7 +322,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -364,7 +361,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -403,7 +400,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was not modified assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -434,7 +431,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -473,7 +470,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was not modified assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -514,7 +511,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -553,7 +550,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was not modified assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -589,7 +586,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -620,7 +617,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -628,7 +625,6 @@ end def teardown - stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/auth.rb =================================================================== --- trunk/test/auth.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/auth.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -4,10 +4,7 @@ # Test etch's handling of client authentication # -require 'test/unit' -require 'etchtest' -require 'tempfile' -require 'fileutils' +require File.join(File.dirname(__FILE__), 'etchtest') require 'net/http' require 'rexml/document' require 'facter' @@ -22,7 +19,10 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port, @pid = start_server(@repodir) + # These tests set an etchserver.conf. The server only reads that file + # once and caches the settings, so we need to start up new server + # instances for these tests rather than reusing the global test server. + @server = start_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -30,7 +30,7 @@ # Make sure the server will initially think this is a new client hostname = Facter['fqdn'].value - Net::HTTP.start('localhost', @port) do |http| + Net::HTTP.start('localhost', @server[:port]) do |http| # Find our client id response = http.get("/clients.xml?name=#{hostname}") if !response.kind_of?(Net::HTTPSuccess) @@ -84,7 +84,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -115,7 +115,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -154,7 +154,7 @@ # Run etch with the wrong key to force a bad signature #puts "Running '#{testname}' test" - run_etch(@port, @testbase, true, '--key=keys/testkey2') + run_etch(@server, @testbase, true, "--key=#{File.join(File.dirname(__FILE__), 'keys', 'testkey2')}") # Verify that the file was not touched assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -200,7 +200,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that the file was not touched assert_equal(origcontents, get_file_contents(@targetfile), testname) @@ -212,9 +212,9 @@ puts "# Starting a second copy of the server and adding this client to the database" sleep 3 repodir2 = initialize_repository - port2, pid2 = start_server(repodir2) - run_etch(port2, @testbase) - stop_server(pid2) + server2 = start_server(repodir2) + run_etch(server2, @testbase) + stop_server(server2) remove_repository(repodir2) # @@ -243,14 +243,14 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) end def teardown - stop_server(@pid) + stop_server(@server) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/commands.rb =================================================================== --- trunk/test/commands.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/commands.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -4,10 +4,7 @@ # Test etch's handling of configuration commands # -require 'test/unit' -require 'etchtest' -require 'tempfile' -require 'fileutils' +require File.join(File.dirname(__FILE__), 'etchtest') class EtchCommandTests < Test::Unit::TestCase include EtchTests @@ -19,7 +16,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port, @pid = start_server(@repodir) + @server = get_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -50,7 +47,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(testname, get_file_contents(@targetfile), testname) @@ -82,7 +79,7 @@ # The assertion here is handled by run_etch as we're passing it an # argument indicating that we expect failure. #puts "Running '#{testname}' test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) end def test_commands_guard_succeeds @@ -111,7 +108,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was not touched assert_equal(testname, get_file_contents(@targetfile), testname) @@ -149,7 +146,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that both steps ran and in the proper order assert_equal("firststep\nsecondstep\n", get_file_contents(@targetfile), testname) @@ -194,7 +191,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that both commands ran, ordering doesn't matter assert_equal(['firstcmd', 'secondcmd'], get_file_contents(@targetfile).split("\n").sort, testname) @@ -240,7 +237,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that both commands ran and in the proper order assert_equal("firstcmd\nsecondcmd\n", get_file_contents(@targetfile), testname) @@ -294,7 +291,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the command-generated file and the regular file were created # properly @@ -339,7 +336,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that only the desired step executed assert_equal("notingroup\n", get_file_contents(@targetfile), testname) @@ -366,11 +363,10 @@ # The assertion here is handled by run_etch as we're passing it an # argument indicating that we expect failure. #puts "Running '#{testname}' test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) end def teardown - stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/delete.rb =================================================================== --- trunk/test/delete.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/delete.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -4,10 +4,7 @@ # Test etch's handling of deleting files # -require 'test/unit' -require 'etchtest' -require 'tempfile' -require 'fileutils' +require File.join(File.dirname(__FILE__), 'etchtest') class EtchDeleteTests < Test::Unit::TestCase include EtchTests @@ -19,7 +16,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port, @pid = start_server(@repodir) + @server = get_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -50,7 +47,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was deleted assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), testname) @@ -76,7 +73,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the link was deleted assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), testname) @@ -104,7 +101,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that the directory was not deleted assert(File.directory?(@targetfile), testname) @@ -133,7 +130,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the directory was deleted assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), testname) @@ -156,7 +153,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that we still don't have a file. That's rather unlikely, # this is really more a test that etch doesn't throw an error if @@ -190,7 +187,7 @@ # Run etch #puts "Running duplicate script instructions test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert(!File.exist?(@targetfile), 'duplicate script instructions') @@ -223,7 +220,7 @@ # Run etch #puts "Running contradictory script instructions test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that the file wasn't removed assert(File.exist?(@targetfile), 'contradictory script instructions') @@ -231,7 +228,6 @@ end def teardown - stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/depend.rb =================================================================== --- trunk/test/depend.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/depend.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -4,10 +4,7 @@ # Test etch's handling of dependencies # -require 'test/unit' -require 'etchtest' -require 'tempfile' -require 'fileutils' +require File.join(File.dirname(__FILE__), 'etchtest') class EtchDependTests < Test::Unit::TestCase include EtchTests @@ -21,7 +18,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port, @pid = start_server(@repodir) + @server = get_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -79,7 +76,7 @@ # Run etch #puts "Running initial dependency test" - run_etch(@port, @testbase, false) + run_etch(@server, @testbase, false) # Verify that the files were created properly assert_equal(sourcecontents, get_file_contents(@targetfile), 'dependency file 1') @@ -141,7 +138,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase, false, @targetfile) + run_etch(@server, @testbase, false, @targetfile) # Verify that the files were created properly assert_equal(sourcecontents, get_file_contents(@targetfile), 'single request dependency file 1') @@ -205,7 +202,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase, true, @targetfile) + run_etch(@server, @testbase, true, @targetfile) # Verify that the files weren't modified assert_equal(origcontents, get_file_contents(@targetfile), 'circular dependency file 1') @@ -259,7 +256,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the regular file and the command-generated file were created # properly @@ -270,7 +267,6 @@ end def teardown - stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/etchtest.rb =================================================================== --- trunk/test/etchtest.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/etchtest.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -2,12 +2,15 @@ # Module of code shared by all of the etch test cases # +require 'test/unit' require 'tempfile' require 'fileutils' -ENV['RUBYLIB'] = '../server/lib' - module EtchTests + # Roughly ../server and ../client + SERVERDIR = "#{File.dirname(File.dirname(__FILE__))}/server" + CLIENTDIR = "#{File.dirname(File.dirname(__FILE__))}/client" + # Haven't found a Ruby method for creating temporary directories, # so create a temporary file and replace it with a directory. def tempdir @@ -17,18 +20,18 @@ Dir.mkdir(tmpdir) tmpdir end - - def initialize_repository(nodegroups = []) + + def initialize_repository(nodegroups=[]) # Generate a temp directory to put our test repository into - repodir = tempdir - + repo = tempdir + # Put the basic files into that directory needed for a basic etch tree - FileUtils.cp_r(Dir.glob('testrepo/*'), repodir) - + FileUtils.cp_r(Dir.glob("#{File.dirname(__FILE__)}/testrepo/*"), repo) + hostname = `facter fqdn`.chomp nodegroups_string = '' nodegroups.each { |ng| nodegroups_string << "<group>#{ng}</group>\n" } - File.open(File.join(repodir, 'nodes.xml'), 'w') do |file| + File.open(File.join(repo, 'nodes.xml'), 'w') do |file| file.puts <<-EOF <nodes> <node name="#{hostname}"> @@ -38,65 +41,87 @@ EOF end - puts "Created repository #{repodir}" + puts "Created repository #{repo}" - repodir + repo end - - def remove_repository(repodir) - FileUtils.rm_rf(repodir) + + def remove_repository(repo) + FileUtils.rm_rf(repo) end - + + @@server = nil + def get_server(newrepo=nil) + if !@@server + @@server = start_server + end + if newrepo + swap_repository(@@server, newrepo) + end + @@server + end + + def swap_repository(server, newrepo) + # Point server[:repo] symlink to newrepo + FileUtils.rm_f(server[:repo]) + File.symlink(newrepo, server[:repo]) + end + UNICORN = false - def start_server(repodir) - ENV['etchserverbase'] = repodir + def start_server(repo='no_repo_yet') + # We want the running server's notion of the server base to be a symlink + # that we can easily change later in swap_repository. + serverbase = Tempfile.new('etchtest').path + File.delete(serverbase) + File.symlink(repo, serverbase) + ENV['etchserverbase'] = serverbase # Pick a random port in the 3001-6000 range (range somewhat randomly chosen) port = 3001 + rand(3000) if pid = fork puts "Giving the server some time to start up" sleep(5) else - Dir.chdir('../server') if UNICORN - exec("unicorn_rails -p #{port}") + exec("cd #{SERVERDIR} && unicorn_rails -p #{port}") else - exec("./script/server -p #{port}") + exec("cd #{SERVERDIR} && ./script/server -p #{port}") end end - [port, pid] + {:port => port, :pid => pid, :repo => serverbase} end - - def stop_server(pid) - Process.kill('TERM', pid) - Process.waitpid(pid) + + def stop_server(server) + Process.kill('TERM', server[:pid]) + Process.waitpid(server[:pid]) end - - def run_etch(port, testbase, errors_expected=false, extra_args='') - #extra_args = extra_args + " --debug" + + def run_etch(server, testbase, errors_expected=false, extra_args='') + extra_args = extra_args + " --debug" if errors_expected # Warn the user that errors are expected. Otherwise it can be # disconcerting if you're watching the tests run and see errors. - sleep 3 + #sleep 3 puts "#" puts "# Errors expected here" puts "#" #sleep 3 end - result = system("ruby ../client/etch --generate-all --server=http://localhost:#{port} --test-base=#{testbase} --key=keys/testkey #{extra_args}") + result = system("ruby #{CLIENTDIR}/etch --generate-all --server=http://localhost:#{server[:port]} --test-base=#{testbase} --key=#{File.dirname(__FILE__)}/keys/testkey #{extra_args}") if errors_expected assert(!result) else assert(result) end end - + + # Wrap File.read and return nil if an exception occurs def get_file_contents(file) # Don't follow symlinks if File.file?(file) && !File.symlink?(file) # Trap exceptions (like non-existent file) so that tests can # properly report back whether the file contents match or not. begin - IO.read(file) + File.read(file) rescue nil end Modified: trunk/test/file.rb =================================================================== --- trunk/test/file.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/file.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -4,10 +4,7 @@ # Test etch's handling of creating and updating regular files # -require 'test/unit' -require 'etchtest' -require 'tempfile' -require 'fileutils' +require File.join(File.dirname(__FILE__), 'etchtest') class EtchFileTests < Test::Unit::TestCase include EtchTests @@ -19,7 +16,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port, @pid = start_server(@repodir) + @server = get_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -52,7 +49,7 @@ # Run etch #puts "Running initial file test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly correctcontents = '' @@ -89,7 +86,7 @@ # Run etch #puts "Running initial file test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly correctcontents = '' @@ -130,7 +127,7 @@ # Run etch #puts "Running different warning file test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly correctcontents = '' @@ -167,7 +164,7 @@ # Run etch #puts "Running no warning file test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), 'no warning file') @@ -197,7 +194,7 @@ # Run etch #puts "Running different line comment test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly correctcontents = '' @@ -236,7 +233,7 @@ # Run etch #puts "Running comment open/close test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly correctcontents = "/*\n" @@ -276,7 +273,7 @@ # Run etch #puts "Running warning on second line test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly correctcontents = sourcecontents_firstline @@ -314,7 +311,7 @@ # Run etch #puts "Running no space around warning test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly correctcontents = '' @@ -347,7 +344,7 @@ # Run etch #puts "Running file ownership and permissions test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file ownership got set correctly # Most systems don't support give-away chown, so this test won't work @@ -383,7 +380,7 @@ # Run etch #puts "Running file ownership w/ bogus owner/group names" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the ownership defaulted to UID/GID 0 # Most systems don't support give-away chown, so this test won't work @@ -419,7 +416,7 @@ # Run etch #puts "Running always_manage_metadata test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file permissions got set correctly perms = File.stat(@targetfile).mode & 07777 @@ -459,7 +456,7 @@ # Run etch #puts "Running duplicate plain instructions test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file contents were updated assert_equal(sourcecontents, get_file_contents(@targetfile), 'duplicate plain instructions') @@ -498,7 +495,7 @@ # Run etch #puts "Running contradictory plain instructions test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that the file contents didn't change assert_equal(origcontents, get_file_contents(@targetfile), 'contradictory plain instructions') @@ -534,7 +531,7 @@ # Run etch #puts "Running duplicate template instructions test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file contents were updated assert_equal(sourcecontents, get_file_contents(@targetfile), 'duplicate template instructions') @@ -573,7 +570,7 @@ # Run etch #puts "Running contradictory template instructions test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that the file contents didn't change assert_equal(origcontents, get_file_contents(@targetfile), 'contradictory template instructions') @@ -609,7 +606,7 @@ # Run etch #puts "Running duplicate script instructions test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file contents were updated assert_equal(sourcecontents, get_file_contents(@targetfile), 'duplicate script instructions') @@ -648,7 +645,7 @@ # Run etch #puts "Running contradictory script instructions test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that the file contents didn't change assert_equal(origcontents, get_file_contents(@targetfile), 'contradictory script instructions') @@ -687,14 +684,13 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(specialtargetfile), testname) end def teardown - stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/history.rb =================================================================== --- trunk/test/history.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/history.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -5,10 +5,7 @@ # history files # -require 'test/unit' -require 'etchtest' -require 'tempfile' -require 'fileutils' +require File.join(File.dirname(__FILE__), 'etchtest') class EtchHistoryTests < Test::Unit::TestCase include EtchTests @@ -20,7 +17,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port, @pid = start_server(@repodir) + @server = get_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -64,7 +61,7 @@ # Run etch #puts "Running initial history test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert_equal(origcontents, get_file_contents(origfile), 'original backup of file') system("cd #{historydir} && co -q -f -r1.1 #{historyfile}") @@ -87,7 +84,7 @@ # Run etch #puts "Running update test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert_equal(origcontents, get_file_contents(origfile), 'original backup of file unchanged') assert_equal(updatedsourcecontents, get_file_contents(historyfile), 'history log of file updated') @@ -117,7 +114,7 @@ # Run etch #puts "Running revert test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert_equal(origcontents, get_file_contents(@targetfile), 'original contents reverted') @@ -133,7 +130,7 @@ # Run etch #puts "Running revert test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert_equal(updatedorigcontents, get_file_contents(@targetfile), 'Updated original contents unchanged') end @@ -181,7 +178,7 @@ # Run etch #puts "Running history setup test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert_equal(origcontents + "\n", get_file_contents(origfile), 'original backup of file via setup') assert_equal(sourcecontents + origcontents + "\n", get_file_contents(@targetfile), 'contents using original backup of file via setup') @@ -221,7 +218,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) origfile = File.join(@testbase, 'orig', "#{@targetfile}.ORIG") origcontents = "This is the original text for #{testname}" @@ -250,7 +247,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert_equal(origcontents + "\n", get_file_contents(origfile), testname) end @@ -292,7 +289,7 @@ # Run etch #puts "Running history link test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert_equal(@destfile, File.readlink(origfile), 'original backup of link') system("cd #{historydir} && co -q -f -r1.1 #{historyfile}") @@ -342,7 +339,7 @@ # Run etch #puts "Running history directory test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert(File.directory?(origfile), 'original backup of directory') # Verify that etch backed up the original directory properly @@ -393,7 +390,7 @@ # Run etch #puts "Running history directory contents test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # In this case, because we converted a directory to something else the # original will be a tarball of the directory @@ -404,7 +401,6 @@ end def teardown - stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/link.rb =================================================================== --- trunk/test/link.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/link.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -4,10 +4,7 @@ # Test etch's handling of creating and updating symbolic links # -require 'test/unit' -require 'etchtest' -require 'tempfile' -require 'fileutils' +require File.join(File.dirname(__FILE__), 'etchtest') require 'pathname' class EtchLinkTests < Test::Unit::TestCase @@ -24,7 +21,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port, @pid = start_server(@repodir) + @server = get_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -54,7 +51,7 @@ # Run etch #puts "Running initial link test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert_equal(@destfile, File.readlink(@targetfile), 'link create') @@ -75,7 +72,7 @@ # Run etch #puts "Running link update test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert_equal(@destfile2, File.readlink(@targetfile), 'link update') @@ -104,7 +101,7 @@ # Run etch #puts "Running link update from non-existent file test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert_equal(@destfile, File.readlink(@targetfile), 'link update from non-existent file') end @@ -130,7 +127,7 @@ # Run etch #puts "Running link to non-existent destination test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the link was not created assert(!File.symlink?(@targetfile), 'link to non-existent destination') @@ -154,7 +151,7 @@ # Run etch #puts "Running link to non-existent destination with override test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the link was updated properly assert_equal(@destfile, File.readlink(@targetfile), 'link to non-existent destination with override') @@ -183,7 +180,7 @@ # Run etch #puts "Running relative link test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the link was updated properly assert_equal(reldestfile, File.readlink(@targetfile), 'relative link') @@ -210,7 +207,7 @@ # Run etch #puts "Running link ownership and permissions test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the link ownership got set correctly # Most systems don't support give-away chown, so this test won't work @@ -245,7 +242,7 @@ # Run etch #puts "Running duplicate dest instructions test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert_equal(@destfile, File.readlink(@targetfile), 'duplicate dest instructions') end @@ -269,7 +266,7 @@ # Run etch #puts "Running contradictory dest instructions test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that the link wasn't created assert(!File.symlink?(@targetfile) && !File.exist?(@targetfile), 'contradictory dest instructions') @@ -298,7 +295,7 @@ # Run etch #puts "Running duplicate script instructions test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert_equal(@destfile, File.readlink(@targetfile), 'duplicate script instructions') end @@ -329,14 +326,13 @@ # Run etch #puts "Running contradictory script instructions test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that the link wasn't created assert(!File.symlink?(@targetfile) && !File.exist?(@targetfile), 'contradictory script instructions') end def teardown - stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/local_requests.rb =================================================================== --- trunk/test/local_requests.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/local_requests.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -4,10 +4,7 @@ # Test etch's handling of local requests # -require 'test/unit' -require 'etchtest' -require 'tempfile' -require 'fileutils' +require File.join(File.dirname(__FILE__), 'etchtest') class EtchLocalRequestsTests < Test::Unit::TestCase include EtchTests @@ -19,7 +16,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port, @pid = start_server(@repodir) + @server = get_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -71,7 +68,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -123,7 +120,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly # Our whitespace in the heredoc above gets added to the generated file, so @@ -133,7 +130,6 @@ end def teardown - stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/nodegroups.rb =================================================================== --- trunk/test/nodegroups.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/nodegroups.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -4,10 +4,7 @@ # Test etch's handling of node groups and the node group hierarchy # -require 'test/unit' -require 'etchtest' -require 'tempfile' -require 'fileutils' +require File.join(File.dirname(__FILE__), 'etchtest') class EtchNodeGroupTests < Test::Unit::TestCase include EtchTests @@ -20,7 +17,7 @@ # Generate a directory for our test repository # Specify that the node should be put into 'testgroup' in nodes.xml @repodir = initialize_repository(['testgroup']) - @port, @pid = start_server(@repodir) + @server = get_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -54,7 +51,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -95,7 +92,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -136,7 +133,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), testname) @@ -180,14 +177,13 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that the file wasn't modified assert_equal(oldsourcecontents, get_file_contents(@targetfile), testname) end def teardown - stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/options.rb =================================================================== --- trunk/test/options.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/options.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -4,10 +4,7 @@ # Test command line options to etch client # -require 'test/unit' -require 'etchtest' -require 'tempfile' -require 'fileutils' +require File.join(File.dirname(__FILE__), 'etchtest') class EtchOptionTests < Test::Unit::TestCase include EtchTests @@ -19,7 +16,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port, @pid = start_server(@repodir) + @server = get_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -64,7 +61,7 @@ # Run etch #puts "Running killswitch test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) assert_equal(origcontents, get_file_contents(@targetfile), 'killswitch') end @@ -102,14 +99,14 @@ # Run etch #puts "Running --dry-run test" - run_etch(@port, @testbase, false, '--dry-run') + run_etch(@server, @testbase, false, '--dry-run') assert_equal(origcontents, get_file_contents(@targetfile), '--dry-run') end def test_help output = nil - IO.popen("ruby ../client/etch --help") do |pipe| + IO.popen("ruby #{CLIENTDIR}/etch --help") do |pipe| output = pipe.readlines end # Make sure at least something resembling help output is there @@ -235,7 +232,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase, false, "#{@targetfile} #{targetfile2} etchtest1 etchtest2") + run_etch(@server, @testbase, false, "#{@targetfile} #{targetfile2} etchtest1 etchtest2") # Verify that only the requested files were created assert_equal(sourcecontents, get_file_contents(@targetfile), testname + ' file 1') @@ -322,7 +319,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase, false, "#{@targetfile} #{targetfile2}") + run_etch(@server, @testbase, false, "#{@targetfile} #{targetfile2}") # Verify that all were created assert_equal(sourcecontents, get_file_contents(@targetfile), testname + ' filesonly file 1') @@ -416,7 +413,7 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase, false, "etchtest1 #{targetfile2}") + run_etch(@server, @testbase, false, "etchtest1 #{targetfile2}") # Verify that all were created assert_equal(origcontents + testname, get_file_contents(cmdtargetfile1), testname + ' cmdandfile cmd 1') @@ -425,7 +422,6 @@ end def teardown - stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/outputcapture.rb =================================================================== --- trunk/test/outputcapture.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/outputcapture.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -4,13 +4,10 @@ # Test output capturing # -require 'test/unit' -require 'etchtest' -require 'tempfile' -require 'fileutils' +require File.join(File.dirname(__FILE__), 'etchtest') require 'timeout' -$: << '../client' -$: << '../server/lib' +$: << EtchTests::CLIENTDIR +$: << File.join(EtchTests::SERVERDIR, 'lib') require 'etchclient' class EtchOutputCaptureTests < Test::Unit::TestCase @@ -23,7 +20,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port, @pid = start_server(@repodir) + @server = get_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -69,13 +66,13 @@ # Run etch #puts "Running '#{testname}' test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Fetch the latest result for this client from the server and verify that # it contains the output from the post command. hostname = Facter['fqdn'].value latest_result_message = '' - Net::HTTP.start('localhost', @port) do |http| + Net::HTTP.start('localhost', @server[:port]) do |http| response = http.get("/results.xml?clients.name=#{hostname}&sort=created_at_reverse") if !response.kind_of?(Net::HTTPSuccess) response.error! @@ -125,7 +122,7 @@ # NOTE: This test is not normally run because the timeout is so long. # Uncomment this run_etch line to run this test. # - #run_etch(@port, @testbase) + #run_etch(@server, @testbase) end rescue Timeout::Error flunk('output capturing did not time out as expected') @@ -133,7 +130,6 @@ end def teardown - stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/scripts.rb =================================================================== --- trunk/test/scripts.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/scripts.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -5,10 +5,7 @@ # creation of links and directories, and control the deletion of files # -require 'test/unit' -require 'etchtest' -require 'tempfile' -require 'fileutils' +require File.join(File.dirname(__FILE__), 'etchtest') class EtchScriptTests < Test::Unit::TestCase include EtchTests @@ -20,7 +17,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port, @pid = start_server(@repodir) + @server = get_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -63,7 +60,7 @@ # Run etch #puts "Running script with syntax error test" - run_etch(@port, @testbase, true) + run_etch(@server, @testbase, true) # Verify that etch didn't do anything to the file assert_equal(before_size, File.stat(@targetfile).size, 'script with syntax error size comparison') @@ -96,7 +93,7 @@ # Run etch #puts "Running script with no output" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that etch didn't do anything to the file assert_equal(before_size, File.stat(@targetfile).size, 'script with no output size comparison') @@ -126,7 +123,7 @@ # Run etch #puts "Running file script test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly correctcontents = '' @@ -167,7 +164,7 @@ # Run etch #puts "Running file source script test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly correctcontents = '' @@ -207,7 +204,7 @@ # Run etch #puts "Running file source script test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly correctcontents = '' @@ -243,7 +240,7 @@ # Run etch #puts "Running link script test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the link was created properly assert_equal(@destfile, File.readlink(@targetfile), 'link script') @@ -274,7 +271,7 @@ # Run etch #puts "Running link script with no output" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that etch didn't do anything to the file assert_equal(before_readlink, File.readlink(@targetfile), 'link script with no output readlink comparison') @@ -301,7 +298,7 @@ # Run etch #puts "Running directory script test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the directory was created assert(File.directory?(@targetfile), 'directory script') @@ -336,7 +333,7 @@ # Run etch #puts "Running directory script with no output" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that etch didn't do anything to the file assert_equal(before_size, File.stat(@targetfile).size, 'directory script with no output size comparison') @@ -364,7 +361,7 @@ # Run etch #puts "Running delete script test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was removed assert(!File.exist?(@targetfile) && !File.symlink?(@targetfile), 'delete script') @@ -401,7 +398,7 @@ # Run etch #puts "Running delete script with no output" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that etch didn't do anything to the file assert_equal(before_size, File.stat(@targetfile).size, 'delete script with no output size comparison') @@ -409,7 +406,6 @@ end def teardown - stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) Modified: trunk/test/transitions.rb =================================================================== --- trunk/test/transitions.rb 2009-11-23 22:04:44 UTC (rev 177) +++ trunk/test/transitions.rb 2009-12-03 23:01:12 UTC (rev 178) @@ -5,10 +5,7 @@ # file, etc.) # -require 'test/unit' -require 'etchtest' -require 'tempfile' -require 'fileutils' +require File.join(File.dirname(__FILE__), 'etchtest') class EtchTransitionTests < Test::Unit::TestCase include EtchTests @@ -20,7 +17,7 @@ # Generate a directory for our test repository @repodir = initialize_repository - @port, @pid = start_server(@repodir) + @server = get_server(@repodir) # Create a directory to use as a working directory for the client @testbase = tempdir @@ -61,7 +58,7 @@ # Run etch #puts "Running file to link test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert_equal(@destfile, File.readlink(@targetfile), 'file to link') @@ -86,7 +83,7 @@ # Run etch #puts "Running file to directory test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert(File.directory?(@targetfile), 'file to directory') end @@ -121,7 +118,7 @@ # Run etch #puts "Running link to file test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), 'link to file') @@ -160,7 +157,7 @@ # Run etch #puts "Running link w/ same contents to file test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), 'link w/ same contents to file') @@ -186,7 +183,7 @@ # Run etch #puts "Running link to directory test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert(File.directory?(@targetfile), 'link to directory') end @@ -222,7 +219,7 @@ # Run etch #puts "Running directory to file test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) # Verify that the file was created properly assert_equal(sourcecontents, get_file_contents(@targetfile), 'directory to file') @@ -249,13 +246,12 @@ # Run etch #puts "Running directory to link test" - run_etch(@port, @testbase) + run_etch(@server, @testbase) assert_equal(@destfile, File.readlink(@targetfile), 'directory to link') end def teardown - stop_server(@pid) remove_repository(@repodir) FileUtils.rm_rf(@testbase) FileUtils.rm_rf(@targetfile) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-11-23 22:04:51
|
Revision: 177 http://etch.svn.sourceforge.net/etch/?rev=177&view=rev Author: jheiss Date: 2009-11-23 22:04:44 +0000 (Mon, 23 Nov 2009) Log Message: ----------- For all *dir options to copy_etch_files if the option is not specified the associated files will not be copied. This allows package targets to more precisely pick the files they want to include. The gem target was the only target not specifying directories and was easily modified to specify what it wants. Remove :installbase option from copy_etch_files, it wasn't being used for anything. Fix tasks to specify proper etcdir. Remove everything related to auto-update cron jobs. It would be very unusual for publicly-released software to operate that way. Leave it up to end users to auto-update the software appropriately for their environment. Modified Paths: -------------- trunk/client/Rakefile trunk/client/etch_cron Added Paths: ----------- trunk/client/postinstall.solaris trunk/client/postremove.solaris Removed Paths: ------------- trunk/client/postinstall trunk/client/postremove Modified: trunk/client/Rakefile =================================================================== --- trunk/client/Rakefile 2009-11-18 06:24:17 UTC (rev 176) +++ trunk/client/Rakefile 2009-11-23 22:04:44 UTC (rev 177) @@ -9,99 +9,91 @@ BUILDROOT = '/var/tmp/etch-client-buildroot' -# Copies the etch client files to destdir. Appropriate subdirectories will be -# composed unless specified via options. +# Copies the etch client files to destdir. If any of the dir options +# are not specified the files that would go in that directory will not +# be copied. # options: # :bindir # :libdir # :etcdir # :mandir -# :crondir (note no default here, crontab will not be copied if not specified) +# :crondir # :ruby (#! lines in scripts will be changed to specified ruby) -# :installbase (base directory where files will end up) def copy_etch_files(destdir, options={}) - bindir = nil if options[:bindir] bindir = File.join(destdir, options[:bindir]) - else - bindir = File.join(destdir, 'bin') - end - mkdir_p(bindir) - binapps = ['etch', 'etch_to_trunk', 'etch_cron_wrapper'] - binapps.each do |binapp| - if options[:ruby] - # Change #! line - File.open(File.join(bindir, binapp), 'w') do |newfile| - File.open(binapp) do |oldfile| - # Modify the first line - firstline = oldfile.gets - # Preserve any options. I.e. #!/usr/bin/ruby -w - shebang, shebangopts = firstline.split(' ', 2) - newfile.puts "#!#{options[:ruby]} #{shebangopts}" - # Then dump in the rest of the file - newfile.write(oldfile.read) + mkdir_p(bindir) + binapps = ['etch', 'etch_to_trunk', 'etch_cron_wrapper'] + binapps.each do |binapp| + if options[:ruby] + # Change #! line + File.open(File.join(bindir, binapp), 'w') do |newfile| + File.open(binapp) do |oldfile| + # Modify the first line + firstline = oldfile.gets + # Preserve any options. I.e. #!/usr/bin/ruby -w + shebang, shebangopts = firstline.split(' ', 2) + newfile.puts "#!#{options[:ruby]} #{shebangopts}" + # Then dump in the rest of the file + newfile.write(oldfile.read) + end end + else + cp(binapp, bindir, :preserve => true) end - else - cp(binapp, bindir, :preserve => true) + chmod(0555, File.join(bindir, binapp)) end - chmod(0555, File.join(bindir, binapp)) end - libdir = nil if options[:libdir] libdir = File.join(destdir, options[:libdir]) - else - libdir = File.join(destdir, 'lib') + mkdir_p(libdir) + + # Substitute ETCHVER into etchclient.rb + # Substitute proper path into CONFIGDIR in etchclient.rb if appropriate + File.open(File.join(libdir, 'etchclient.rb.new'), 'w') do |newfile| + IO.foreach(File.join(libdir, 'etchclient.rb')) do |line| + if line =~ /^\s*VERSION/ + line.sub!(/=.*/, "= '#{ETCHVER}'") + end + if options[:etcdir] && line =~ /^\s*CONFIGDIR/ + line.sub!(/=.*/, "= #{options[:etcdir]}") + end + newfile.write(line) + end + end + chmod(0444, File.join(libdir, 'etchclient.rb')) + + serverlibs = ['etch.rb', 'versiontype.rb'] + serverlibs.each do |serverlib| + cp(File.join('..', 'server', 'lib', serverlib), libdir, :preserve => true) + chmod(0444, File.join(libdir, serverlib)) + end end - mkdir_p(libdir) - clientlibs = ['etchclient.rb'] - clientlibs.each do |clientlib| - cp(clientlib, libdir, :preserve => true) - end - serverlibs = ['etch.rb', 'versiontype.rb'] - serverlibs.each do |serverlib| - cp(File.join('..', 'server', 'lib', serverlib), libdir, :preserve => true) - end - clientlibs + serverlibs.each do |lib| - chmod(0444, File.join(libdir, lib)) - end - mandir = nil if options[:mandir] mandir = File.join(destdir, options[:mandir]) - else - mandir = File.join(destdir, 'man') + man8dir = File.join(mandir, 'man8') + mkdir_p(man8dir) + cp('etch.8', man8dir, :preserve => true) + chmod(0444, File.join(man8dir, 'etch.8')) end - man8dir = File.join(mandir, 'man8') - mkdir_p(man8dir) - cp('etch.8', man8dir, :preserve => true) - chmod(0444, File.join(man8dir, 'etch.8')) - etcdir = nil - # Start by calculating the real etc directory that will be used when the - # package is installed. We need to substitute that path into the library - # later. - realetcdir = nil if options[:etcdir] - realetcdir = options[:etcdir] - else - realetcdir = '/etc' + etcdir = File.join(destdir, options[:etcdir]) + # FIXME: Need to add support for etch.conf to the code + #mkdir_p(etcdir) + #cp('etch.conf', etcdir, :preserve => true) + #chmod(0644, File.join(etcdir, 'etch.conf')) + # All of the supporting config files go into a subdirectory + etcetchdir = File.join(etcdir, 'etch') + mkdir_p(etcetchdir) + etcetchfiles = ['ca.pem', 'dhparams'] + etcetchfiles.each do |etcetchfile| + cp(etcetchfile, etcetchdir, :preserve => true) + chmod(0644, File.join(etcetchdir, etcetchfile)) + end end - # Then compose the etc directory to copy files to - etcdir = File.join(destdir, realetcdir) - # FIXME: Need to add support for etch.conf to the code - #mkdir_p(etcdir) - #cp('etch.conf', etcdir, :preserve => true) - #chmod(0644, File.join(etcdir, 'etch.conf')) - # All of the supporting config files go into a subdirectory - etcetchdir = File.join(etcdir, 'etch') - mkdir_p(etcetchdir) - etcetchfiles = ['ca.pem', 'dhparams'] - etcetchfiles.each do |etcetchfile| - cp(etcetchfile, etcetchdir, :preserve => true) - chmod(0644, File.join(etcetchdir, etcetchfile)) - end if options[:crondir] crondir = File.join(destdir, options[:crondir]) @@ -111,24 +103,6 @@ cp('etch_cron', File.join(crondir, 'etch'), :preserve => true) chmod(0444, File.join(crondir, 'etch')) end - - # Substitute ETCHVER into etchclient.rb - # Substitute proper path into CONFIGDIR in etchclient.rb if appropriate - newetchclient = File.join(libdir, 'etchclient.rb.new') - etchclient = File.join(libdir, 'etchclient.rb') - File.open(newetchclient, 'w') do |newfile| - IO.foreach(etchclient) do |line| - if line =~ /^\s*VERSION/ - line.sub!(/=.*/, "= '#{ETCHVER}'") - end - if options[:installbase] && line =~ /^\s*CONFIGDIR/ - line.sub!(/=.*/, "= #{realetcdir}") - end - newfile.write(line) - end - end - mv(newetchclient, etchclient) - chmod(0444, etchclient) end desc 'Build an etch client RPM on a Red Hat box' @@ -149,11 +123,10 @@ sbindir = File.join('usr', 'sbin') libdir = File.join('usr', 'lib', 'ruby', 'site_ruby', '1.8') mandir = File.join('usr', 'share', 'man') - etcdir = File.join('etc', 'etch') + etcdir = '/etc' crondir = File.join('etc', 'cron.d') copy_etch_files(BUILDROOT, :bindir => sbindir, :libdir => libdir, - :mandir => mandir, :etcdir => etcdir, :crondir => crondir, - :installbase => '/') + :mandir => mandir, :etcdir => etcdir, :crondir => crondir) # # Prep spec file @@ -198,11 +171,10 @@ sbindir = File.join('usr', 'sbin') libdir = File.join('usr', 'local', 'lib', 'site_ruby', '1.8') mandir = File.join('usr', 'share', 'man') - etcdir = File.join('etc', 'etch') + etcdir = '/etc' crondir = File.join('etc', 'cron.d') copy_etch_files(BUILDROOT, :bindir => sbindir, :libdir => libdir, - :mandir => mandir, :etcdir => etcdir, :crondir => crondir, - :installbase => '/') + :mandir => mandir, :etcdir => etcdir, :crondir => crondir) # # Set permissions @@ -236,10 +208,10 @@ sbindir = File.join('usr', 'sbin') libdir = File.join('opt', 'csw', 'lib', 'ruby', 'site_ruby', '1.8') mandir = File.join('usr', 'share', 'man') - etcdir = File.join('etc', 'etch') + etcdir = '/etc' copy_etch_files(BUILDROOT, :bindir => sbindir, :libdir => libdir, :mandir => mandir, :etcdir => etcdir, - :ruby => '/opt/csw/bin/ruby', :installbase => '/') + :ruby => '/opt/csw/bin/ruby') # # Prep packaging files @@ -257,9 +229,9 @@ prototype.puts("i pkginfo=./pkginfo") cp('depend', 'solbuild/depend') prototype.puts("i depend=./depend") - cp('postinstall', 'solbuild/postinstall') + cp('postinstall.solaris', 'solbuild/postinstall') prototype.puts("i postinstall=./postinstall") - cp('postremove', 'solbuild/postremove') + cp('postremove.solaris', 'solbuild/postremove') prototype.puts("i postremove=./postremove") # The tail +2 removes the first line, which is the base directory # and doesn't need to be included in the package. @@ -310,10 +282,10 @@ sbindir = File.join('usr', 'sbin') libdir = File.join('opt', 'csw', 'lib', 'ruby', 'site_ruby', '1.8') mandir = File.join('usr', 'share', 'man') - etcdir = File.join('etc', 'etch') + etcdir = '/etc' copy_etch_files(BUILDROOT, :bindir => sbindir, :libdir => libdir, :mandir => mandir, :etcdir => etcdir, - :ruby => '/usr/local/bin/ruby', :installbase => '/') + :ruby => '/usr/local/bin/ruby') # Since we're using the Sunfreeware ruby but CSW libraries we need to add # the CSW ruby library directory to the search path @@ -346,9 +318,9 @@ prototype.puts("i pkginfo=./pkginfo") cp('depend', 'solbuild/depend') prototype.puts("i depend=./depend") - cp('postinstall', 'solbuild/postinstall') + cp('postinstall.solaris', 'solbuild/postinstall') prototype.puts("i postinstall=./postinstall") - cp('postremove', 'solbuild/postremove') + cp('postremove.solaris', 'solbuild/postremove') prototype.puts("i postremove=./postremove") # The tail +2 removes the first line, which is the base directory # and doesn't need to be included in the package. @@ -394,8 +366,7 @@ :mandir => Config::CONFIG['mandir'], :etcdir => Config::CONFIG['sysconfdir'], # Can't find a better way to get the path to the current ruby - :ruby => File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']), - :installbase => '/') + :ruby => File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])) end desc 'Fetch tarball from sourceforge' @@ -437,10 +408,12 @@ # rm_rf(BUILDROOT) - copy_etch_files(BUILDROOT) + copy_tpkg_files(BUILDROOT, + :bindir => 'bin', + :libdir => 'lib') # - # Prep gemspec + # Prep gemspec (renaming to Rakefile in the process) # File.open(File.join(BUILDROOT, 'Rakefile'), 'w') do |gemspec| IO.foreach('gemspec') do |line| Modified: trunk/client/etch_cron =================================================================== --- trunk/client/etch_cron 2009-11-18 06:24:17 UTC (rev 176) +++ trunk/client/etch_cron 2009-11-23 22:04:44 UTC (rev 177) @@ -8,6 +8,3 @@ MAILTO="" 0 * * * * root /usr/sbin/etch_cron_wrapper -# Make sure the client package stays updated -MAILTO="" -0 0 * * * root yum -d 0 -e 0 -R 30 -y update etch-client Deleted: trunk/client/postinstall =================================================================== --- trunk/client/postinstall 2009-11-18 06:24:17 UTC (rev 176) +++ trunk/client/postinstall 2009-11-23 22:04:44 UTC (rev 177) @@ -1,9 +0,0 @@ -#!/bin/sh - -# Everything about this makes me feel dirty -crontab -l | grep -v etch > /tmp/root_crontab || exit 1 -echo "0 * * * * /usr/sbin/etch_cron_wrapper > /dev/null 2>&1" >> /tmp/root_crontab || exit 1 -echo "0 0 * * * /opt/csw/bin/pkg-get -U > /dev/null 2>&1; /opt/csw/bin/pkg-get -u YPCetch > /dev/null 2>&1" >> /tmp/root_crontab || exit 1 -crontab /tmp/root_crontab -rm /tmp/root_crontab - Copied: trunk/client/postinstall.solaris (from rev 176, trunk/client/postinstall) =================================================================== --- trunk/client/postinstall.solaris (rev 0) +++ trunk/client/postinstall.solaris 2009-11-23 22:04:44 UTC (rev 177) @@ -0,0 +1,8 @@ +#!/bin/sh + +# Everything about this makes me feel dirty +crontab -l | grep -v etch > /tmp/root_crontab || exit 1 +echo "0 * * * * /usr/sbin/etch_cron_wrapper > /dev/null 2>&1" >> /tmp/root_crontab || exit 1 +crontab /tmp/root_crontab +rm /tmp/root_crontab + Deleted: trunk/client/postremove =================================================================== --- trunk/client/postremove 2009-11-18 06:24:17 UTC (rev 176) +++ trunk/client/postremove 2009-11-23 22:04:44 UTC (rev 177) @@ -1,10 +0,0 @@ -#!/bin/sh - -crontab -l | /usr/xpg4/bin/grep -qs etch -if [ $? = 0 ] -then - crontab -l | grep -v etch > /tmp/root_crontab || exit 1 - crontab /tmp/root_crontab - rm /tmp/root_crontab -fi - Copied: trunk/client/postremove.solaris (from rev 176, trunk/client/postremove) =================================================================== --- trunk/client/postremove.solaris (rev 0) +++ trunk/client/postremove.solaris 2009-11-23 22:04:44 UTC (rev 177) @@ -0,0 +1,10 @@ +#!/bin/sh + +crontab -l | /usr/xpg4/bin/grep -qs etch +if [ $? = 0 ] +then + crontab -l | grep -v etch > /tmp/root_crontab || exit 1 + crontab /tmp/root_crontab + rm /tmp/root_crontab +fi + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-11-18 06:24:25
|
Revision: 176 http://etch.svn.sourceforge.net/etch/?rev=176&view=rev Author: jheiss Date: 2009-11-18 06:24:17 +0000 (Wed, 18 Nov 2009) Log Message: ----------- Fix cut-n-paste typo Modified Paths: -------------- trunk/client/Rakefile Modified: trunk/client/Rakefile =================================================================== --- trunk/client/Rakefile 2009-11-18 06:24:01 UTC (rev 175) +++ trunk/client/Rakefile 2009-11-18 06:24:17 UTC (rev 176) @@ -281,7 +281,7 @@ # system("cd solbuild && pkgmk -r #{BUILDROOT} -d $PWD/solbuild") - system("pkgtrans solbuild ../YPCetch-#{ETCHVER}.pkg YPCetch") + system("pkgtrans solbuild ../OSSetch-#{ETCHVER}.pkg OSSetch") # # Cleanup @@ -370,7 +370,7 @@ # system("cd solbuild && pkgmk -r #{BUILDROOT} -d $PWD/solbuild") - system("pkgtrans solbuild ../YPCetch-#{ETCHVER}-sparc.pkg YPCetch") + system("pkgtrans solbuild ../OSSetch-#{ETCHVER}-sparc.pkg OSSetch") # # Cleanup This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-11-18 06:24:07
|
Revision: 175 http://etch.svn.sourceforge.net/etch/?rev=175&view=rev Author: jheiss Date: 2009-11-18 06:24:01 +0000 (Wed, 18 Nov 2009) Log Message: ----------- Add license file Modified Paths: -------------- trunk/README Added Paths: ----------- trunk/LICENSE Added: trunk/LICENSE =================================================================== --- trunk/LICENSE (rev 0) +++ trunk/LICENSE 2009-11-18 06:24:01 UTC (rev 175) @@ -0,0 +1,24 @@ +The MIT License + +etch 1.x Copyright (c) <2003> <Jason Heiss> + +etch 3.x is a derivative work of etch 1.x +Copyright (c) <2008,2009> <YELLOWPAGES.COM LLC> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. Modified: trunk/README =================================================================== --- trunk/README 2009-11-17 00:35:34 UTC (rev 174) +++ trunk/README 2009-11-18 06:24:01 UTC (rev 175) @@ -20,7 +20,7 @@ License ------------------------------------------------------------------------------ -License: MIT (http://www.opensource.org/licenses/mit-license.php) +License: MIT (see LICENSE file) ------------------------------------------------------------------------------ Credits This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-11-17 00:35:43
|
Revision: 174 http://etch.svn.sourceforge.net/etch/?rev=174&view=rev Author: jheiss Date: 2009-11-17 00:35:34 +0000 (Tue, 17 Nov 2009) Log Message: ----------- Re-arrange /etc related directory paths so that we can eventually add support for /etc/etch.conf. Secondary config files remain in /etc/etch or equivalent. Modified Paths: -------------- trunk/client/Rakefile trunk/client/etchclient.rb Modified: trunk/client/Rakefile =================================================================== --- trunk/client/Rakefile 2009-11-17 00:34:28 UTC (rev 173) +++ trunk/client/Rakefile 2009-11-17 00:35:34 UTC (rev 174) @@ -79,18 +79,28 @@ chmod(0444, File.join(man8dir, 'etch.8')) etcdir = nil + # Start by calculating the real etc directory that will be used when the + # package is installed. We need to substitute that path into the library + # later. realetcdir = nil if options[:etcdir] realetcdir = options[:etcdir] else realetcdir = '/etc' end + # Then compose the etc directory to copy files to etcdir = File.join(destdir, realetcdir) - mkdir_p(etcdir) - etcfiles = ['ca.pem', 'dhparams'] - etcfiles.each do |etcfile| - cp(etcfile, etcdir, :preserve => true) - chmod(0644, File.join(etcdir, etcfile)) + # FIXME: Need to add support for etch.conf to the code + #mkdir_p(etcdir) + #cp('etch.conf', etcdir, :preserve => true) + #chmod(0644, File.join(etcdir, 'etch.conf')) + # All of the supporting config files go into a subdirectory + etcetchdir = File.join(etcdir, 'etch') + mkdir_p(etcetchdir) + etcetchfiles = ['ca.pem', 'dhparams'] + etcetchfiles.each do |etcetchfile| + cp(etcetchfile, etcetchdir, :preserve => true) + chmod(0644, File.join(etcetchdir, etcetchfile)) end if options[:crondir] @@ -391,7 +401,7 @@ desc 'Fetch tarball from sourceforge' task :fetch do if !File.exist?(TARBALL) - url = "http://downloads.sourceforge.net/project/etch/etch/#{ETCHVER}/#{TARBALLFILE}?use_mirror=autoselect" + url = "http://downloads.sourceforge.net/project/etch/etch/#{ETCHVER}/#{TARBALLFILE}" puts "Fetching tarball from #{url}" open(url) do |df| open(TARBALL, 'w') do |lf| Modified: trunk/client/etchclient.rb =================================================================== --- trunk/client/etchclient.rb 2009-11-17 00:34:28 UTC (rev 173) +++ trunk/client/etchclient.rb 2009-11-17 00:35:34 UTC (rev 174) @@ -41,7 +41,7 @@ CONFIRM_SKIP = 2 CONFIRM_QUIT = 3 PRIVATE_KEY_PATHS = ["/etc/ssh/ssh_host_rsa_key", "/etc/ssh_host_rsa_key"] - CONFIGDIR = '/etc/etch' + CONFIGDIR = '/etc' # We need these in relation to the output capturing ORIG_STDOUT = STDOUT.dup @@ -141,17 +141,17 @@ http = Net::HTTP.new(@filesuri.host, @filesuri.port) if @filesuri.scheme == "https" # Eliminate the OpenSSL "using default DH parameters" warning - if File.exist?(File.join(CONFIGDIR, 'dhparams')) - dh = OpenSSL::PKey::DH.new(IO.read(File.join(CONFIGDIR, 'dhparams'))) + if File.exist?(File.join(CONFIGDIR, 'etch', 'dhparams')) + dh = OpenSSL::PKey::DH.new(IO.read(File.join(CONFIGDIR, 'etch', 'dhparams'))) Net::HTTP.ssl_context_accessor(:tmp_dh_callback) http.tmp_dh_callback = proc { dh } end http.use_ssl = true - if File.exist?(File.join(CONFIGDIR, 'ca.pem')) - http.ca_file = File.join(CONFIGDIR, 'ca.pem') + if File.exist?(File.join(CONFIGDIR, 'etch', 'ca.pem')) + http.ca_file = File.join(CONFIGDIR, 'etch', 'ca.pem') http.verify_mode = OpenSSL::SSL::VERIFY_PEER - elsif File.directory?(File.join(CONFIGDIR, 'ca')) - http.ca_path = File.join(CONFIGDIR, 'ca') + elsif File.directory?(File.join(CONFIGDIR, 'etch', 'ca')) + http.ca_path = File.join(CONFIGDIR, 'etch', 'ca') http.verify_mode = OpenSSL::SSL::VERIFY_PEER end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-11-17 00:34:35
|
Revision: 173 http://etch.svn.sourceforge.net/etch/?rev=173&view=rev Author: jheiss Date: 2009-11-17 00:34:28 +0000 (Tue, 17 Nov 2009) Log Message: ----------- First pass at making an RPM spec that meets the Fedora packaging guidelines. Added Paths: ----------- trunk/client/etch.spec Added: trunk/client/etch.spec =================================================================== --- trunk/client/etch.spec (rev 0) +++ trunk/client/etch.spec 2009-11-17 00:34:28 UTC (rev 173) @@ -0,0 +1,44 @@ +Name: etch +Version: %VER% +Release: 1%{?dist} +BuildArch: noarch +Summary: A tool for system configuration management +Group: Applications/System +License: MIT +URL: http://etch.sourceforge.net/ +Source0: http://downloads.sourceforge.net/project/etch/etch/%{version}/etch-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +BuildRequires: rubygem-rake +Requires: ruby(abi) = 1.8, facter, rcs + +# Per http://fedoraproject.org/wiki/Packaging:Ruby +%{!?ruby_sitelib: %global ruby_sitelib %(ruby -rrbconfig -e 'puts Config::CONFIG["sitelibdir"] ')} + +%description +A tool for system configuration management, i.e. management of the +configuration files of the operating system and core applications. Easy for a +professional system administrator to start using, yet scalable to large +and/or complex environments. + +%prep +%setup -q + +%build + +%install +rm -rf %{buildroot} +cd client && rake install[%{buildroot}] + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root,-) +%{_sbindir}/* +%{ruby_sitelib}/* +%{_mandir}/man8/* +%config(noreplace) %{_sysconfdir}/* + +%changelog + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-11-17 00:33:35
|
Revision: 172 http://etch.svn.sourceforge.net/etch/?rev=172&view=rev Author: jheiss Date: 2009-11-17 00:33:27 +0000 (Tue, 17 Nov 2009) Log Message: ----------- Fix typo in comment Modified Paths: -------------- trunk/client/etch_cron Modified: trunk/client/etch_cron =================================================================== --- trunk/client/etch_cron 2009-11-17 00:32:59 UTC (rev 171) +++ trunk/client/etch_cron 2009-11-17 00:33:27 UTC (rev 172) @@ -1,6 +1,6 @@ # Run the etch client every hour # If you want to disable etch updates do NOT comment out this cron job. -# Out next client update will just put it back anyway. +# Our next client update will just put it back anyway. # Instead create /var/etch/disable_etch and add a comment as to # why this box shouldn't be getting updates. Etch will notice # that file and abort. disable_etch files with no comment will be This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-11-17 00:33:06
|
Revision: 171 http://etch.svn.sourceforge.net/etch/?rev=171&view=rev Author: jheiss Date: 2009-11-17 00:32:59 +0000 (Tue, 17 Nov 2009) Log Message: ----------- Switch to a more conventional version number scheme of major.minor.patch rather than major.patch. Modified Paths: -------------- Rakefile Modified: Rakefile =================================================================== --- Rakefile 2009-11-16 21:57:29 UTC (rev 170) +++ Rakefile 2009-11-17 00:32:59 UTC (rev 171) @@ -1,4 +1,4 @@ -ETCHVER = '3.13' +ETCHVER = '3.15.0' TAGNAME = "release-#{ETCHVER}" TAGDIR = "tags/#{TAGNAME}" DIST = "etch-#{ETCHVER}" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-11-16 21:57:40
|
Revision: 170 http://etch.svn.sourceforge.net/etch/?rev=170&view=rev Author: jheiss Date: 2009-11-16 21:57:29 +0000 (Mon, 16 Nov 2009) Log Message: ----------- Update URL. Modified Paths: -------------- trunk/README Modified: trunk/README =================================================================== --- trunk/README 2009-11-14 22:17:56 UTC (rev 169) +++ trunk/README 2009-11-16 21:57:29 UTC (rev 170) @@ -5,7 +5,7 @@ Setup ------------------------------------------------------------------------------ -See the GettingStarted page on http://etch.wiki.sourceforge.net/ +See the GettingStarted page on http://etch.sourceforge.net/ ------------------------------------------------------------------------------ Help This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-11-14 22:18:04
|
Revision: 169 http://etch.svn.sourceforge.net/etch/?rev=169&view=rev Author: jheiss Date: 2009-11-14 22:17:56 +0000 (Sat, 14 Nov 2009) Log Message: ----------- Remove old comments Modified Paths: -------------- trunk/client/Portfile Modified: trunk/client/Portfile =================================================================== --- trunk/client/Portfile 2009-11-14 22:08:11 UTC (rev 168) +++ trunk/client/Portfile 2009-11-14 22:17:56 UTC (rev 169) @@ -34,13 +34,6 @@ PortGroup ruby 1.0 -# fetch -# extract -# patch -# configure -# build -# destroot - use_configure no build {} test.run no This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |