-
Notifications
You must be signed in to change notification settings - Fork 247
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
Add an integration test for the test server #115
Conversation
5c2f56f
to
37c22aa
Compare
580c980
to
8ef4f33
Compare
// Give the service time to boot. | ||
iterationCount := 0 | ||
for { | ||
iterationCount++ |
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.
let's use require.Eventually
here too
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.
ooo. Very cool
require.NoError(t, err) | ||
require.Equal(t, v1.CheckPermissionResponse_PERMISSIONSHIP_HAS_PERMISSION, v1Resp.Permissionship) | ||
|
||
// Ensure check against readonly works as well. |
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.
add a check that a write against readonly fails
8ef4f33
to
5079b43
Compare
Updated |
@@ -0,0 +1,212 @@ | |||
//go:build withcontainerimage | |||
// +build withcontainerimage |
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.
can we standardize on a build tag? maybe replace this and ci
with docker
since that's what this requires
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.
I'll change to docker
, but leaving CI
as is
- uses: "actions/setup-go@v2" | ||
with: | ||
go-version: "^1.17" | ||
- name: "Test with image" |
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 maybe want to repurpose this whole job to be for e2e tests and eventually have evan's e2e tests run in here, too
|
||
func TestTestServer(t *testing.T) { | ||
tester, err := newTester(t, | ||
&dockertest.RunOptions{ |
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.
It'd be great if this could build the image, too so that devs can't accidentally run these tests with stale images.
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.
I'd have to wire up the Docker API calls too; I think we should just move newTester
into a util package, export it, and then optionally add a "build it not present" flag to it
}, | ||
}, | ||
}, | ||
}) |
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.
style nitpick that i think makes things more readable
_, err = rov0client.Write(context.Background(), &v0.WriteRequest{
Updates: []*v0.RelationTupleUpdate{{ // <----
Operation: v0.RelationTupleUpdate_CREATE,
Tuple: &v0.RelationTuple{
ObjectAndRelation: &v0.ObjectAndRelation{
Namespace: "resource",
ObjectId: "someresource",
Relation: "reader",
},
User: &v0.User{UserOneof: &v0.User_Userset{Userset: &v0.ObjectAndRelation{
Namespace: "user",
ObjectId: "somegal",
Relation: "...",
}}},
},
}},
})
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.
I actually disagree; I'd wonder how I'm adding a single item directly to the slice
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.
well, this is how it's done in many places in the codebase, so we should pick one
Updates: []*v0.RelationTupleUpdate{ | ||
{ | ||
Operation: v0.RelationTupleUpdate_CREATE, | ||
Tuple: &v0.RelationTuple{ |
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.
can't we declare a variable for this tuple? we're reusing it here
that'd even let us use tuple.ToRelationship
in the other test
cleanup func() | ||
} | ||
|
||
func newTester(t *testing.T, containerOpts *dockertest.RunOptions) (*spicedbHandle, error) { |
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.
I really don't like this function name or design even as we've used it in the other tests.
It doesn't have the container details in it, but it does have the knowledge that the container will somehow be SpiceDB because of the healthcheck built into it.
Now that we've copied and pasted this code a few places, can we make it more generic?
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.
Personally, I want it into a util package that SpiceDB exports
&dockertest.RunOptions{ | ||
Repository: "authzed/spicedb", | ||
Tag: "latest", | ||
Cmd: []string{"spicedb", "serve-testing", "--log-level", "debug"}, |
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.
What about moving this into the e2e
package from #75? the test would build/run much faster, and avoid the need for build tags (plus that e2e GHA already handles caching).
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.
I explicitly want this tested against the built binary image, as that's how people are going to be using it most of the time. Unless I'm mistaken, #75 doesn't run the server as a distinct binary?
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.
It does, it exec
s the built spicedb
5079b43
to
8d31dab
Compare
Updated, but still using Docker. Will issue a followup commit to change to use the e2e stuff once in |
8d31dab
to
a8fe8f1
Compare
a8fe8f1
to
fe5c7bb
Compare
Signed-off-by: Joseph Schorr <josephschorr@users.noreply.github.com>
fe5c7bb
to
d841e87
Compare
I'd rather this go in now and get cleaned up later than have the branch stagnate.
No description provided.