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

Hana client contract test hardening #1074

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions tests/serverless/internal/resources/runtimes/nodejs.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,12 @@ func NodeJSFunctionUsingHanaClient(rtm serverlessv1alpha2.Runtime) serverlessv1a
let result = await conn.exec('SELECT 1 AS "One" FROM DUMMY')
return result;
} catch(err) {
// it is expected to leave here
return err;
// it is expected to leave here. The purpose is to check if hana client returns a known error instead of crashing the whole container with SIGSEGV
// HY000 means general error - https://stackoverflow.com/questions/7472884/what-is-sql-error-5-sqlstate-hy000-and-what-can-cause-this-error
if(err.sqlState && err.sqlState=="HY000"){
return "OK";
}
return "NOK";
}
}
}
Expand All @@ -286,7 +290,7 @@ func NodeJSFunctionUsingHanaClient(rtm serverlessv1alpha2.Runtime) serverlessv1a
Source: serverlessv1alpha2.Source{
Inline: &serverlessv1alpha2.InlineSource{
Source: src,
Dependencies: `{"name": "hana-client","version": "0.0.1","dependencies": { "@sap/hana-client": "^2.21.26"} }`,
Dependencies: `{"name": "hana-client","version": "0.0.1","dependencies": { "@sap/hana-client": "latest"} }`,
},
},
ResourceConfiguration: &serverlessv1alpha2.ResourceConfiguration{
Expand Down
4 changes: 2 additions & 2 deletions tests/serverless/internal/testsuite/hana_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ func HanaClientTest(restConfig *rest.Config, cfg internal.Config, logf *logrus.E
executor.NewParallelRunner(logf, "Fn tests",
executor.NewSerialTestRunner(nodejs18Logger, "NodeJS18 test",
function.CreateFunction(nodejs18Logger, nodejs18Fn, "Create NodeJS18 Function", runtimes.NodeJSFunctionUsingHanaClient(serverlessv1alpha2.NodeJs18)),
assertion.NewHTTPCheck(nodejs18Logger, "Testing hana-client in nodejs18 function", nodejs18Fn.FunctionURL, poll, "{\"code\":10,\"sqlState\":\"28000\"}"),
assertion.NewHTTPCheck(nodejs18Logger, "Testing hana-client in nodejs18 function", nodejs18Fn.FunctionURL, poll, "OK"),
),
executor.NewSerialTestRunner(nodejs20Logger, "NodeJS20 test",
function.CreateFunction(nodejs20Logger, nodejs20Fn, "Create NodeJS20 Function", runtimes.NodeJSFunctionUsingHanaClient(serverlessv1alpha2.NodeJs20)),
assertion.NewHTTPCheck(nodejs18Logger, "Testing hana-client in nodejs20 function", nodejs20Fn.FunctionURL, poll, "{\"code\":10,\"sqlState\":\"28000\"}"),
assertion.NewHTTPCheck(nodejs18Logger, "Testing hana-client in nodejs20 function", nodejs20Fn.FunctionURL, poll, "OK"),
),
),
), nil
Expand Down
Loading