orleans icon indicating copy to clipboard operation
orleans copied to clipboard

Testing scenarios and approaches for unit testing user code

Open ashkan-saeedi-mazdeh opened this issue 10 years ago • 1 comments

I was updating the documentation in the Unit Tests page and I realized that the new awesome TestCluster doesn't work automatically simply if you derive from it like it was the case for TestingSiloHost

In the case of TestingSiloHost , the default constructor for the class was creating 2 silos and also a default memory storage provider was being created as well.

Now the question is, should we add the configuration as a mandatory step for users which want to test their grain code? or we should modify the TestCluster ?

I'm ok with both, want to know what should I do to do it and send a PR.

Also TestingSiloHost had a static method to stop all silos which could be used in MS test cleanup like this

[ClassCleanup]
        private static void CleanUp()
        {
            StopAllSilosIfRunning();
        }

Should we add that to the TestCluster as well?

ashkan-saeedi-mazdeh avatar Aug 08 '16 08:08 ashkan-saeedi-mazdeh

Hi @ashkan-saeedi-mazdeh

Thanks for updating our documentation, we really need that !!

Regards the question of new TestCluster, it is indeed slightly different from the old TestingSiloHost in aspect of their default constructor, but I want to clarify couple points.

  1. when default constructor new TestCluster() is used, two silos are creating by default, with livenessServiceType as MembershipTableGrain. And it also init a client with default client config too. You can see a glimpse of part of the default TestClusterOptions in TestClusterOPtions.FallbackOptions class, where initialSiloCount are set to 2.
  2. And also TestCluster has a StopAllSilos(), which I think it is equivalent to StopAllSilosIfRunning() but not a static method.

But you are right about that the default TestCluster doesn't have a storage provider configured. You need to configure it using

options.ClusterConfiguration.AddMemoryStorageProvider("Default");
options.ClusterConfiguration.AddMemoryStorageProvider("MemoryStore");'

But storage provider is not mandatory for every grain tests, only needed for cases like testing persistence. So I hold the opinion to not add this as a default config to default TestCluster. So default TestCluster is a working cluster with minimum resource configured (MVP!).

xiazen avatar Jan 07 '17 01:01 xiazen