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

NO-JIRA: [e2e test framework] Add a flag to add an annotation to HostedCluster #3854

Merged

Conversation

orenc1
Copy link
Contributor

@orenc1 orenc1 commented Apr 9, 2024

What this PR does / why we need it:
This addition will allow us to insert a custom annotation needed for the e2e test suite for the HostedCluster.
In particular, specify the management platform type in case of kubevirt external infra testing.

Which issue(s) this PR fixes (optional, use fixes #<issue_number>(, fixes #<issue_number>, ...) format, where issue_number might be a GitHub issue, or a Jira story:
Fixes #

Checklist

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

@openshift-ci openshift-ci bot requested review from csrwng and sjenning April 9, 2024 19:22
@openshift-ci openshift-ci bot added area/testing Indicates the PR includes changes for e2e testing and removed do-not-merge/needs-area labels Apr 9, 2024
Copy link

netlify bot commented Apr 9, 2024

Deploy Preview for hypershift-docs ready!

Name Link
🔨 Latest commit 082e2e0
🔍 Latest deploy log https://app.netlify.com/sites/hypershift-docs/deploys/6615955457ded400078ce657
😎 Deploy Preview https://deploy-preview-3854--hypershift-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -115,6 +115,7 @@ func TestMain(m *testing.M) {
flag.StringVar(&globalOpts.ManagementClusterNamespace, "e2e.management-cluster-namespace", "", "Namespace of the management cluster's HostedCluster (required to test request serving isolation)")
flag.StringVar(&globalOpts.ManagementClusterName, "e2e.management-cluster-name", "", "Name of the management cluster's HostedCluster (required to test request serving isolation)")
flag.BoolVar(&globalOpts.DisablePKIReconciliation, "e2e.disable-pki-reconciliation", false, "If set, TestUpgradeControlPlane will upgrade the control plane without reconciling the pki components")
flag.StringVar(&globalOpts.configurableClusterOptions.Annotation, "e2e.annotation", "", "An annotation to apply to the HostedCluster (key=value)")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest making the annotations repeatable. That way we can add more than one annotation at a time. That will probably help us out in the future.

you can achieve this using a custom var with the flags package. i tested this out. here's an example.

package main

import (
        "flag" 
        "fmt"
        "strings"
)

type stringMapVar map[string]string

func (s *stringMapVar) String() string {
        if *s == nil {
                return ""
        }
        return fmt.Sprintf("%v", *s)
}

func (s *stringMapVar) Set(value string) error {
        split := strings.Split(value, "=")
        if len(split) != 2 {
                return fmt.Errorf("invalid argument: %s", value)
        }
        if *s == nil {
                *s = stringMapVar(map[string]string{})
        }
        map[string]string(*s)[split[0]] = split[1]
        return nil
}

var annotations stringMapVar

func main() {

        flag.Var(&annotations, "annotations", "")
        flag.Parse()

        if annotations != nil {
                fmt.Printf("%s\n", annotations.String())
        }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, thanks.
e2e.annotations can be specified multiple times and the annotations are aggregated.

Signed-off-by: Oren Cohen <ocohen@redhat.com>
@orenc1 orenc1 force-pushed the e2e_framework_annotations_flag branch from 082e2e0 to 9deac8b Compare April 10, 2024 09:58
Copy link
Contributor

@davidvossel davidvossel left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 10, 2024
Copy link
Contributor

openshift-ci bot commented Apr 10, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: davidvossel, orenc1

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 10, 2024
@orenc1
Copy link
Contributor Author

orenc1 commented Apr 11, 2024

/test e2e-aws

@rcerven
Copy link

rcerven commented Apr 11, 2024

/retest

@orenc1 orenc1 changed the title [e2e test framework] Add a flag to add an annotation to HostedCluster NO-JIRA: [e2e test framework] Add a flag to add an annotation to HostedCluster Apr 11, 2024
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 11, 2024
@openshift-ci-robot
Copy link

@orenc1: This pull request explicitly references no jira issue.

In response to this:

What this PR does / why we need it:
This addition will allow us to insert a custom annotation needed for the e2e test suite for the HostedCluster.
In particular, specify the management platform type in case of kubevirt external infra testing.

Which issue(s) this PR fixes (optional, use fixes #<issue_number>(, fixes #<issue_number>, ...) format, where issue_number might be a GitHub issue, or a Jira story:
Fixes #

Checklist

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@orenc1
Copy link
Contributor Author

orenc1 commented Apr 11, 2024

/retest

Copy link
Contributor

openshift-ci bot commented Apr 11, 2024

@orenc1: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 5630971 into openshift:main Apr 11, 2024
12 checks passed
@orenc1 orenc1 deleted the e2e_framework_annotations_flag branch April 12, 2024 06:58
@orenc1
Copy link
Contributor Author

orenc1 commented Apr 16, 2024

/cherry-pick release-4.15

@openshift-cherrypick-robot

@orenc1: #3854 failed to apply on top of branch "release-4.15":

Applying: Add a flag to add an annotation to HostedCluster
Using index info to reconstruct a base tree...
M	test/e2e/e2e_test.go
Falling back to patching base and 3-way merge...
Auto-merging test/e2e/e2e_test.go
CONFLICT (content): Merge conflict in test/e2e/e2e_test.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Add a flag to add an annotation to HostedCluster
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-4.15

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

orenc1 added a commit to orenc1/hypershift that referenced this pull request Apr 17, 2024
…Cluster

manual backport of openshift#3854

Signed-off-by: Oren Cohen <ocohen@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/testing Indicates the PR includes changes for e2e testing jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants