Integration testing

Is there any way to run integration tests in some sort of separated namespace against a single DGraph instance? Or run super light weight instances of DGraph for small targeted single function integration tests?

I have a number of integration tests and ideally they would run in parallel, however for each test I am often dropping and re-creating the DB so I have it in a known state. The issue here is when one test drops the db while another one is running, the running test fails. So I am now running them serially.

Does Dgraph have any features for running tests in parallel? I looked but could not see any.

It would be great if there was some types of namespace option maybe when you instantiate a new client, I think that would go some way to solving my problem. It would also be great if you could delete all the name-spaced test data when closing the client.

I Imagine the namespace would just prepend itself to every predicate seamlessly

Something like this:

    
 const namespace = `testName-${(new Date).toISOString}`
 const dgraphClientStub = new dgraph.DgraphClientStub(
        address,
        grpcCredentials,
        namespace,
    );

    // or 

    dgraphClientStub.setNamespace(namespace)

    // after tests run
    dgraphClientStub.closeAndDelete({reallyDelete: true});

Unfortunately, partitioning the graph by namespaces isn’t supported yet.

If your tests just query the database, then you could maybe load the data in an initial populate step and then query in parallel.

Thank you for the quick reply @pawan.

I did think the same thing, and I was just discussing that very idea with a friend. I have reservations about coding it that way. I feel that overtime the tests will become unwieldy if I just keep adding to a huge block of setup date. In turn making each individual test harder to read than they should/would be.

As the app is new test time is not a big issue just yet, this is just my engineering brain optimising! So I resolved with my friend I should just write the test’s in what I feel is the “better”, small separate setup blocks, and not parallelise, hoping a feature like this will be added to the DB sometime in the future.

Do you think you will be adding support for namespaces or any other feature that will help with testing any time soon (6-12 months).

Maybe you could add something like this to the end of your roadmap? Not sure how hard a feature like this would be, or how many other people will want it.

We use this approach at https://github.com/dgraph-io/dgraph/blob/master/systest/mutations_test.go#L19 for your reference.

There is already an open issue for this at https://github.com/dgraph-io/dgraph/issues/1143. We should be doing it in the next 6-12 months for sure.

@pawan

Thanks, that’s helpful! I will follow that issue.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.