public void TestChangeCompactionProperties()
        {
            var scheme = new KeyspaceScheme
            {
                Name          = TestSchemaUtils.GetRandomKeyspaceName(),
                Configuration = new KeyspaceConfiguration
                {
                    ColumnFamilies = new[]
                    {
                        new ColumnFamily
                        {
                            Name = "CF1"
                        }
                    }
                }
            };

            ActualizeKeyspaces(scheme);
            Assert.That(cluster.UpdateColumnFamilyInvokeCount, Is.EqualTo(0));

            scheme.Configuration.ColumnFamilies[0].CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategy(4, 32);
            ActualizeKeyspaces(scheme);
            Assert.That(cluster.UpdateColumnFamilyInvokeCount, Is.EqualTo(0));

            scheme.Configuration.ColumnFamilies[0].CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategy(3, 32);
            ActualizeKeyspaces(scheme);
            Assert.That(cluster.UpdateColumnFamilyInvokeCount, Is.EqualTo(1));

            scheme.Configuration.ColumnFamilies[0].CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategy(3, 31);
            ActualizeKeyspaces(scheme);
            Assert.That(cluster.UpdateColumnFamilyInvokeCount, Is.EqualTo(2));

            ActualizeKeyspaces(scheme);
            Assert.That(cluster.UpdateColumnFamilyInvokeCount, Is.EqualTo(2));

            scheme.Configuration.ColumnFamilies[0].CompactionStrategy = CompactionStrategy.LeveledCompactionStrategy(10);
            ActualizeKeyspaces(scheme);
            Assert.That(cluster.UpdateColumnFamilyInvokeCount, Is.EqualTo(3));

            scheme.Configuration.ColumnFamilies[0].CompactionStrategy = CompactionStrategy.LeveledCompactionStrategy(11);
            ActualizeKeyspaces(scheme);
            Assert.That(cluster.UpdateColumnFamilyInvokeCount, Is.EqualTo(4));

            scheme.Configuration.ColumnFamilies[0].CompactionStrategy = CompactionStrategy.LeveledCompactionStrategy(11);
            ActualizeKeyspaces(scheme);
            Assert.That(cluster.UpdateColumnFamilyInvokeCount, Is.EqualTo(4));
        }
        public void TestUpdateColumnFamily()
        {
            var name = TestSchemaUtils.GetRandomColumnFamilyName();
            var originalColumnFamily = new ColumnFamily
            {
                Name = name,
                CompactionStrategy = CompactionStrategy.LeveledCompactionStrategy(sstableSizeInMb: 10),
                GCGraceSeconds     = 123,
                ReadRepairChance   = 0.3,
                Caching            = ColumnFamilyCaching.All
            };

            keyspaceConnection.AddColumnFamily(originalColumnFamily);

            originalColumnFamily.CompactionStrategy = CompactionStrategy.LeveledCompactionStrategy(sstableSizeInMb: 20);
            originalColumnFamily.GCGraceSeconds     = 321;
            originalColumnFamily.ReadRepairChance   = 0.9;
            originalColumnFamily.Caching            = ColumnFamilyCaching.None;
            keyspaceConnection.UpdateColumnFamily(originalColumnFamily);

            var columnFamily = keyspaceConnection.DescribeKeyspace().ColumnFamilies[name];

            Assert.That(columnFamily.Name, Is.EqualTo(originalColumnFamily.Name));
            Assert.That(columnFamily.CompactionStrategy.CompactionStrategyType, Is.EqualTo(originalColumnFamily.CompactionStrategy.CompactionStrategyType));
            Assert.That(columnFamily.CompactionStrategy.CompactionStrategyOptions.SstableSizeInMb, Is.EqualTo(originalColumnFamily.CompactionStrategy.CompactionStrategyOptions.SstableSizeInMb));
            Assert.That(columnFamily.GCGraceSeconds, Is.EqualTo(originalColumnFamily.GCGraceSeconds));
            Assert.That(columnFamily.ReadRepairChance, Is.EqualTo(originalColumnFamily.ReadRepairChance));

            originalColumnFamily.CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategy(minThreshold: 5, maxThreshold: 17);
            keyspaceConnection.UpdateColumnFamily(originalColumnFamily);

            columnFamily = keyspaceConnection.DescribeKeyspace().ColumnFamilies[name];
            Assert.That(columnFamily.Name, Is.EqualTo(originalColumnFamily.Name));
            Assert.That(columnFamily.CompactionStrategy.CompactionStrategyType, Is.EqualTo(originalColumnFamily.CompactionStrategy.CompactionStrategyType));
            Assert.That(columnFamily.CompactionStrategy.CompactionStrategyOptions.Enabled, Is.EqualTo(originalColumnFamily.CompactionStrategy.CompactionStrategyOptions.Enabled));
            Assert.That(columnFamily.CompactionStrategy.CompactionStrategyOptions.MinThreshold, Is.EqualTo(originalColumnFamily.CompactionStrategy.CompactionStrategyOptions.MinThreshold));
            Assert.That(columnFamily.CompactionStrategy.CompactionStrategyOptions.MaxThreshold, Is.EqualTo(originalColumnFamily.CompactionStrategy.CompactionStrategyOptions.MaxThreshold));
            Assert.That(columnFamily.GCGraceSeconds, Is.EqualTo(originalColumnFamily.GCGraceSeconds));
            Assert.That(columnFamily.ReadRepairChance, Is.EqualTo(originalColumnFamily.ReadRepairChance));
        }
 public void TestCompareColumnFamiliesByCompactionStrategy()
 {
     Assert.That(
         !comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.LeveledCompactionStrategy(10)
     },
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.LeveledCompactionStrategy(10)
     })
         );
     Assert.That(
         !comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.LeveledCompactionStrategyDisabled()
     },
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.LeveledCompactionStrategyDisabled()
     })
         );
     Assert.That(
         !comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategy(4, 32)
     },
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategy(4, 32)
     })
         );
     Assert.That(
         !comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategyDisabled()
     },
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategyDisabled()
     })
         );
     Assert.That(
         !comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategyDisabled()
     },
             new ColumnFamily {
         Name = "name", CompactionStrategy = new CompactionStrategy(CompactionStrategyType.SizeTiered, new CompactionStrategyOptions {
             Enabled = false, MinThreshold = 4, MaxThreshold = 32
         })
     })
         );
     Assert.That(
         comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategy(4, 32)
     },
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategyDisabled()
     })
         );
     Assert.That(
         comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategy(4, 32)
     },
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategy(16, 32)
     })
         );
     Assert.That(
         comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategy(4, 32)
     },
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategy(4, 16)
     })
         );
     Assert.That(
         comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.LeveledCompactionStrategy(20)
     },
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.LeveledCompactionStrategy(10)
     })
         );
     Assert.That(
         comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.LeveledCompactionStrategy(4)
     },
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategy(4, 4)
     })
         );
     Assert.That(
         comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.LeveledCompactionStrategyDisabled()
     },
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.SizeTieredCompactionStrategyDisabled()
     })
         );
     Assert.That(
         comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", CompactionStrategy = CompactionStrategy.LeveledCompactionStrategyDisabled()
     },
             new ColumnFamily {
         Name = "name", CompactionStrategy = null
     })
         );
 }