-
Notifications
You must be signed in to change notification settings - Fork 403
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
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5e28661
add api-gateway test logic for node
MichalKalke f30884f
adjust tests to check the runtime
MichalKalke 3ac3668
add python39 test
MichalKalke e3ac195
uncomment main
MichalKalke 258df6b
adjust pod selector
MichalKalke 602f579
add check if all labels exists
MichalKalke e22f3b8
adjust labels and error handling
MichalKalke 54b10ed
rename package
MichalKalke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
87 changes: 87 additions & 0 deletions
87
tests/function-controller/testsuite/scenarios/api_gateway.go
This file contains hidden or 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,87 @@ | ||
package scenarios | ||
|
||
import ( | ||
"fmt" | ||
"github.com/pkg/errors" | ||
typedappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" | ||
"time" | ||
|
||
"github.com/kyma-project/kyma/tests/function-controller/pkg/function" | ||
|
||
serverlessv1alpha2 "github.com/kyma-project/kyma/components/function-controller/pkg/apis/serverless/v1alpha2" | ||
"github.com/sirupsen/logrus" | ||
"k8s.io/client-go/dynamic" | ||
typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" | ||
"k8s.io/client-go/rest" | ||
|
||
"github.com/kyma-project/kyma/tests/function-controller/pkg/shared" | ||
"github.com/kyma-project/kyma/tests/function-controller/pkg/step" | ||
"github.com/kyma-project/kyma/tests/function-controller/testsuite" | ||
"github.com/kyma-project/kyma/tests/function-controller/testsuite/runtimes" | ||
"github.com/kyma-project/kyma/tests/function-controller/testsuite/teststep" | ||
) | ||
|
||
const ( | ||
nodejs16 = "nodejs16" | ||
nodejs18 = "nodejs18" | ||
python39 = "python39" | ||
) | ||
|
||
func SimpleFunctionAPIGatewayTest(restConfig *rest.Config, cfg testsuite.Config, logf *logrus.Entry) (step.Step, error) { | ||
now := time.Now() | ||
cfg.Namespace = fmt.Sprintf("%s-%02dh%02dm%02ds", "test-simple-api-gateway", now.Hour(), now.Minute(), now.Second()) | ||
|
||
dynamicCli, err := dynamic.NewForConfig(restConfig) | ||
if err != nil { | ||
return nil, errors.Wrapf(err, "while creating dynamic client") | ||
} | ||
|
||
coreCli, err := typedcorev1.NewForConfig(restConfig) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "while creating k8s CoreV1Client") | ||
} | ||
|
||
appsCli, err := typedappsv1.NewForConfig(restConfig) | ||
if err != nil { | ||
return nil, errors.Wrapf(err, "while creating k8s apps client") | ||
} | ||
|
||
python39Logger := logf.WithField(scenarioKey, "python39") | ||
nodejs16Logger := logf.WithField(scenarioKey, "nodejs16") | ||
nodejs18Logger := logf.WithField(scenarioKey, "nodejs18") | ||
|
||
genericContainer := shared.Container{ | ||
DynamicCli: dynamicCli, | ||
Namespace: cfg.Namespace, | ||
WaitTimeout: cfg.WaitTimeout, | ||
Verbose: cfg.Verbose, | ||
Log: logf, | ||
} | ||
|
||
python39Fn := function.NewFunction("python39", cfg.KubectlProxyEnabled, genericContainer.WithLogger(python39Logger)) | ||
|
||
nodejs16Fn := function.NewFunction("nodejs16", cfg.KubectlProxyEnabled, genericContainer.WithLogger(nodejs16Logger)) | ||
|
||
nodejs18Fn := function.NewFunction("nodejs18", cfg.KubectlProxyEnabled, genericContainer.WithLogger(nodejs18Logger)) | ||
|
||
logf.Infof("Testing function in namespace: %s", cfg.Namespace) | ||
|
||
return step.NewSerialTestRunner(logf, "Runtime test", | ||
teststep.NewNamespaceStep("Create test namespace", coreCli, genericContainer), | ||
teststep.NewApplication("Create HTTP basic application", HTTPAppName, HTTPAppImage, int32(80), appsCli.Deployments(genericContainer.Namespace), coreCli.Services(genericContainer.Namespace), genericContainer), | ||
step.NewParallelRunner(logf, "Fn tests", | ||
step.NewSerialTestRunner(python39Logger, "Python39 test", | ||
teststep.CreateFunction(python39Logger, python39Fn, "Create Python39 Function", runtimes.BasicPythonFunction("Hello from python39", serverlessv1alpha2.Python39)), | ||
teststep.NewAPIGatewayFunctionCheck("python39", python39Fn, coreCli, genericContainer.Namespace, python39), | ||
), | ||
step.NewSerialTestRunner(nodejs16Logger, "NodeJS16 test", | ||
teststep.CreateFunction(nodejs16Logger, nodejs16Fn, "Create NodeJS16 Function", runtimes.BasicNodeJSFunction("Hello from nodejs16", serverlessv1alpha2.NodeJs16)), | ||
teststep.NewAPIGatewayFunctionCheck("nodejs16", nodejs16Fn, coreCli, genericContainer.Namespace, nodejs16), | ||
), | ||
step.NewSerialTestRunner(nodejs18Logger, "NodeJS18 test", | ||
teststep.CreateFunction(nodejs18Logger, nodejs18Fn, "Create NodeJS18 Function", runtimes.BasicNodeJSFunction("Hello from nodejs18", serverlessv1alpha2.NodeJs18)), | ||
teststep.NewAPIGatewayFunctionCheck("nodejs18", nodejs18Fn, coreCli, genericContainer.Namespace, nodejs18), | ||
), | ||
), | ||
), nil | ||
} |
This file contains hidden or 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
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.
We can implement such selector: