Skip to content

Contract test between api-gateway and serverless #17894

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

Merged
merged 8 commits into from
Aug 1, 2023

Conversation

MichalKalke
Copy link
Contributor

@MichalKalke MichalKalke commented Jul 26, 2023

Description

Kubernetes resources produced by serverless must satisfy API-gateway label selectors so that when istio and api-gateway are installed, user may add a sidecar to the function pod and expose its API.

Changes proposed in this pull request:

  • Add contract test for all runtimes which check if labels in Pod and Service are the same

Related issue(s)
#17506

@kyma-bot kyma-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 26, 2023
@netlify
Copy link

netlify bot commented Jul 26, 2023

Deploy Preview for kyma-project-docs-preview ready!

Name Link
🔨 Latest commit 54b10ed
🔍 Latest deploy log https://app.netlify.com/sites/kyma-project-docs-preview/deploys/64c79f075cc21c00082c58b6
😎 Deploy Preview https://deploy-preview-17894--kyma-project-docs-preview.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.

@kyma-bot
Copy link
Contributor

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

@kyma-bot kyma-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 26, 2023
@MichalKalke
Copy link
Contributor Author

/test all

@MichalKalke MichalKalke marked this pull request as ready for review July 27, 2023 09:45
@MichalKalke MichalKalke requested a review from a team as a code owner July 27, 2023 09:45
@kyma-bot kyma-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 27, 2023
@MichalKalke MichalKalke added area/tests Issues or PRs related to tests area/serverless Issues or PRs related to serverless labels Jul 27, 2023
@MichalKalke MichalKalke changed the title add api-gateway test logic for node Contract test between api-gateway and serverless Jul 27, 2023
@dbadura dbadura self-assigned this Jul 27, 2023
return errors.Wrap(err, "while trying to get service")
}

pods, err := d.client.Pods(d.namespace).List(context.Background(), metav1.ListOptions{LabelSelector: resourceLabel})
Copy link
Contributor

@dbadura dbadura Jul 27, 2023

Choose a reason for hiding this comment

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

We can implement such selector:

kubectl get pod -n test-simple-tracing-11h22m49s  -l serverless.kyma-project.io/function-name=nodejs16,serverless.kyma-project.io/resource=deployment

@MichalKalke
Copy link
Contributor Author

/test all


for _, label := range requiredLabels {
if _, exists := labels[label]; !exists {
return errors.New(fmt.Sprintf("Label %s is missing", label))
Copy link
Contributor

Choose a reason for hiding this comment

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

We can gather all errors by using https://pkg.go.dev/errors#Join

if val == v {
delete(service.Spec.Selector, k)
} else {
return errors.Errorf("Expected %s but got %s", v, val)
Copy link
Contributor

Choose a reason for hiding this comment

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

We can gather all errors by using https://pkg.go.dev/errors#Join


err = checkIfRequiredLabelsExists(svc.Spec.Selector, true)
if err != nil {
return errors.Wrap(err, " in service")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should write it in such way: errors.Wrap(err, "while checking the service labels

@kwiatekus
Copy link
Contributor

/test all

@dbadura
Copy link
Contributor

dbadura commented Jul 31, 2023

/retest

@kyma-bot kyma-bot added the lgtm Looks good to me! label Aug 1, 2023
@dbadura
Copy link
Contributor

dbadura commented Aug 1, 2023

/retest

@kyma-bot kyma-bot merged commit 32990c0 into kyma-project:main Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/serverless Issues or PRs related to serverless area/tests Issues or PRs related to tests lgtm Looks good to me! size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants