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

Call an initial check request to load schema #306

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
35 changes: 35 additions & 0 deletions test/kessel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,47 @@ func TestMain(m *testing.M) {

wg.Wait()

// make initial empty request to load schema for first time use.
localKesselContainer.spicedbContainer.WaitForQuantizationInterval()
err = loadSchema()
if err != nil {
localKesselContainer.Close()
panic(fmt.Errorf("Failed to load schema, %w", err))
}
// wait a bit before activating tests that will actually use the loaded schema
localKesselContainer.spicedbContainer.WaitForQuantizationInterval()

result := m.Run()

localKesselContainer.Close()
os.Exit(result)
}

func loadSchema() error {
kcurl := fmt.Sprintf("http://localhost:%s", localKesselContainer.kccontainer.GetPort("8080/tcp"))
token, err := GetJWTToken(kcurl, "admin", "admin")
if err != nil {
fmt.Print(err)
}
conn, err := grpc.NewClient(
fmt.Sprintf("localhost:%s", localKesselContainer.gRPCport),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpcutil.WithInsecureBearerToken(token.AccessToken),
)
if err != nil {
fmt.Print(err)
}

client := v1beta1.NewKesselTupleServiceClient(conn)

// send empty CreateTuplesRequest to hit service and load schema.
_, err = client.CreateTuples(context.Background(), &v1beta1.CreateTuplesRequest{})
if err != nil {
return err
}
return nil
}

func TestKesselAPIGRPC_CreateTuples(t *testing.T) {
t.Parallel()
kcurl := fmt.Sprintf("http://localhost:%s", localKesselContainer.kccontainer.GetPort("8080/tcp"))
Expand Down
Loading