-
Notifications
You must be signed in to change notification settings - Fork 266
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
Added new test for python pip version check and functionality #17681
Draft
ypagar1
wants to merge
1
commit into
os-autoinst:master
Choose a base branch
from
ypagar1:python-pip
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+115
−0
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
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,8 @@ | ||
import pysample_package | ||
|
||
print(pysample_package.__version__) | ||
#print(pysample_package.__author__) | ||
|
||
from pysample_package import mymodule | ||
mymodule.greet("Ram") | ||
mymodule.print_hello() | ||
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
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
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,103 @@ | ||
# SUSE's openQA tests | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you need to run |
||
# | ||
# Copyright 2022 SUSE LLC | ||
# SPDX-License-Identifier: FSFAP | ||
# | ||
# Package: python3? | ||
# Summary: Run python3 testsuite | ||
# - Test suitable only for SLE15SPs+ | ||
# - Check that Python 3.x is the main version installed based on SPs | ||
# - Check that Python 3.1? is available to install | ||
# - Install some python package using pip (e.g. pysample_package) | ||
# - Test installed package by importing it in python script | ||
# - Uninstall previously installed python package using pip | ||
# Maintainer: QE Core <qe-core@suse.com> | ||
|
||
use base "consoletest"; | ||
use strict; | ||
use warnings; | ||
use testapi; | ||
use serial_terminal 'select_serial_terminal'; | ||
use version_utils; | ||
use utils "zypper_call"; | ||
use registration "add_suseconnect_product"; | ||
|
||
sub run{ | ||
select_serial_terminal; | ||
# Test system python3 version | ||
my @system_python3_version = script_output(qq[zypper se --installed-only --provides '/usr/bin/python3' | awk -F '|' '/python3[0-9]*/ {gsub(" ", ""); print \$2}' | awk -F '-' '{print \$1}' | uniq | head -1]); | ||
die "There are many python3 versions installed " if (scalar(@system_python3_version) > 1); | ||
my $sys_python3_version = get_python3_version($system_python3_version[0]); | ||
record_info("System python version", "$sys_python3_version"); | ||
my ($python_version, $pip_version) = get_pip_version($sys_python3_version); | ||
#Test system python3 pip | ||
test_python_pip($python_version, $pip_version); | ||
#Test other available python versions | ||
test_available_python_versions(); | ||
} | ||
|
||
sub test_available_python_versions { | ||
# Test all avaiable new python3 versions if any | ||
my $ret = zypper_call('se "python3[0-9]*"', exitcode => [0, 104]); | ||
die('No new python3 packages available') if ($ret == 104); | ||
my @python3_versions = split(/\n/, script_output(qq[zypper se 'python3[0-9]*' | awk -F '|' '/python3[0-9]/ {gsub(" ", ""); print \$2}' | awk -F '-' '{print \$1}' | uniq])); | ||
record_info("Available versions", "All available new python3 versions are: @python3_versions"); | ||
foreach my $python3_spec_release (@python3_versions) { | ||
record_info("Installing $python3_spec_release", "$python3_spec_release is tested now"); | ||
zypper_call("install $python3_spec_release"); | ||
my $python3_version = get_python3_version($python3_spec_release); | ||
my ($python_version, $pip_version) = get_pip_version($python3_version); | ||
#Test system python3 pip | ||
test_python_pip($python_version, $pip_version); | ||
} | ||
} | ||
|
||
sub test_python_pip { | ||
#Test pip package installation and uninstallation | ||
my ($python_version, $pip_version) = @_; | ||
my $package = "pysample_package-1.0.tar.gz"; | ||
my $script = "test_pysample_package.py"; | ||
assert_script_run("[ -f $package ] || curl -O " . data_url("console/$package") . " || true"); | ||
record_info("Testing pip version $pip_version", "$pip_version is tested now"); | ||
my $pip_install_cmd = "$pip_version install ".((split(/-/, $package))[0])." --no-index --find-links ."; | ||
my $pip_install_output = script_output("$pip_install_cmd"); | ||
record_info("Pip installed package:","$pip_install_output"); | ||
my $pip_show_cmd = "$pip_version show ".((split(/-/, $package))[0]); | ||
my $pip_show_output = script_output("$pip_show_cmd"); | ||
record_info("Verify package installation", "$pip_show_output"); | ||
assert_script_run("[ -f $script ] || curl -O " . data_url("console/$script") . " || true"); | ||
my $output = script_output("$python_version $script"); | ||
record_info("Script output", "$output"); | ||
my $pip_uninstall_cmd = "$pip_version uninstall -y ".((split(/-/, $package))[0]); | ||
$output = script_output("$pip_uninstall_cmd"); | ||
record_info("Uninstall package: ", "$output"); | ||
} | ||
|
||
sub get_python3_version { | ||
#Get specific version of python e.g."Python 3.6.15" | ||
my ($python3_version) = @_; | ||
if ($python3_version eq "python3") { | ||
return script_output("$python3_version --version"); | ||
} | ||
my $sub_version = substr($python3_version, 7); | ||
return script_output("python3.$sub_version --version"); | ||
} | ||
|
||
sub get_pip_version { | ||
#Get python and associated pip version e.g. "python3.6" and "pip3.6" | ||
my ($python_version) = @_; | ||
my ($major, $minor) = split(/\./, substr($python_version, 7),3); | ||
my ($pip_version) = script_output("pip$major.$minor --version"); | ||
die "No associated pip installed for $python_version" if ($pip_version eq ""); | ||
record_info("Pip version associated to $python_version is", "$pip_version"); | ||
return ("python$major.$minor", "pip$major.$minor") | ||
} | ||
|
||
|
||
sub post_fail_hook { | ||
select_console 'log-console'; | ||
assert_script_run 'save_y2logs /tmp/python3_pip_version_check_y2logs.tar.bz2'; | ||
upload_logs '/tmp/python3_pip_version_check_y2logs.tar.bz2'; | ||
} | ||
|
||
1; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use the package from: #17675 if you rebase on top of her changes, so you can leverage on @DeepthiYV's module