-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ilja Bobkevic
committed
Jul 8, 2015
1 parent
1c54c0c
commit 5f78a24
Showing
9 changed files
with
208 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- encoding: utf-8 -*- | ||
# | ||
# Copyright 2015 North Development AB | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
language: ruby | ||
rvm: | ||
- 1.9.3 | ||
- 2.0.0 | ||
|
||
script: | ||
- bundle exec rake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- encoding: utf-8 -*- | ||
# | ||
# Copyright 2015 North Development AB | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
source 'https://rubygems.org' | ||
|
||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,23 @@ | ||
# kitchen-transport-rsync | ||
Test Kitchen transport Rsync | ||
|
||
[![Build Status](https://api.travis-ci.org/unibet/kitchen-transport-rsync.svg)](https://travis-ci.org/unibet/kitchen-transport-rsync) | ||
[![Gem Version](https://badge.fury.io/rb/kitchen-transport-rsync.svg)](http://badge.fury.io/rb/kitchen-transport-rsync) | ||
|
||
This transport is based on rsync over ssh providing dramatic performance improvements. | ||
It will only work with TK 1.4 and rsync has to be available in the PATH on both local and remote end points. | ||
|
||
Only passwordless (using ssh key pair) communication is supported at the moment. | ||
|
||
## Recommended **.kitchen.yml** snippet to activate Rsync transport | ||
|
||
``` | ||
transport: | ||
name: rsync | ||
ssh_key: ~/.vagrant.d/insecure_private_key | ||
username: vagrant | ||
``` | ||
|
||
## Gemfile | ||
``` | ||
gem 'kitchen-transport-rsync' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- encoding: utf-8 -*- | ||
# | ||
# Copyright 2015 North Development AB | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
task :default => [:syntax_ruby] | ||
|
||
task :syntax_ruby do | ||
Dir['**/*.rb'].each do |f| | ||
system("ruby -Ku -c #{f}") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- encoding: utf-8 -*- | ||
# | ||
# Copyright 2015 North Development AB | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
$:.push File.expand_path('../lib', __FILE__) | ||
|
||
require 'kitchen-transport-rsync/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = 'kitchen-transport-rsync' | ||
spec.version = Kitchen::Transport::Rsync::VERSION | ||
spec.authors = 'Ilja Bobkevic' | ||
spec.email = '[email protected]' | ||
spec.description = 'Additional Test kitchen transport using rsync' | ||
spec.summary = spec.description | ||
spec.homepage = 'https://github.com/unibet/kitchen-transport-rsync' | ||
spec.license = 'Apache 2' | ||
|
||
spec.files = `git ls-files`.split($/) | ||
spec.executables = [] | ||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) | ||
spec.require_paths = %w(lib) | ||
|
||
spec.add_dependency 'test-kitchen', '~> 1.4' | ||
spec.add_development_dependency 'rake', '~> 10.4' | ||
spec.add_development_dependency 'rspec', '~> 3.3' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- encoding: utf-8 -*- | ||
# | ||
# Copyright 2015 North Development AB | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
module Kitchen | ||
module Transport | ||
module Rsync | ||
VERSION = '0.1.0' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# | ||
# Author:: Ilja Bobkevic <[email protected]> | ||
# | ||
# Copyright 2015, North Development AB | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
require 'kitchen/transport/ssh' | ||
|
||
module Kitchen | ||
module Transport | ||
class Rsync < Ssh | ||
|
||
def create_new_connection(options, &block) | ||
if @connection | ||
logger.debug("[SSH] shutting previous connection #{@connection}") | ||
@connection.close | ||
end | ||
|
||
@connection_options = options | ||
@connection = self.class::Connection.new(options, &block) | ||
end | ||
|
||
class Connection < Ssh::Connection | ||
def upload(locals, remote) | ||
Array(locals).each do |local| | ||
full_remote = File.join(remote, File.basename(local)) | ||
recursive = File.directory?(local) | ||
execute("mkdir -p #{full_remote}") if recursive | ||
time = Benchmark.realtime do | ||
ssh_command = [login_command.command, login_command.arguments].flatten.join(' ') | ||
sync_command = "rsync -e '#{ssh_command}' -a#{@logger.debug? ? 'v' : ''}z #{local} #{@session.options[:user]}@#{@session.host}:#{remote}" | ||
@logger.debug("[RSYNC] Running rsync command: #{sync_command}") | ||
system(sync_command) | ||
end | ||
logger.info("[RSYNC] Time taken to upload #{local} to #{self}:#{full_remote}: %.2f sec" % time) | ||
end | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |