Skip to content

Commit

Permalink
feature: running windows tests in session 1
Browse files Browse the repository at this point in the history
  • Loading branch information
ireznice committed Jul 7, 2015
1 parent 3d0e640 commit 1e62f55
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 6 deletions.
74 changes: 74 additions & 0 deletions lib/travis/worker/job/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,80 @@ def run_script
exit $(cat ~/build.sh.exit)
EOF
session.exec("GUEST_API_URL=%s bash ~/wrapper.sh" % guest_api_url) { exit_exec? }
elsif payload[:config][:os] == 'windows' && Hash === payload[:config][:windows] && payload[:config][:windows][:run_in_session1]
puts "++++++-----------------GOT ============================";
session.upload_file("~/buildWrapper.sh", <<EOF % [Travis::Worker::VirtualMachine.config[:username], Travis::Worker::VirtualMachine.config[:password]])
#!/bin/bash
curl -X POST -d '{"message":"Interactive runner started"}' $GUEST_API_URL/logs
WIN_HOME_DIR=`cygpath -adw ~`
WIN_HOME_DIR2=`echo $WIN_HOME_DIR | sed s'|\\\\\\\\|\\\\\\\\\\\\\\\\|g'`\\\\runPS.ps1
/cygdrive/c/Tools/PsExec.exe -u "%s" -p "%s" -acceptEula -h -i 1 powershell -file "$WIN_HOME_DIR2"
if [ -f ~/build.sh.exit ] ; then
exit $(cat ~/build.sh.exit)
else
echo "Runner script was probably not executed, returning 1";
exit 1;
fi
EOF

session.upload_file("~/runPS.ps1", <<EOF % guest_api_url)
$GUESTAPI="%s";
[System.Reflection.Assembly]::LoadWithPartialName("System.Net");
[System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions");
$ser = New-Object System.Web.Script.Serialization.JavaScriptSerializer;
$json = $ser.serialize(@{message= "`n`nMinttyRunner started`n`n"});
$bytes = [System.Text.Encoding]::ASCII.GetBytes($json);
$cl = new-object System.Net.WebClient;
$cl.uploaddata("$GUESTAPI/logs", $bytes);
$p = new-object system.diagnostics.process;
$p.StartInfo.UseShellExecute = $false;
$p.StartInfo.CreateNoWindow = $true;
$p.StartInfo.FileName = "c:\\cygwin\\bin\\mintty.exe";
$p.StartInfo.Arguments = "-l - --exec /bin/bash -l -c 'exec /bin/bash ~/build.sh'";
$p.StartInfo.RedirectStandardError = $p.StartInfo.RedirectStandardOutput = $true;
$block = {
try
{
$hash = @{message = $event.SourceEventArgs.Data};
$json = $ser.Serialize($hash);
$cl = new-object System.Net.WebClient;
$bytes = [System.Text.Encoding]::ASCII.GetBytes($json);
$cl.uploaddata("$GUESTAPI/logs", $bytes);
}
catch
{
}
}
Register-ObjectEvent -InputObject $p -EventName OutputDataReceived -Action $block -SourceIdentifier OutputReader | Out-Null;
$p.Start() | out-null;
$p.BeginOutputReadLine();
while(-not $p.HasExited)
{
sleep 1;
};
if($p.StandardError -ne $null)
{
$p.StandardError.ReadToEnd()|Out-Host;
};
Unregister-Event -SourceIdentifier OutputReader;
$p.WaitForExit();
$json = $ser.serialize(@{message= "`n`nMinttyRunner finished`n`n"});
$bytes = [System.Text.Encoding]::ASCII.GetBytes($json);
$cl = new-object System.Net.WebClient;
$cl.uploaddata("$GUESTAPI/logs", $bytes);
exit $($p.ExitCode);
EOF
session.exec("GUEST_API_URL=%s bash --login ~/buildWrapper.sh" % guest_api_url) { exit_exec? }
else
session.exec("GUEST_API_URL=%s bash --login ~/build.sh" % guest_api_url) { exit_exec? }
end
Expand Down
5 changes: 5 additions & 0 deletions lib/travis/worker/virtual_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ def self.provider
self.const_get(provider_name)
end
end

def self.config
provider_name = Travis::Worker.config.vms.provider
Travis::Worker.config.send(provider_name.to_sym)
end
end
end
end
9 changes: 3 additions & 6 deletions lib/travis/worker/virtual_machine/soap_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def initialize(name)

def prepare
info "soap API adapter prepared"
@client = Savon.client(client_config)
end

def sandboxed(opts = {})
Expand Down Expand Up @@ -121,18 +122,14 @@ def client_config
res
end

def client
@client ||= Savon.client(client_config)
end

def template_name(opts)
if soap_config.image_override
soap_config.image_override
else
raise "Could not construct templateName, dist field must not be empty" unless opts[:dist]

[ soap_config.template_name_prefix,
opts[:dist],
[ soap_config.template_name_prefix,
opts[:dist],
opts[:group]
].select(&:present?).join('_')
end
Expand Down

0 comments on commit 1e62f55

Please sign in to comment.