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

feat: add binding testing and multiple bindings test data to compliance service #1150

Conversation

viacheslav-rostovtsev
Copy link
Member

Split into semantically meaningful commits for reading convenience.

@viacheslav-rostovtsev viacheslav-rostovtsev requested a review from a team as a code owner July 21, 2022 22:15
Copy link
Contributor

@vchudnov-g vchudnov-g left a comment

Choose a reason for hiding this comment

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

Did a first pass, but let me do a second pass next week. I think it's looking good, but I want to think some things through.

@@ -174,7 +175,7 @@ func TestRESTCalls(t *testing.T) {
log.Fatal(err)
}
if got, want := string(body), testCase.want; noSpace(got) != noSpace(want) {
t.Errorf("testcase %2d: body: got `%s`, want %s", idx, got, want)
t.Errorf("testcase %2d: body: got `%s`, want `%s`", idx, noSpace(got), noSpace(want))
Copy link
Contributor

Choose a reason for hiding this comment

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

use %q instead of backticking the %s.

Also, for the error message, isn';t it clearer to leave the whitespace in for readability?

Copy link
Member Author

Choose a reason for hiding this comment

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

👍
I think being able to see the real assert condition is more convenient. In my case e.g. there was an issue with a tab, invisible in the 'readable' version.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, so the problem might be that noSpace does not remove \t. Maybe it should, and then you can have the asserts use noSpace but the t.Errorf remain readable.

@@ -116,10 +119,13 @@ message RepeatRequest {
optional int32 p_int32 = 7;
optional int64 p_int64 = 8;
optional double p_double = 9;

optional string intended_binding_uri = 10;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would place this near the server_verify field, since it's not testing the data fromat preservation like the rest of the compliance suite is

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@@ -56,3 +56,6 @@ func init() {

RegexLiteral = fmt.Sprintf(`^[%s]+`, CharsLiteral)
}

// A key-type for storing binding URI value in the Context
type BindingURIKey string
Copy link
Contributor

@vchudnov-g vchudnov-g Jul 22, 2022

Choose a reason for hiding this comment

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

all the uses of this are BindingUriKey("bindingUri"), AFAICT. Why not define const BindingUriKey string="bindingUri"?

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

Copy link
Member Author

Choose a reason for hiding this comment

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

the constant has it's own string-derived type instead of string because (as I understand) the Context is a shared space so if someone else wants to have a "bindingUri" it'll be in a separate type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see what you mean about the type. The doc stipulates using non-built-in types to avoid collisions with other packages, since the type, not just the name, presumably plays a part in the lookup.

@@ -217,6 +217,16 @@ func prepRepeatDataPathResourceTest(request *genproto.RepeatRequest) (verb strin
name = "Compliance.RepeatDataPathResource"
info := request.GetInfo()

if strings.HasPrefix(info.GetFString(), "first/") {
return prepRepeatDataPathResourceTestFirstBinding(request)
Copy link
Contributor

Choose a reason for hiding this comment

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

(no action needed) I think this is fine, but it makes me think in the future we should change the first/ and second/ in the URL templates to other names for clarity, like blue and cyan or something.....

// Separately checking that the binding in the client request matches binding in the test suite.
// This guards against the test suite file being wrong on the client.
if expectedRequest.GetIntendedBindingUri() != received.GetIntendedBindingUri() {
return fmt.Errorf("(ComplianceSuiteRequestBindingMismatchError) intended binding of request %q do not match test suite (expected: %s, received: %s)", name, expectedRequest.GetIntendedBindingUri(), received.GetIntendedBindingUri())
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: s/do not/does not/

@@ -56,3 +56,6 @@ func init() {

RegexLiteral = fmt.Sprintf(`^[%s]+`, CharsLiteral)
}

// A key-type for storing binding URI value in the Context
type BindingURIKey string
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see what you mean about the type. The doc stipulates using non-built-in types to avoid collisions with other packages, since the type, not just the name, presumably plays a part in the lookup.

@@ -174,7 +175,7 @@ func TestRESTCalls(t *testing.T) {
log.Fatal(err)
}
if got, want := string(body), testCase.want; noSpace(got) != noSpace(want) {
t.Errorf("testcase %2d: body: got `%s`, want %s", idx, got, want)
t.Errorf("testcase %2d: body: got `%s`, want `%s`", idx, noSpace(got), noSpace(want))
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, so the problem might be that noSpace does not remove \t. Maybe it should, and then you can have the asserts use noSpace but the t.Errorf remain readable.

@viacheslav-rostovtsev viacheslav-rostovtsev merged commit 9d43ed0 into googleapis:main Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants