-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Included Private ai stack basic sanity test
- Loading branch information
1 parent
6867869
commit d478e33
Showing
1 changed file
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
use Mojo::Base 'publiccloud::basetest'; | ||
use testapi; | ||
use serial_terminal 'select_serial_terminal'; | ||
use publiccloud::utils qw(is_byos registercloudguest register_openstack); | ||
use publiccloud::ssh_interactive 'select_host_console'; | ||
use strict; | ||
use warnings; | ||
use utils; | ||
use publiccloud::utils; | ||
use File::Basename; | ||
|
||
sub install_dependencies { | ||
my ($instance) = @_; | ||
|
||
record_info('Refresh and update'); | ||
$instance->ssh_assert_script_run('sudo zypper ref; sudo zypper -n up', | ||
timeout => 1000); | ||
sleep 90; # Wait for zypper to be available | ||
|
||
install_package($instance, "curl"); | ||
install_package($instance, "docker"); | ||
} | ||
|
||
sub install_package { | ||
my ($instance, $package) = @_; | ||
|
||
record_info("Install $package", | ||
"Install package $package using transactional server and reboot"); | ||
trup_install($package); | ||
|
||
$instance->ssh_assert_script_run("sudo systemctl start $package", | ||
timeout => 100); | ||
$instance->ssh_assert_script_run("sudo systemctl enable $package", | ||
timeout => 100); | ||
$instance->ssh_assert_script_run("sudo systemctl status $package", | ||
timeout => 100); | ||
record_info("Installed $package"); | ||
} | ||
|
||
sub install_rke2 { | ||
my ($instance, $ins_rke2) = @_; | ||
|
||
$instance->ssh_assert_script_run("curl -sfL $ins_rke2 | sh", | ||
timeout => 1000); | ||
$instance->ssh_assert_script_run('sudo systemctl enable rke2-server', | ||
timeout => 100); | ||
$instance->ssh_assert_script_run('sudo systemctl start rke2-server', | ||
timeout => 100); | ||
$instance->ssh_assert_script_run('sudo systemctl status rke2-server', | ||
timeout => 100); | ||
record_info('Installed RKE2'); | ||
} | ||
|
||
sub install_kubectl { | ||
my ($instance, $ins_kubectl) = @_; | ||
|
||
$instance->ssh_assert_script_run("curl -LO $ins_kubectl", | ||
timeout => 1000); | ||
$instance->ssh_assert_script_run('chmod +x ./kubectl', timeout => 100); | ||
$instance->ssh_assert_script_run( | ||
'sudo mv ./kubectl /usr/local/bin/kubectl', | ||
timeout => 100); | ||
$instance->ssh_assert_script_run('kubectl version --client', | ||
timeout => 100); | ||
record_info('RKE2 setup is complete'); | ||
} | ||
|
||
sub install_helm { | ||
my ($instance, $ins_helm) = @_; | ||
|
||
$instance->ssh_assert_script_run("curl $ins_helm | bash", | ||
timeout => 1000); | ||
record_info('Helm private-ai-chart install complete'); | ||
} | ||
|
||
sub run { | ||
my ($self, $args) = @_; | ||
|
||
# Download unpublished DMS package and install RPM | ||
my $ins_rke2 = get_var('RKE2_URL'); | ||
my $ins_kubectl = get_var('KUBECTL_URL'); | ||
my $ins_helm = get_var('HELM_URL'); | ||
|
||
# Create AWS instance | ||
my $provider; | ||
my $instance; | ||
select_host_console(); | ||
|
||
my $aws_ai_test = | ||
get_var('PUBLIC_CLOUD_INSTANCE_FOR_AWS_AI', 'basic_sanity'); | ||
if ($aws_ai_test) { | ||
$instance = $self->{my_instance} = $args->{my_instance}; | ||
$provider = $self->{provider} = | ||
$args->{my_provider}; # Required for cleanup | ||
} | ||
else { | ||
$provider = $self->{provider} = | ||
$self->provider_factory(); # Required for cleanup | ||
$instance = $self->{my_instance} = $provider->create_instance( | ||
check_guestregister => is_openstack ? 0 : 1); | ||
} | ||
|
||
registercloudguest($instance) if is_byos(); | ||
registercloudguest($instance) if (is_byos() && !$aws_ai_test); | ||
|
||
# Install dependencies, RKE2, HELM, and REPOs | ||
install_dependencies($instance); | ||
install_rke2($instance, $ins_rke2); | ||
install_kubectl($instance, $ins_kubectl); | ||
install_helm($instance, $ins_helm); | ||
} | ||
|
||
1; |