-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest-g5k-checks
executable file
·42 lines (37 loc) · 1.42 KB
/
test-g5k-checks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/ruby
# This is a script to test g5k-checks on a node, executed from a gitlab-ci runner
gem 'ruby-cute', ">=0.11"
require 'cute'
require 'net/scp'
require 'pp'
require 'logger'
if ARGV.length < 1
puts "Too few arguments (please provide which distro you want to test)"
exit false
end
g5k = Cute::G5K::API.new
logger = Logger.new(STDOUT)
STDERR.reopen(STDOUT)
STDOUT.sync = true
logger.info("Dumping CI_* ENV variables:")
puts ENV.to_a.select { |e| e[0] =~ /^CI_/ }.map { |e| e.join(' ') }.join("\n")
logger.info("Reserving node...")
job = g5k.reserve(:site => 'nancy', :queue => 'production', :nodes => 1, :walltime => '0:15', :type => :allow_classic_ssh, :wait => true, :name => 'gitlab g5k-checks')
logger.info("Job #{job['uid']} created.")
node = job['assigned_nodes'].first
logger.info("Running on: #{node}")
logger.info("Running sudo-g5k")
ssh = Net::SSH::start(node, g5k.g5k_user, {:keys => ['/home/gitlab-runner/.ssh/id_rsa']})
ssh.exec3!("sudo-g5k")
scp = Net::SCP.start(node, g5k.g5k_user)
gl = Dir::glob("#{ARGV[0]}/g5k-checks_*_amd64.deb")
if gl.length != 1
raise "no file to upload"
end
logger.info("Copying and installing artifact")
scp.upload!(gl.first, "/tmp/g5k-checks.deb")
ssh.exec3!('sudo apt install -y -o Dpkg::Options::="--force-confnew" --allow-downgrades /tmp/g5k-checks.deb')
logger.info("Running g5k-checks")
ssh.exec3!('sudo g5k-checks --remove-tests="User used sudo-g5k" -v')
ssh.close
g5k.release(job)