Skip to content

Commit

Permalink
AISTACK_BASIC test
Browse files Browse the repository at this point in the history
  • Loading branch information
yarunachalam committed Oct 18, 2024
1 parent bc6ff4d commit 45bf5eb
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/main_micro_alp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ sub load_slem_on_pc_tests {
} elsif (get_var('PUBLIC_CLOUD_UPLOAD_IMG')) {
loadtest("boot/boot_to_desktop");
loadtest("publiccloud/upload_image");
# AISTACK test verification
} elsif (get_var('PUBLIC_CLOUD_AISTACK')) {
loadtest("boot/boot_to_desktop");
loadtest("publiccloud/upload_image");
loadtest('publiccloud/aistack_basic', run_args => $args);
} else {
# SLEM basic test
loadtest("boot/boot_to_desktop");
Expand All @@ -321,10 +326,8 @@ sub load_slem_on_pc_tests {
$run_args->{runtime} = $_;
load_container_engine_test($run_args);
}

loadtest("publiccloud/ssh_interactive_end", run_args => $args);
}
else {
} else {
loadtest "publiccloud/check_services", run_args => $args;
loadtest("publiccloud/slem_basic", run_args => $args);
}
Expand Down
164 changes: 164 additions & 0 deletions tests/publiccloud/aistack_basic.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# SUSE's openQA tests
#
# Copyright 2022 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Basic aistack test

# Summary: This test performs the following actions
# - Create a VM in EC2 using SLE-Micro-6-0-BYOS.x86_64-1.0.0-EC2-Build1.36.raw.xz
# - Install the required dependencies to install the aistack helm chart and containers
# - Test access to OpenWebUI and run integration tests with Ollama and MilvusDB
# Maintainer: Yogalakshmi Arunachalam <[email protected]>
#

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;
use version_utils;
use Data::Dumper;

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 create_aistack {
my ($instance, $rke2_url, $kubectl_url, $helm_url) = @_;

# Install dependencies
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");

# Install RKE2
$instance->ssh_assert_script_run("curl -sfL $rke2_url | 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');

# Install kubectl
$instance->ssh_assert_script_run("curl -LO $kubectl_url",
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('kubectl setup complete');

# Install Helm
$instance->ssh_assert_script_run("curl $helm_url | bash",
timeout => 1000);
record_info('Helm installation complete');
}

sub run {
my ($self, $args) = @_;

# Required tools
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;

#credentials from openwebui
#my $admin_username = get_var('OPENWEBUI_ADMIN');
#my $admin_password = get_var('OPENWEBUI_PASSWD');
#my $openwebui_hostname = get_var('OPENWEBUI_HOSTNAME');

select_host_console();
record_info("DEBUG", "Args passed: " . Dumper($args));
my $aws_ai_test =
get_var('PUBLIC_CLOUD_INSTANCE_FOR_AWS_AI', 'basic_sanity');
record_info("DEBUG", "Value of PUBLIC_CLOUD_INSTANCE_FOR_AWS_AI: $aws_ai_test");
if ($aws_ai_test) {
$instance = $self->{my_instance} = $args->{my_instance};
$provider = $self->{provider} =
$args->{my_provider}; # Required for cleanup
record_info("DEBUG", "my_instance from args: " . (defined($args->{my_instance}) ? $args->{my_instance} : "undefined"));
record_info("DEBUG", "my_provider from args: " . (defined($args->{my_provider}) ? $args->{my_provider} : "undefined"));
}
else {
$provider = $self->{provider} =
$self->provider_factory(); # Required for cleanup
record_info("DEBUG", "Provider created: " . (defined($provider) ? "defined" : "undefined"));
record_info("DEBUG", "Provider factory output: " . Dumper($provider));
$instance = $self->{my_instance} = $provider->create_instance(
check_guestregister => is_openstack ? 0 : 1);
record_info("DEBUG", "Instance created: " . (defined($instance) ? "defined" : "undefined"));
}

# Debug statements
if (defined($instance)) {
record_info("DEBUG", "Instance is defined: " . $instance);
} else {
record_info("DEBUG", "Instance is undefined after assignment.");
}

if (defined($provider)) {
record_info("DEBUG", "Provider is defined: " . $provider);
} else {
record_info("DEBUG", "Provider is undefined after assignment.");
}

if (is_byos()) {
registercloudguest($instance);
record_info("DEBUG", "Called registercloudguest for BYOS with instance: " . $instance);
}

if (is_byos() && !$aws_ai_test) {
registercloudguest($instance);
record_info("DEBUG", "Called registercloudguest for BYOS with instance (non-AWS AI): " . $instance);
}

# registercloudguest($instance) if is_byos();
# registercloudguest($instance) if (is_byos() && !$aws_ai_test);


# Create AI stack
create_aistack($instance, $ins_rke2, $ins_kubectl, $ins_helm);

# Validate OpenWebUI
#validate_openwebui($admin_username, $admin_password, $openwebui_hostname);
# Verify Ollama api endpoint
#verify_api_endpoint();
# Milvus DB Test
#milvus_db_test();
# Milvus DB Test
#milvus_db_test();
# OpenWebUI Integration test
#test_openwebui_interaction();
}

1;

0 comments on commit 45bf5eb

Please sign in to comment.