orleans icon indicating copy to clipboard operation
orleans copied to clipboard

Getting exception when instantiating TestCluster object using TestCluster(ClusterConfiguration clusterConfiguration, ClientConfiguration clientConfiguration) constructor

Open dyereve opened this issue 9 years ago • 8 comments

Hello everyone, I'm trying to use TestCluster inside my integration testing class. I'm doing something like the following:

ClusterConfiguration clusterConfig;
var serverConfigFile = (AppDomain.CurrentDomain.BaseDirectory +"\\DevTestServerConfiguration.xml");
            using (TextReader sr = new StringReader(File.OpenText(serverConfigFile).ReadToEnd()))
            {
                clusterConfig = new ClusterConfiguration(sr);
            }
ClientConfiguration clientConfig;
 var clientConfigFile = (AppDomain.CurrentDomain.BaseDirectory +"\\DevTestClientConfiguration.xml");
            using (TextReader sr = new StringReader(File.OpenText(clientConfigFile).ReadToEnd()))
            {
                clientConfig = new ClientConfiguration();
                clientConfig.Load(sr);
            }
			this.HostedCluster = new TestCluster();
  #region SetManuallyProviderConfiguration
            foreach (var item in clusterConfig.Globals.ProviderConfigurations)
            {
                this.HostedCluster.ClusterConfiguration.Globals.ProviderConfigurations.Add(item);
            }

            foreach (var item in clientConfig.ProviderConfigurations)
            {
                this.HostedCluster.ClientConfiguration.ProviderConfigurations.Add(item);
            }
			#endregion  
            if (this.HostedCluster.Primary == null)
            {
                    HostedCluster.Deploy();
            }

... the above code working as a charm but when i try to instantiate TestCluster object passing ClusterConfiguration and ClientConfiguration directly to the constructor (replacing #region ManuallySetProviderConfigurations snippet with the following) :

this.HostedCluster = new TestCluster(clusterConfig, clientConfig);

...i'm getting the following exception when it tries to execute HostedCluster.Deploy():

Message = "The target silo became unavailable for message: Request *cli/9f78b28f@3ca3eb98->S127.0.0.1:40000:0TypeManagerId@S00000011 #2: global::Orleans.Runtime.ITypeManager:GetTypeCodeMap(). Target History is: S127.0.0.1:40000:0:TypeManagerId:@S00000011. See https...

Any ideas why is that happening?

dyereve avatar Dec 06 '16 13:12 dyereve

In the working scenario, you used this.HostedCluster = new TestCluster(); and you feed ProviderConfigurations from xml config file to your HostedCluster. In this case, HostedCluster will use default value for other configuration.

While in the non-working scenario, you feed all the config in your DevTestServerConfiguration.xml and DevTestClientConfiguration.xml to your HosterCluster by using new TestCluster(clusterConfig, clientConfig). And it stopped working. I suspect there's incorrect config value in your xml config files. Mind share them so we can see what's going on?

Sorry for the late response. Hopefully you already find the answer.

xiazen avatar Dec 28 '16 00:12 xiazen

@dyereve, have you solved the problem already?

sergeybykov avatar Jan 03 '17 15:01 sergeybykov

Hello, I'm on vacations currently an i m expected to return to my duties in a couple of days. I receive the email from one of your team members but I didn't make any progress on that for the same reason.I' ll give you my feedback in the next few days. Cheers! Achilles

Get Outlook for Androidhttps://aka.ms/ghei36

On Tue, Jan 3, 2017 at 3:53 PM +0000, "Sergey Bykov" <[email protected]mailto:[email protected]> wrote:

@dyerevehttps://github.com/dyereve, have you solved the problem already?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/dotnet/orleans/issues/2489#issuecomment-270146141, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AVsUnL-gDjN7glwn0DNLoqyKU8fUyuM4ks5rOm7vgaJpZM4LFZsH.

dyereve avatar Jan 03 '17 23:01 dyereve

Hello, I attached the configuration files as you asked me. Unfortunately i didn't find yet a solution on how to use the TestCluster object passing clusterConfig and clientConfig directly on constructor.

DevTestClientConfiguration.txt DevTestServerConfiguration.txt

Thank you!

dyereve avatar Jan 05 '17 14:01 dyereve

You need to add Override config to your cluster config, such as

<Override Node="Primary">
  <Networking Port="22222" />
</Override>

When TestCluster deploy, it deploys a list of silo names from its ClusterConfiguration.Overrides.Keys. See TestCluster.cs ->

        public void Deploy()
        {
            this.Deploy(this.ClusterConfiguration.Overrides.Keys);
        }

Otherwise it cannot find any silo to deploy, hence the "The target silo became unavailable " exception

xiazen avatar Jan 06 '17 22:01 xiazen

I tested your cluster config + new Override config.txt with code snippet :


namespace UnitTests
{
    public class TestClusterTests : TestClusterPerTest
    {
        public override TestCluster CreateTestCluster()
        {

            ClusterConfiguration clusterConfig;
            var serverConfigFile = "DevTestServerConfiguration.xml";
            using (TextReader sr = new StringReader(File.OpenText(serverConfigFile).ReadToEnd()))
            {
                clusterConfig = new ClusterConfiguration(sr);
            }
            ClientConfiguration clientConfig;
            var clientConfigFile = "DevTestClientConfiguration.xml";
            using (TextReader sr = new StringReader(File.OpenText(clientConfigFile).ReadToEnd()))
            {
                clientConfig = new ClientConfiguration();
                clientConfig.Load(sr);
            }

          return new TestCluster(clusterConfig, clientConfig);
        }

        [Fact, TestCategory("Functional"), TestCategory("TestCluster")]
        public async Task TestClusterTests1()
        {
            Assert.NotNull(this.HostedCluster.Primary);
            ISimpleGrain grain = GrainClient.GrainFactory.GetGrain<ISimpleGrain>(random.Next(), SimpleGrain.SimpleGrainNamePrefix);
            await grain.SetA(1);
            Assert.Equal(await grain.GetA(), 1);
        }
    }
}

The test passed. Let me know if you have further issues

xiazen avatar Jan 06 '17 22:01 xiazen

@dyereve does the fix work for you?

xiazen avatar Jan 09 '17 19:01 xiazen

closing this issue, feel free to reopen it if you still have other problems

xiazen avatar Jan 12 '17 20:01 xiazen