Skip to content

Commit

Permalink
tests: remove expect uses from the server container
Browse files Browse the repository at this point in the history
In order to remove the repositories from the container image the
testsuite needs to stop relying on sumaform to add any package like
expect.
  • Loading branch information
cbosdo committed Jan 22, 2025
1 parent 52eea0e commit 4aae138
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
4 changes: 1 addition & 3 deletions testsuite/dockerfiles/server-all-in-one-dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ RUN zypper -n --gpg-auto-import-keys ref && \
servletapi5 \
cpio \
spacecmd \
expect \
prometheus \
wget && \
prometheus && \
zypper addrepo --no-gpgcheck obs://systemsmanagement:Uyuni:Utils systemsmanagement:uyuni:utils && \
zypper -n install obs-to-maven yarn && \
zypper clean -a
Expand Down
6 changes: 4 additions & 2 deletions testsuite/features/step_definitions/command_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,8 @@
success = file_inject(get_target('server'), source, dest)
raise ScriptError, 'File injection in server failed' unless success

get_target('server').run("expect -f /tmp/#{file} #{$reportdb_ro_user}")
node = get_target('server')
node.run_local("expect -f /tmp/#{file} #{$reportdb_ro_user} #{node.has_mgrctl}")
end

Then(/^I should see the read-only user listed on the ReportDB user accounts$/) do
Expand All @@ -1404,7 +1405,8 @@
success = file_inject(get_target('server'), source, dest)
raise ScriptError, 'File injection in server failed' unless success

get_target('server').run("expect -f /tmp/#{file} #{$reportdb_ro_user}")
node = get_target('server')
node.run_local("expect -f /tmp/#{file} #{$reportdb_ro_user} #{node.has_mgrctl}")
end

Then(/^I shouldn't see the read-only user listed on the ReportDB user accounts$/) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
raise ScriptError, 'File injection failed' unless success

system_name = get_system_name(host)
output, = target.run("sed -i '/^set timeout /c\\set timeout #{DEFAULT_TIMEOUT}' /tmp/#{boostrap_script} && expect -f /tmp/#{boostrap_script} #{system_name}", verbose: true)
output, = target.run_local("sed -i '/^set timeout /c\\set timeout #{DEFAULT_TIMEOUT}' /tmp/#{boostrap_script} && expect -f /tmp/#{boostrap_script} #{system_name} #{target.has_mgrctl}", verbose: true)
unless output.include? '-bootstrap complete-'
log output.encode('utf-8', invalid: :replace, undef: :replace, replace: '_')
raise ScriptError, 'Bootstrap didn\'t finish properly'
Expand Down
14 changes: 12 additions & 2 deletions testsuite/features/upload_files/bootstrap-general.exp
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
set address [lindex $argv 0]
set mgrctl [lindex $argv 1]

spawn /usr/bin/scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /srv/www/htdocs/pub/bootstrap/bootstrap.sh root@$address:/root/bootstrap.sh
if { $mgrctl } {
spawn mgrctl exec -ti -- /usr/bin/scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /srv/www/htdocs/pub/bootstrap/bootstrap.sh root@$address:/root/bootstrap.sh
} else {
spawn /usr/bin/scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /srv/www/htdocs/pub/bootstrap/bootstrap.sh root@$address:/root/bootstrap.sh

}
expect {
"*?assword:*" { send "linux\r"; interact }
eof { exit }
}

spawn /usr/bin/ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $address
if { $mgrctl } {
spawn mgrctl exec -ti -- /usr/bin/ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $address
} else {
spawn /usr/bin/ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $address
}
match_max 1000000
expect "*?assword:*"
send -- "linux\r"
Expand Down
7 changes: 6 additions & 1 deletion testsuite/features/upload_files/create_user_reportdb.exp
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
set user [lindex $argv 0]
set mgrctl [lindex $argv 1]

spawn /usr/bin/uyuni-setup-reportdb-user
if { $mgrctl } {
spawn mgrctl exec -ti -- /usr/bin/uyuni-setup-reportdb-user
} else {
spawn /usr/bin/uyuni-setup-reportdb-user
}
match_max 100000
expect -exact "Report DB Name is: reportdb\r
\[a\]dd/\[m\]odify/\[d\]elete user (case insensitive). Default is \[m\]: "
Expand Down
7 changes: 6 additions & 1 deletion testsuite/features/upload_files/delete_user_reportdb.exp
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
set user [lindex $argv 0]
set mgrctl [lindex $argv 1]

spawn /usr/bin/uyuni-setup-reportdb-user
if { $mgrctl } {
spawn mgrctl exec -ti -- /usr/bin/uyuni-setup-reportdb-user
} else {
spawn /usr/bin/uyuni-setup-reportdb-user
}
match_max 100000
expect -exact "Report DB Name is: reportdb\r
\[a\]dd/\[m\]odify/\[d\]elete user (case insensitive). Default is \[m\]: "
Expand Down

0 comments on commit 4aae138

Please sign in to comment.