Skip to content

Commit

Permalink
Included Private ai stack basic sanity test
Browse files Browse the repository at this point in the history
  • Loading branch information
yarunachalam committed Oct 18, 2024
1 parent 6867869 commit 9ac367d
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/main_publiccloud.pm
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ sub load_publiccloud_tests {
load_publiccloud_download_repos();
} elsif (get_var('PUBLIC_CLOUD_QAM')) {
load_maintenance_publiccloud_tests();
} elsif (get_var('PUBLIC_CLOUD_AISTACK')) {
my $args = OpenQA::Test::RunArgs->new();
loadtest('publiccloud/upload_image', run_args => $args);
loadtest('publiccloud/aistack_basic', run_args => $args);
} else {
load_latest_publiccloud_tests();
}
Expand Down
10 changes: 8 additions & 2 deletions lib/publiccloud/ec2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@ sub find_img {
my ($self, $name) = @_;

$name = $self->prefix . '-' . $name;

record_info('DEBUG', "Searching for image with name: $name");
my $out = script_output("aws ec2 describe-images --filters 'Name=name,Values=$name'");
record_info('DEBUG', "Raw output from AWS EC2 describe-images: $out");
if ($out =~ /"ImageId":\s+"([^"]+)"/) {
return $1;
my $image_id = $1;
# Log the found image ID
record_info('DEBUG', "Found image ID: $image_id");
return $image_id;
# return $1;
}
record_info('DEBUG', "No image found for name: $name");
return;
}

Expand Down
17 changes: 16 additions & 1 deletion lib/publiccloud/provider.pm
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Retrieves the image-id by given image C<name>.
=cut

sub find_img {
record_info('DEBUG', "find_image is not implemented");
die('find_image() isn\'t implemented');
}

Expand Down Expand Up @@ -294,7 +295,16 @@ sub get_image_id {
return $self->{image_cache}->{$img_name} if ($self->{image_cache}->{$img_name});

my $image_id = $self->find_img($img_name);
die("Image $img_name is not available in the cloud provider") unless ($image_id);
record_info('DEBUG', "Searching for image: $img_name");
unless ($image_id) {
# Log a message if the image ID is not found
record_info('ERROR', "Image $img_name is not available in the cloud provider");
die("Image $img_name is not available in the cloud provider");
} else {
# Log the found image ID
record_info('DEBUG', "Found image ID: $image_id for image: $img_name");
}
# die("Image $img_name is not available in the cloud provider") unless ($image_id);
$self->{image_cache}->{$img_name} = $image_id;
return $image_id;
}
Expand Down Expand Up @@ -457,10 +467,15 @@ Calls terraform tool and applies the corresponding configuration .tf file
sub terraform_apply {
my ($self, %args) = @_;
my $terraform_timeout = get_var('TERRAFORM_TIMEOUT', TERRAFORM_TIMEOUT);
record_info('DEBUG', "Terraform timeout: $terraform_timeout");
my $terraform_vm_create_timeout = get_var('TERRAFORM_VM_CREATE_TIMEOUT');
record_info('DEBUG', "Terraform VM create timeout: $terraform_vm_create_timeout");


my $image_uri = $self->get_image_uri();
record_info('DEBUG', "Image URI: $image_uri");
my $image_id = $self->get_image_id();
record_info('DEBUG', "Image ID: $image_id");

$args{count} //= '1';
my $instance_type = get_var('PUBLIC_CLOUD_INSTANCE_TYPE');
Expand Down
133 changes: 133 additions & 0 deletions tests/publiccloud/aistack_basic.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# 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;

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();

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);

# 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 9ac367d

Please sign in to comment.