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

CM-423: Adds e2e test for istio-csr controller with grpc CreateCertificate call #226

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

PillaiManish
Copy link
Contributor

@PillaiManish PillaiManish commented Dec 26, 2024

The PR adds the e2e test scenarios for the new istio-csr controller.

  • Apply's the new IstioCSR resource in the istio-system namespace
  • Create a new job - grpcurl-job which calls the endpoint of the istio-csr
  • Waits for the response and validates the certificate and the root chain

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Dec 26, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Dec 26, 2024

@PillaiManish: This pull request references CM-423 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target either version "4.19." or "openshift-4.19.", but it targets "cert-manager-1.15" instead.

In response to this:

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.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 26, 2024
Copy link
Contributor

openshift-ci bot commented Dec 26, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@swghosh
Copy link
Member

swghosh commented Dec 27, 2024

/testwith openshift/cert-manager-operator/master/e2e-operator #220

@PillaiManish
Copy link
Contributor Author

/reopen

@PillaiManish PillaiManish reopened this Jan 6, 2025
Copy link
Contributor

openshift-ci bot commented Jan 6, 2025

@PillaiManish: Failed to re-open PR: state cannot be changed. There is already an open pull request from PillaiManish:master to openshift:master.

In response to this:

/reopen

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-sigs/prow repository.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 6, 2025

@PillaiManish: This pull request references CM-423 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target either version "4.19." or "openshift-4.19.", but it targets "cert-manager-1.15" instead.

In response to this:

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.

@PillaiManish PillaiManish marked this pull request as ready for review January 6, 2025 12:41
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 6, 2025
@openshift-ci openshift-ci bot requested review from swghosh and TrilokGeer January 6, 2025 12:42
@bharath-b-rh
Copy link
Contributor

/testwith openshift/cert-manager-operator/master/e2e-operator #220

Copy link
Member

@swghosh swghosh left a comment

Choose a reason for hiding this comment

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

Please refactor the tests using a fresh Ginkgo suite that can have a label for TechPreview and Feature:IstioCSR or the alike.

Also, per discussions with team earlier we can strip the service mesh functionality for now and only make this test, really test the grpc server exposed by istio-csr with a plain client.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 11, 2025
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 13, 2025
Copy link
Member

@swghosh swghosh left a comment

Choose a reason for hiding this comment

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

overall the test case(s) seem to be in a good shape.

@swghosh
Copy link
Member

swghosh commented Jan 13, 2025

/testwith openshift/cert-manager-operator/master/e2e-operator #220

@bharath-b-rh
Copy link
Contributor

Please add the description.

@PillaiManish
Copy link
Contributor Author

/testwith openshift/cert-manager-operator/master/e2e-operator #220

1 similar comment
@PillaiManish
Copy link
Contributor Author

/testwith openshift/cert-manager-operator/master/e2e-operator #220

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 14, 2025
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 17, 2025
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 17, 2025
Comment on lines 144 to 241
By("creating an grpcurl job")
job := &batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
Name: "grpcurl-job",
},
Spec: batchv1.JobSpec{
Completions: ptr.To(int32(1)),
BackoffLimit: ptr.To(back_off_limits),
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: grpcAppName,
Labels: map[string]string{
"app": grpcAppName,
},
},
Spec: corev1.PodSpec{
ServiceAccountName: serviceAccountName,
AutomountServiceAccountToken: ptr.To(false),
RestartPolicy: corev1.RestartPolicyOnFailure,
Containers: []corev1.Container{
{
Name: grpcAppName,
Image: "registry.redhat.io/rhel9/go-toolset",
Command: []string{
"/bin/sh",
"-c",
},
Env: []corev1.EnvVar{
{
Name: "GOCACHE",
Value: "/tmp/go-cache",
},
},
Args: []string{
"GOCACHE=/tmp/go-cache && " +
"export GOPATH=/tmp/go && " +
"go install github.com/fullstorydev/grpcurl/cmd/[email protected] >/dev/null 2>&1 && " +
"TOKEN=$(cat /var/run/secrets/istio-ca/token) && " +
"/tmp/go/bin/grpcurl " +
"-import-path /proto " +
"-proto /proto/ca.proto " +
"-H \"Authorization: Bearer $TOKEN\" " +
fmt.Sprintf("-d '{\"csr\": \"%s\", \"validity_duration\": 3600}' ", csr) +
"-cacert /etc/root-secret/ca.crt " +
"-key /etc/root-secret/tls.key " +
"-cert /etc/root-secret/tls.crt " +
fmt.Sprintf("%s istio.v1.auth.IstioCertificateService/CreateCertificate", istioCSRGRPCEndpoint),
},
VolumeMounts: []corev1.VolumeMount{
{Name: "root-secret", MountPath: "/etc/root-secret"},
{Name: "proto", MountPath: "/proto"},
{Name: "service-token", MountPath: "/var/run/secrets/istio-ca"},
},
},
},
Volumes: []corev1.Volume{
{
Name: "service-token",
VolumeSource: corev1.VolumeSource{
Projected: &corev1.ProjectedVolumeSource{
DefaultMode: ptr.To(int32(420)),
Sources: []corev1.VolumeProjection{
{
ServiceAccountToken: &corev1.ServiceAccountTokenProjection{
Audience: "istio-ca",
ExpirationSeconds: ptr.To(int64(3600)),
Path: "token",
},
},
},
},
},
},
{
Name: "root-secret",
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: "istiod-tls",
},
},
},
{
Name: "proto",
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: "proto-cm",
},
},
},
},
},
},
},
},
}
Copy link
Member

Choose a reason for hiding this comment

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

prefer a file for this instead, as most of the field values are fixed. replaceStrInFile can help;
however follow-up PR is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I can do it in a follow-up, if that works?

Copy link
Member

Choose a reason for hiding this comment

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

let's de-clutter it, how about a test/e2e/testdata/istio_csr/grpcurl_job.yaml?

apiVersion: batch/v1
kind: Job
metadata:
  name: grpcurl-istio-csr
spec:
  backoffLimit: 10
  completions: 1
  template:
    metadata:
      labels:
        app: grpcurl-istio-csr
      name: grpcurl-istio-csr
    spec:
      automountServiceAccountToken: false
      containers:
      - args:
        - |
          go install github.com/fullstorydev/grpcurl/cmd/[email protected] >/dev/null 2>&1 && \
          TOKEN=$(cat /var/run/secrets/istio-ca/token) && \
          /tmp/go/bin/grpcurl \
            -import-path /proto \
            -proto /proto/ca.proto \
            -H "Authorization: Bearer $TOKEN" \
            -d '{"csr": "{{.CertificateSigningRequest}}", "validity_duration": 3600}' \
            -cacert /etc/root-secret/ca.crt \
            -key /etc/root-secret/tls.key \
            -cert /etc/root-secret/tls.crt \
            {{.IstioCSRStatus.IstioCSRGRPCEndpoint}} istio.v1.auth.IstioCertificateService/CreateCertificate
        command:
        - /bin/sh
        - -c
        env:
        - name: GOCACHE
          value: /tmp/go-cache
        - name: GOPATH
          value: /tmp/go
        image: registry.redhat.io/rhel9/go-toolset
        name: grpcurl
        volumeMounts:
        - mountPath: /etc/root-secret
          name: root-secret
        - mountPath: /proto
          name: proto
        - mountPath: /var/run/secrets/istio-ca
          name: sa-token
      restartPolicy: OnFailure
      serviceAccountName: '{{.IstioCSRStatus.ServiceAccount}}'
      volumes:
      - name: sa-token
        projected:
          defaultMode: 420
          sources:
          - serviceAccountToken:
              audience: istio-ca
              expirationSeconds: 3600
              path: token
      - name: root-secret
        secret:
          secretName: istiod-tls
      - configMap:
          name: proto-cm
        name: proto

what I meant basically pushes ahead of #247, so that within test/e2e/config_template.go we can add:

+ // IstioCSRConfig customizes the fields in a job spec
+ type IstioCSRGRPCurlJobConfig struct {
+ 	CertificateSigningRequest string
+ 	IstioCSRStatus            v1alpha1.IstioCSRStatus
+ }

to get the above yaml value filled in during test.

Copy link
Member

Choose a reason for hiding this comment

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

As discussed, we'll do this on a follow-up PR after #247 lands.

Copy link
Member

@swghosh swghosh left a comment

Choose a reason for hiding this comment

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

few nits, otherwise LGTM.

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 25, 2025
@swghosh
Copy link
Member

swghosh commented Feb 25, 2025

/retitle CM-423: Adds e2e test for istio-csr controller with grpc CreateCertificate call

@openshift-ci openshift-ci bot changed the title CM-423: added test case for istio-csr CM-423: Adds e2e test for istio-csr controller with grpc CreateCertificate call Feb 25, 2025
@bharath-b-rh
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 25, 2025
Copy link
Member

@lunarwhite lunarwhite left a comment

Choose a reason for hiding this comment

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

LGTM, only minor nits

  - applys IstioCSR resource
  - deploys grpcurl job - which calls the grpc endpoint of istio-csr
  - checks the response and validates the certificate
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 25, 2025
@lunarwhite
Copy link
Member

/label qe-approved
/lgtm

@openshift-ci openshift-ci bot added the qe-approved Signifies that QE has signed off on this PR label Feb 25, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Feb 25, 2025

@PillaiManish: This pull request references CM-423 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target either version "4.19." or "openshift-4.19.", but it targets "cert-manager-1.15" instead.

In response to this:

The PR adds the e2e test scenarios for the new istio-csr controller.

  • Apply's the new IstioCSR resource in the istio-system namespace
  • Create a new job - grpcurl-job which calls the endpoint of the istio-csr
  • Waits for the response and validates the certificate and the root chain

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.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 25, 2025
Copy link
Contributor

openshift-ci bot commented Feb 25, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bharath-b-rh, lunarwhite, PillaiManish, swghosh

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

@swghosh
Copy link
Member

swghosh commented Feb 25, 2025

/cherry-pick cert-manager-1.15

@openshift-cherrypick-robot

@swghosh: once the present PR merges, I will cherry-pick it on top of cert-manager-1.15 in a new PR and assign it to you.

In response to this:

/cherry-pick cert-manager-1.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-sigs/prow repository.

Copy link
Contributor

openshift-ci bot commented Feb 25, 2025

@PillaiManish: 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-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 91e24b4 into openshift:master Feb 25, 2025
9 checks passed
@openshift-cherrypick-robot

@swghosh: #226 failed to apply on top of branch "cert-manager-1.15":

Applying: adds e2e test case for istio-csr:#423
Using index info to reconstruct a base tree...
M	test/e2e/cert_manager_deployment_test.go
M	test/e2e/certificates_test.go
M	test/e2e/utils_test.go
M	test/library/utils.go
Falling back to patching base and 3-way merge...
Auto-merging test/library/utils.go
CONFLICT (content): Merge conflict in test/library/utils.go
Auto-merging test/e2e/utils_test.go
Auto-merging test/e2e/certificates_test.go
CONFLICT (content): Merge conflict in test/e2e/certificates_test.go
Auto-merging test/e2e/cert_manager_deployment_test.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 adds e2e test case for istio-csr:#423

In response to this:

/cherry-pick cert-manager-1.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-sigs/prow repository.

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. docs-approved Signifies that Docs has signed off on this PR 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. px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants