Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add appveyor and Windows test #53

Merged
merged 5 commits into from
Jan 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ namespace :test do
sh('sh', '-c', "cd #{path} && config=test-runner.yaml ruby -I ../../lib docker_test.rb tests/*")
end

task :winrm do
path = File.join(File.dirname(__FILE__), 'test', 'winrm')
sh('sh', '-c', "cd #{path} && ruby windows.rb")
end

task :vm do
concurrency = ENV['CONCURRENCY'] || 4
path = File.join(File.dirname(__FILE__), 'test', 'integration')
Expand Down
48 changes: 48 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: "master-{build}"

os: Windows Server 2012 R2
platform:
- x64

environment:
winrm_user: test_user
winrm_pass: Pass@word1

matrix:
- ruby_version: "21"
train_target: winrm://test_user@localhost:5985

- ruby_version: "21"
train_ssl: true
train_target: winrm://test_user@localhost:5986

clone_folder: c:\projects\train
clone_depth: 1

cache:
- C:\Ruby21\bin\gem

install:
- systeminfo
- ps: net user /add $env:winrm_user $env:winrm_pass
- ps: net localgroup administrators $env:winrm_user /add
- ps: $env:winrm_cert = (New-SelfSignedCertificate -DnsName localhost -CertStoreLocation cert:\localmachine\my).Thumbprint
- ps: winrm create winrm/config/Listener?Address=*+Transport=HTTPS "@{Hostname=`"localhost`";CertificateThumbprint=`"$($env:winrm_cert)`"}"
- ps: winrm set winrm/config/client/auth '@{Basic="true"}'
- ps: winrm set winrm/config/service/auth '@{Basic="true"}'
- ps: winrm set winrm/config/service '@{AllowUnencrypted="true"}'
- ps: $env:PATH="C:\Ruby$env:ruby_version\bin;$env:PATH"
- ps: Write-Host $env:PATH
- gem install bundler --quiet --no-ri --no-rdoc
- gem update --system 2.4.5
- ruby --version
- gem --version
- bundler --version
- ruby -r rubygems -e "p Gem.path"

build_script:
- bundle install --without integration tools

test_script:
- SET SPEC_OPTS=--format progress
- bundle exec rake test:winrm
62 changes: 62 additions & 0 deletions test/winrm/windows.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env ruby
# encoding: utf-8
#
# Author:: Christoph Hartmann (<chris@lollyrock.com>)

require 'train'
require 'json'

# expects the following env variables
# export winrm_user=test_user
# export winrm_pass=Pass@word1
# export train_target='winrm://test_user@localhost:5985'
# export train_ssl='true'

def get_os(backend, opts = {})
# resolve configuration
target_config = Train.target_config(opts)
puts "Use the following config: #{target_config}"

# initialize train
train = Train.create(backend, target_config)

# start or reuse a connection
conn = train.connection
os = conn.os

# get OS info
conf = {
name: os[:name],
family: os[:family],
release: os[:release],
arch: os[:arch],
}

# close the connection
conn.close
conf
end

def compare_hash(value, cmp)
value == cmp
end

# check local
local = get_os('local')
puts "Detected the following OS (local): #{local}"

# winrm over http
winrm = get_os('winrm', {
target: ENV['train_target'],
password: ENV['winrm_pass'],
ssl: ENV['train_ssl'],
self_signed: true,
})
puts "Detected the following OS (remote): #{winrm}"

# compare values
cmp = {:name=>nil, :family=>"windows", :release=>"Server 2012 R2", :arch=>nil}
if !compare_hash(local, cmp) || !compare_hash(winrm, cmp)
puts "Expected OS: #{cmp}"
exit 1
end