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

Workaround for boo#1019090, bnc#1014602 #2300

Merged
merged 1 commit into from Jan 18, 2017
Merged

Conversation

drpaneas
Copy link
Contributor

boo#1019090: do not install 'java-bootstrap' packages, as they
conflict with java on Leap42.2

bnc#1014602: java 1.7.0 is reported by java when having ibm-java 1.7.1
installed. This behavior is expected and acceptable according to IBM.

Also only fail the test for 'javac' if the -devel package should be
installed (SDK available) but it's not.

@sysrich
Copy link
Member

sysrich commented Jan 11, 2017

If these are workarounds, shouldn't they be using record_soft_failure with a relevant reference to the bugs in question so we know when those workarounds are being triggered?

@coolo
Copy link
Contributor

coolo commented Jan 11, 2017

it's unlikely though that we will fix the 42.2 FTP repo - so it will be soft failure forever :(

@drpaneas
Copy link
Contributor Author

The test tries to do zypper_call "in java-*"; and if fails in opensuse because of boo#1019090. So, the current workaround is to check if DISTRI is opensuse and then install everything except from the bootstrap packages. However, instead of "hardcoding" it like this and making it work only for this specific case, it would be better if I would go with a more generic approach. For example:

  1. Try to install java-* packages
  2. If there is a dependency conflict, save a screenshot.
  3. Mark this as a soft-failed test.
  4. Continue the zypper installation by choosing the solution 1 (which is kind of the default)

All these are already implemented in tests/installation/zdup.pm by @okurz . So, one way it is to copy and paste a part of his code:

my $self = shift;

# precompile regexes
my $zypper_dup_continue      = qr/^Continue\? \[y/m;
my $zypper_dup_conflict      = qr/^Choose from above solutions by number[\s\S,]* \[1/m;
my $zypper_dup_notifications = qr/^View the notifications now\? \[y/m;
my $zypper_dup_error         = qr/^Abort, retry, ignore\? \[a/m;
my $zypper_dup_finish        = qr/^There are some running programs that might use files|^ZYPPER-DONE/m;
my $zypper_packagekit        = qr/^Tell PackageKit to quit\?/m;
my $zypper_packagekit_again  = qr/^Try again\?/m;
my $zypper_repo_disabled     = qr/^Repository '[^']+' has been successfully disabled./m;
my $zypper_installing        = qr/Installing: \S+/;
my $zypper_dup_fileconflict  = qr/^File conflicts .*^Continue\? \[y/ms;
my $zypper_retrieving        = qr/Retrieving \S+/;
my $zypper_check_conflicts   = qr/Checking for file conflicts: \S+/;

script_run("(zypper in java-*;echo ZYPPER-DONE) | tee /dev/$serialdev", 0);

$out = wait_serial([$zypper_dup_continue, $zypper_dup_conflict, $zypper_dup_error], 240);
while ($out) {
    if ($out =~ $zypper_dup_conflict) {
        if (get_var("WORKAROUND_DEPS")) {
            record_soft_failure 'workaround dependencies';
            send_key '1';
            send_key 'ret';
        }
        else {
            $self->result('fail');
            save_screenshot;
            return;
        }
    }
    elsif ($out =~ $zypper_dup_continue) {
        # confirm zypper dup continue
        send_key 'y';
        send_key 'ret';
        last;
    }
    elsif ($out =~ $zypper_dup_error) {
        $self->result('fail');
        save_screenshot;
        return;
    }
    save_screenshot;
    $out = wait_serial([$zypper_dup_continue, $zypper_dup_conflict, $zypper_dup_error], 120);
}
unless ($out) {
    $self->result('fail');
    save_screenshot;
    return;
}

# wait for zypper dup finish, accept failures in meantime
my $post_checks = [
    $zypper_dup_finish,       $zypper_installing,      $zypper_dup_notifications, $zypper_dup_error,
    $zypper_dup_fileconflict, $zypper_check_conflicts, $zypper_retrieving
];
$out = wait_serial($post_checks, 480);
while ($out) {
    if ($out =~ $zypper_dup_notifications) {
        send_key 'n';    # do not show notifications
        send_key 'ret';
    }
    elsif ($out =~ $zypper_dup_error) {
        $self->result('fail');
        save_screenshot;
        return;
    }
    elsif ($out =~ $zypper_dup_finish) {
        last;
    }
    elsif ($out =~ $zypper_retrieving or $out =~ $zypper_check_conflicts) {
        # probably to avoid hitting black screen on video
        send_key 'shift';
        # continue but do a check again
        $out = wait_serial($post_checks, 240);
        next;
    }
    elsif ($out =~ $zypper_dup_fileconflict) {
        #             record_soft_failure;
        #             send_key 'y';
        #             send_key 'ret';
        $self->result('fail');
        save_screenshot;
        return;
    }
    else {
        # probably to avoid hitting black screen on video
        send_key 'shift';
    }
    save_screenshot;
    $out = wait_serial([$zypper_dup_finish, $zypper_installing, $zypper_dup_notifications, $zypper_dup_error], 240);
}

In the meanwhile, instead of repeating the previous codeblock, I would prefer to use an API call similar to zypper_call. However, I am not aware if there is any. Do you think that it makes sense to create a new call for that? IHMO it makes sense to have a zypper call that detects conflicts, saves a soft-failure and then proceeds with solution 1. The aforementioned source code does all this beautifully, so I suppose it would not be that hard to make a function out of it. Right?

After all, I am open to suggestions, what do you guys think?

As for the bnc#1014602 this is an invalid bug, so there is no reason to mark this as a soft-failure. I would say it's rather a weird to have a package with version 1.7.1 but when I ask for the version of it (using the typical --version) it responds with 1.7.0 and on top of that this is expected. So, it's a specific case from IBM, but it's not a bug or a failure according to the them, so it makes no sense to flag it as a problem (soft or not). Hm?

@okurz
Copy link
Member

okurz commented Jan 12, 2017

I didn't implement the part you mentioned, I just changed it and adopted maintainership.

In general, anytime you want to reuse code move it up in the hierarchy to the first common point, e.g. a baseclass which is common to the test modules that share the functionality. You can do that by extracting the part into a function, find a baseclass (e.g. lib/opensusebasetest.pm), define the function as a object method there and call the object method from the test modules.

In general the procedure with record_soft_fail should be like this:

  • if a test fails, create a ticket
  • change the test code and reference the ticket

recording a soft failure without a reference is a bad approach as - honestly - no one will care until it might be too late. So you want a test to fail and only explicitly accept dependency issues in certain and known cases. You maybe could make it a bit easier by doing something like assert_screen 'dependency_issue_please_create_workaround_needle'; and needle appropriately which looks hacky but could be faster than changing test code.

@drpaneas
Copy link
Contributor Author

drpaneas commented Jan 12, 2017

@okurz thanks for the clarification. So, after talking with @asemen we concluded to another simpler solution for boo#1019090:

if the test runs in opensuse, then
    if there are java-bootstrap packages available in the repositories, then
        if trying to install java along with bootstrap packages fails, then
            mark soft failure with the bug number
            # this means they fixed (or not) the bug, by removing the bootstrap pkgs
            continue by not installing the bootstrap packages
        else
            # this means they fixed the bug so both pks exist but not conflict
            continue by installing java along with bootstrap packages

In that case, no matter of Leap or TW, if such bug exists in opensuse it will be flagged as soft-failed (hitting boo#1019090) and the test will continue with the workaround.

@drpaneas
Copy link
Contributor Author

I recommitted and rebased. The new code works as expected, tested in:

Please review the code, and merge if you are OK with the changes :)

@drpaneas
Copy link
Contributor Author

+use base "installbasetest"; this is not needed, let me remove it and re-commit.

fi
else
echo "check linked java version: FAIL"
echo "linked java is: $java_version_active should be $dot_version_short"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indendation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part of the code is will be removed, thanks to the previous refactor. Yet again, thanks for catching this.

echo "INFO: linked java is: $java_version_active which is normal according to bnc#1014602"
fi
else
echo "check linked java version: FAIL"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DRY. You are calling the same code multiple times, please extract method.

Hint: echo -n and combine multiple echo calls

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for spotting this, will refactor the code properly.

echo "Reason : devel pkg is not installed, thus it is normal there is not javac"
if zypper products -i | grep sle-sdk > /dev/null; then
echo "Status : Error! The devel pkg should be installed. Check your repos!"
exit 8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 8?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any guideline for openQA return codes? I was using mine, which kind of pointless because they are known only to me, so I will change all the (fail) return codes to 1, which is the default that everybody expects in such a case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, "do not use magic numbers" ;-)


if (check_var("DISTRI", "opensuse")) {
if ($bootstrap_pkg_rt == 0) {
print "There are java bootstrap packages available to be installed\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better replace by diag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, I don't want to replace it, I need this to be visible in the screenshots. However, I can 'add' a diag, so this will be also visible in the logs.

boo#1019090: if there are 'java-bootstrap' packages,
try to install them, unless they conflict with java.

bnc#1014602: java 1.7.0 is reported by java when having ibm-java 1.7.1
installed. This behavior is expected and acceptable according to IBM.

Also only fail the test for 'javac' if the -devel package should be
installed (SDK available) but it's not.

Update the date in the comment section (2016 -> 2017).

Replace all the undefined exit codes with 1.
dzedro referenced this pull request Jan 17, 2017
Installs every possible java version that is available in the
currently enabled repositories of the SUT.

Make sure that there is at least one Java version installed, otherwise
quite testing.

Testing Coverage

For every installed Java version (except gcj), it implements the
following scenarios:

- All tests ignore gcj.

- Number of java alternatives is equal with the number of the installed
  java versions.

- Number of javac alternatives is equal with the number of the installed
  java-devel versions.

- Number of javaplugin alternatives is equal with the number of the
  installed java-ibm versions.

- update-alternatives works for both java and javac.

- update-alternatives works for javaplugin only for java-ibm.

- java -version corresponds to the currently active version of java.

- Compile and run a basic helloworld program.

- Detect abnormal behavior in java -version (see bnc#1014602)

Testing Environment

Wherever there are java and java-devel (javac) packages. It has been
tested in SLES-12-{SP1,2}.
Copy link
Member

@okurz okurz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good enough for now :-) I will merge and ask you to please closely monitor scenarios where this is running.

}
else {
diag "There are no java bootstrap packages";
print "There are no java bootstrap packages\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that repetition is certainly not what I intended.

@okurz okurz merged commit b713fc3 into os-autoinst:master Jan 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants