<commit_before>﻿//-----------------------------------------------------------------------
// <copyright file="ClusterShardingConfigSpec.cs" company="Akka.NET Project">
//     Copyright (C) 2009-2018 Lightbend Inc. <http://www.lightbend.com>
//     Copyright (C) 2013-2018 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
//-----------------------------------------------------------------------

using System;
using Akka.Configuration;
using Akka.DistributedData;
using Akka.DistributedData.Internal;
using Akka.DistributedData.Serialization;
using FluentAssertions;
using Xunit;
using Xunit.Abstractions;

namespace Akka.Cluster.Sharding.Tests
{
    public class ClusterShardingConfigSpec : Akka.TestKit.Xunit2.TestKit
    {
        public ClusterShardingConfigSpec() : base(GetConfig())
        {
        }

        public static Config GetConfig()
        {
            return ConfigurationFactory.ParseString("akka.actor.provider = \"Akka.Cluster.ClusterActorRefProvider, Akka.Cluster\"");
        }

        [Fact]
        public void Should_cluster_sharding_settings_have_default_config()
        {
            ClusterSharding.Get(Sys);
            var config = Sys.Settings.Config.GetConfig("akka.cluster.sharding");

            Assert.NotNull(config);
            Assert.Equal("sharding", config.GetString("guardian-name"));
            Assert.Equal(string.Empty, config.GetString("role"));
            Assert.False(config.GetBoolean("remember-entities"));
            Assert.Equal(TimeSpan.FromSeconds(5), config.GetTimeSpan("coordinator-failure-backoff"));
            Assert.Equal(TimeSpan.FromSeconds(2), config.GetTimeSpan("retry-interval"));
            Assert.Equal(100000, config.GetInt("buffer-size"));
            Assert.Equal(TimeSpan.FromSeconds(60), config.GetTimeSpan("handoff-timeout"));
            Assert.Equal(TimeSpan.FromSeconds(10), config.GetTimeSpan("shard-start-timeout"));
            Assert.Equal(TimeSpan.FromSeconds(10), config.GetTimeSpan("entity-restart-backoff"));
            Assert.Equal(TimeSpan.FromSeconds(10), config.GetTimeSpan("rebalance-interval"));
            Assert.Equal(string.Empty, config.GetString("journal-plugin-id"));
            Assert.Equal(string.Empty, config.GetString("snapshot-plugin-id"));
            Assert.Equal("persistence", config.GetString("state-store-mode"));
            Assert.Equal(TimeSpan.FromSeconds(5), config.GetTimeSpan("waiting-for-state-timeout"));
            Assert.Equal(TimeSpan.FromSeconds(5), config.GetTimeSpan("updating-state-timeout"));
            Assert.Equal("akka.cluster.singleton", config.GetString("coordinator-singleton"));
            Assert.Equal(string.Empty, config.GetString("use-dispatcher"));

            Assert.Equal(10, config.GetInt("least-shard-allocation-strategy.rebalance-threshold"));
            Assert.Equal(3, config.GetInt("least-shard-allocation-strategy.max-simultaneous-rebalance"));

            Assert.Equal("all", config.GetString("entity-recovery-strategy"));
            Assert.Equal(TimeSpan.FromMilliseconds(100), config.GetTimeSpan("entity-recovery-constant-rate-strategy.frequency"));
            Assert.Equal(5, config.GetInt("entity-recovery-constant-rate-strategy.number-of-entities"));

            var singletonConfig = Sys.Settings.Config.GetConfig("akka.cluster.singleton");

            Assert.NotNull(singletonConfig);
            Assert.Equal("singleton", singletonConfig.GetString("singleton-name"));
            Assert.Equal(string.Empty, singletonConfig.GetString("role"));
            Assert.Equal(TimeSpan.FromSeconds(1), singletonConfig.GetTimeSpan("hand-over-retry-interval"));
            Assert.Equal(10, singletonConfig.GetInt("min-number-of-hand-over-retries"));
        }
    }

    public class DDataClusterShardingConfigSpec : TestKit.Xunit2.TestKit
    {
        public DDataClusterShardingConfigSpec(ITestOutputHelper helper) : base(GetConfig(), output:helper)
        {
        }

        public static Config GetConfig()
        {
            return ConfigurationFactory.ParseString(@"akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
                akka.cluster.sharding.state-store-mode = ddata
            ");
        }

        [Fact]
        public void Should_load_DData_serializers_when_enabled()
        {
            ClusterSharding.Get(Sys);

            var rmSerializer = Sys.Serialization.FindSerializerFor(WriteAck.Instance);
            rmSerializer.Should().BeOfType<ReplicatorMessageSerializer>();

            var rDSerializer = Sys.Serialization.FindSerializerFor(ORDictionary<string, GSet<string>>.Empty);
            rDSerializer.Should().BeOfType<ReplicatedDataSerializer>();
        }
    }
}<commit_msg>removed duplicate spec<commit_after>﻿//-----------------------------------------------------------------------
// <copyright file="ClusterShardingConfigSpec.cs" company="Akka.NET Project">
//     Copyright (C) 2009-2018 Lightbend Inc. <http://www.lightbend.com>
//     Copyright (C) 2013-2018 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
//-----------------------------------------------------------------------

using System;
using Akka.Configuration;
using Xunit;

namespace Akka.Cluster.Sharding.Tests
{
    public class ClusterShardingConfigSpec : Akka.TestKit.Xunit2.TestKit
    {
        public ClusterShardingConfigSpec() : base(GetConfig())
        {
        }

        public static Config GetConfig()
        {
            return ConfigurationFactory.ParseString("akka.actor.provider = \"Akka.Cluster.ClusterActorRefProvider, Akka.Cluster\"");
        }

        [Fact]
        public void Should_cluster_sharding_settings_have_default_config()
        {
            ClusterSharding.Get(Sys);
            var config = Sys.Settings.Config.GetConfig("akka.cluster.sharding");

            Assert.NotNull(config);
            Assert.Equal("sharding", config.GetString("guardian-name"));
            Assert.Equal(string.Empty, config.GetString("role"));
            Assert.False(config.GetBoolean("remember-entities"));
            Assert.Equal(TimeSpan.FromSeconds(5), config.GetTimeSpan("coordinator-failure-backoff"));
            Assert.Equal(TimeSpan.FromSeconds(2), config.GetTimeSpan("retry-interval"));
            Assert.Equal(100000, config.GetInt("buffer-size"));
            Assert.Equal(TimeSpan.FromSeconds(60), config.GetTimeSpan("handoff-timeout"));
            Assert.Equal(TimeSpan.FromSeconds(10), config.GetTimeSpan("shard-start-timeout"));
            Assert.Equal(TimeSpan.FromSeconds(10), config.GetTimeSpan("entity-restart-backoff"));
            Assert.Equal(TimeSpan.FromSeconds(10), config.GetTimeSpan("rebalance-interval"));
            Assert.Equal(string.Empty, config.GetString("journal-plugin-id"));
            Assert.Equal(string.Empty, config.GetString("snapshot-plugin-id"));
            Assert.Equal("persistence", config.GetString("state-store-mode"));
            Assert.Equal(TimeSpan.FromSeconds(5), config.GetTimeSpan("waiting-for-state-timeout"));
            Assert.Equal(TimeSpan.FromSeconds(5), config.GetTimeSpan("updating-state-timeout"));
            Assert.Equal("akka.cluster.singleton", config.GetString("coordinator-singleton"));
            Assert.Equal(string.Empty, config.GetString("use-dispatcher"));

            Assert.Equal(10, config.GetInt("least-shard-allocation-strategy.rebalance-threshold"));
            Assert.Equal(3, config.GetInt("least-shard-allocation-strategy.max-simultaneous-rebalance"));

            Assert.Equal("all", config.GetString("entity-recovery-strategy"));
            Assert.Equal(TimeSpan.FromMilliseconds(100), config.GetTimeSpan("entity-recovery-constant-rate-strategy.frequency"));
            Assert.Equal(5, config.GetInt("entity-recovery-constant-rate-strategy.number-of-entities"));

            var singletonConfig = Sys.Settings.Config.GetConfig("akka.cluster.singleton");

            Assert.NotNull(singletonConfig);
            Assert.Equal("singleton", singletonConfig.GetString("singleton-name"));
            Assert.Equal(string.Empty, singletonConfig.GetString("role"));
            Assert.Equal(TimeSpan.FromSeconds(1), singletonConfig.GetTimeSpan("hand-over-retry-interval"));
            Assert.Equal(10, singletonConfig.GetInt("min-number-of-hand-over-retries"));
        }
    }
}
{'fraction_non_alphanumeric': 0.16630824372759856, 'fraction_numerical': 0.010872162485065711, 'mean_word_length': 2.846966911764706, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4826305', 'n_tokens_mistral': 2307, 'n_tokens_neox': 2232, 'n_words': 255}