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

Upgrade mgrpxy tool before installing the containerized proxy. #9540

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Feature: Setup containerized proxy
Scenario: Wait until the proxy host appears
When I wait until onboarding is completed for "proxy"

Scenario: Upgrade mgrpxy tool
Then I upgrade "proxy" with the last "mgrpxy" version
maximenoel8 marked this conversation as resolved.
Show resolved Hide resolved
And I reboot the "proxy" minion through the web UI
maximenoel8 marked this conversation as resolved.
Show resolved Hide resolved

Scenario: Generate containerized proxy configuration
When I generate the configuration "/tmp/proxy_container_config.tar.gz" of containerized proxy on the server
And I copy the configuration "/tmp/proxy_container_config.tar.gz" of containerized proxy from the server to the proxy
Expand Down
15 changes: 15 additions & 0 deletions testsuite/features/step_definitions/command_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1769,3 +1769,18 @@
occurences = count.to_i
raise "The word #{word} occured #{occurences} times, which is more more than #{threshold} times in file #{path}" if occurences > threshold
end

Then(/^I upgrade "([^"]*)" with the last "([^"]*)" version$/) do |host, package|
system_name = get_system_name(host)
last_event_id = get_last_event_id(system_name)
trigger_upgrade(system_name, package)
repeat_until_timeout(timeout: 300, message: 'Waiting for the new event to complete') do
current_events = fetch_event_history(system_name)

# Find the event with the highest ID (newest event)
new_event = current_events.max_by { |event| event[:id] }

# Check if there is a new event and its status is "Completed"
break if new_event && new_event[:id] > last_event_id && new_event[:status] == 'Completed' && new_event[:completed]
end
end
50 changes: 50 additions & 0 deletions testsuite/features/support/commonlib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -751,3 +751,53 @@ def api_unlock
file.flock(File::LOCK_UN)
end
end

# Function to fetch the current list of events
#
# @param hostname String The hostname of the system from requested
def fetch_event_history(hostname)
output, _code = get_target('server').run("spacecmd -u admin -p admin system_listeventhistory #{hostname}", check_errors: true)
events = []
current_event = {}

output.split("\n").each do |line|
case line
when /^Id:\s+(\d+)$/
current_event[:id] = Regexp.last_match(1).to_i
when /^History type:\s+(.+)$/
current_event[:history_type] = Regexp.last_match(1)
when /^Status:\s+(.+)$/
current_event[:status] = Regexp.last_match(1)
when /^Completed:\s+(.+)$/
begin
current_event[:completed] = Time.parse(Regexp.last_match(1))
rescue ArgumentError
current_event[:completed] = nil
end
end

if current_event.key?(:id) && current_event.key?(:completed)
events << current_event
current_event = {}
end
end

events
end

# Function to get the highest event ID (latest event)
#
# @param hostname String The hostname of the system from requested
def get_last_event_id(hostname)
events = fetch_event_history(hostname)
last_event = events.max_by { |event| event[:id] }
last_event ? last_event[:id] : nil
end
maximenoel8 marked this conversation as resolved.
Show resolved Hide resolved

# Function to trigger the upgrade command
#
# @param hostname String The hostname of the system from requested
# @param package String The package name where it will trigger an upgrade
def trigger_upgrade(hostname, package)
get_target('server').run("spacecmd -u admin -p admin system_upgradepackage #{hostname} #{package} -y", check_errors: true)
maximenoel8 marked this conversation as resolved.
Show resolved Hide resolved
end
Loading