Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name">
        /// </param>
        public static async Task <Index> RecreateAsync(this IndexCollection indexes, string name)
        {
            Index index = await indexes.GetOrNullAsync(name);

            if (index != null)
            {
                await index.RemoveAsync();
            }

            await indexes.CreateAsync(name);

            index = await indexes.GetOrNullAsync(name);

            Assert.NotNull(index);

            return(index);
        }
Пример #2
0
        public async Task IndexCollection()
        {
            string indexName = string.Format("delete-me-{0}", Guid.NewGuid());

            using (var service = await SdkHelper.CreateService())
            {
                IndexCollection indexes = service.Indexes;

                Index testIndex = await indexes.CreateAsync(indexName);

                //// TODO: Verify testIndex

                await testIndex.GetAsync();

                //// TODO: Reverify testIndex

                await indexes.GetAllAsync();

                Assert.NotNull(indexes.SingleOrDefault(x => x.Title == testIndex.Title));

                foreach (Index index in indexes)
                {
                    int      dummyInt;
                    string   dummyString;
                    bool     dummyBool;
                    DateTime dummyTime;
                    dummyBool   = index.AssureUTF8;
                    dummyString = index.BlockSignatureDatabase;
                    dummyInt    = index.BlockSignSize;
                    dummyInt    = index.BloomFilterTotalSizeKB;
                    dummyString = index.ColdPath;
                    dummyString = index.ColdPathExpanded;
                    dummyString = index.ColdToFrozenDir;
                    dummyString = index.ColdToFrozenScript;
                    dummyBool   = index.CompressRawData;
                    long size = index.CurrentDBSizeMB;
                    dummyString = index.DefaultDatabase;
                    dummyBool   = index.EnableRealTimeSearch;
                    dummyInt    = index.FrozenTimePeriodInSecs;
                    dummyString = index.HomePath;
                    dummyString = index.HomePathExpanded;
                    dummyString = index.IndexThreads;
                    long time = index.LastInitTime;
                    dummyString = index.MaxBloomBackfillBucketAge;
                    dummyInt    = index.MaxConcurrentOptimizes;
                    dummyString = index.MaxDataSize;
                    dummyInt    = index.MaxHotBuckets;
                    dummyInt    = index.MaxHotIdleSecs;
                    dummyInt    = index.MaxHotSpanSecs;
                    dummyInt    = index.MaxMemMB;
                    dummyInt    = index.MaxMetaEntries;
                    dummyInt    = index.MaxRunningProcessGroups;
                    dummyTime   = index.MaxTime;
                    dummyInt    = index.MaxTotalDataSizeMB;
                    dummyInt    = index.MaxWarmDBCount;
                    dummyString = index.MemPoolMB;
                    dummyString = index.MinRawFileSyncSecs;
                    dummyTime   = index.MinTime;
                    dummyInt    = index.NumBloomFilters;
                    dummyInt    = index.NumHotBuckets;
                    dummyInt    = index.NumWarmBuckets;
                    dummyInt    = index.PartialServiceMetaPeriod;
                    dummyInt    = index.QuarantineFutureSecs;
                    dummyInt    = index.QuarantinePastSecs;
                    dummyInt    = index.RawChunkSizeBytes;
                    dummyInt    = index.RotatePeriodInSecs;
                    dummyInt    = index.ServiceMetaPeriod;
                    dummyString = index.SuppressBannerList;
                    bool sync = index.Sync;
                    dummyBool   = index.SyncMeta;
                    dummyString = index.ThawedPath;
                    dummyString = index.ThawedPathExpanded;
                    dummyInt    = index.ThrottleCheckPeriod;
                    long eventCount = index.TotalEventCount;
                    dummyBool = index.Disabled;
                    dummyBool = index.IsInternal;
                }

                for (int i = 0; i < indexes.Count; i++)
                {
                    Index index = indexes[i];

                    int      dummyInt;
                    string   dummyString;
                    bool     dummyBool;
                    DateTime dummyTime;
                    dummyBool   = index.AssureUTF8;
                    dummyString = index.BlockSignatureDatabase;
                    dummyInt    = index.BlockSignSize;
                    dummyInt    = index.BloomFilterTotalSizeKB;
                    dummyString = index.ColdPath;
                    dummyString = index.ColdPathExpanded;
                    dummyString = index.ColdToFrozenDir;
                    dummyString = index.ColdToFrozenScript;
                    dummyBool   = index.CompressRawData;
                    long size = index.CurrentDBSizeMB;
                    dummyString = index.DefaultDatabase;
                    dummyBool   = index.EnableRealTimeSearch;
                    dummyInt    = index.FrozenTimePeriodInSecs;
                    dummyString = index.HomePath;
                    dummyString = index.HomePathExpanded;
                    dummyString = index.IndexThreads;
                    long time = index.LastInitTime;
                    dummyString = index.MaxBloomBackfillBucketAge;
                    dummyInt    = index.MaxConcurrentOptimizes;
                    dummyString = index.MaxDataSize;
                    dummyInt    = index.MaxHotBuckets;
                    dummyInt    = index.MaxHotIdleSecs;
                    dummyInt    = index.MaxHotSpanSecs;
                    dummyInt    = index.MaxMemMB;
                    dummyInt    = index.MaxMetaEntries;
                    dummyInt    = index.MaxRunningProcessGroups;
                    dummyTime   = index.MaxTime;
                    dummyInt    = index.MaxTotalDataSizeMB;
                    dummyInt    = index.MaxWarmDBCount;
                    dummyString = index.MemPoolMB;
                    dummyString = index.MinRawFileSyncSecs;
                    dummyTime   = index.MinTime;
                    dummyInt    = index.NumBloomFilters;
                    dummyInt    = index.NumHotBuckets;
                    dummyInt    = index.NumWarmBuckets;
                    dummyInt    = index.PartialServiceMetaPeriod;
                    dummyInt    = index.QuarantineFutureSecs;
                    dummyInt    = index.QuarantinePastSecs;
                    dummyInt    = index.RawChunkSizeBytes;
                    dummyInt    = index.RotatePeriodInSecs;
                    dummyInt    = index.ServiceMetaPeriod;
                    dummyString = index.SuppressBannerList;
                    bool sync = index.Sync;
                    dummyBool   = index.SyncMeta;
                    dummyString = index.ThawedPath;
                    dummyString = index.ThawedPathExpanded;
                    dummyInt    = index.ThrottleCheckPeriod;
                    long eventCount = index.TotalEventCount;
                    dummyBool = index.Disabled;
                    dummyBool = index.IsInternal;
                }

                var attributes = GetIndexAttributes(testIndex);

                attributes.BlockSignSize             = testIndex.BlockSignSize + 1;
                attributes.EnableOnlineBucketRepair  = !testIndex.EnableOnlineBucketRepair;
                attributes.MaxBloomBackfillBucketAge = "20d";
                attributes.FrozenTimePeriodInSecs    = testIndex.FrozenTimePeriodInSecs + 1;
                attributes.MaxConcurrentOptimizes    = testIndex.MaxConcurrentOptimizes + 1;
                attributes.MaxDataSize              = "auto";
                attributes.MaxHotBuckets            = testIndex.MaxHotBuckets + 1;
                attributes.MaxHotIdleSecs           = testIndex.MaxHotIdleSecs + 1;
                attributes.MaxMemMB                 = testIndex.MaxMemMB + 1;
                attributes.MaxMetaEntries           = testIndex.MaxMetaEntries + 1;
                attributes.MaxTotalDataSizeMB       = testIndex.MaxTotalDataSizeMB + 1;
                attributes.MaxWarmDBCount           = testIndex.MaxWarmDBCount + 1;
                attributes.MinRawFileSyncSecs       = "disable";
                attributes.PartialServiceMetaPeriod = testIndex.PartialServiceMetaPeriod + 1;
                attributes.QuarantineFutureSecs     = testIndex.QuarantineFutureSecs + 1;
                attributes.QuarantinePastSecs       = testIndex.QuarantinePastSecs + 1;
                attributes.RawChunkSizeBytes        = testIndex.RawChunkSizeBytes + 1;
                attributes.RotatePeriodInSecs       = testIndex.RotatePeriodInSecs + 1;
                attributes.ServiceMetaPeriod        = testIndex.ServiceMetaPeriod + 1;
                attributes.SyncMeta                 = !testIndex.SyncMeta;
                attributes.ThrottleCheckPeriod      = testIndex.ThrottleCheckPeriod + 1;

                bool updatedSnapshot = await testIndex.UpdateAsync(attributes);

                Assert.True(updatedSnapshot);

                await testIndex.DisableAsync();

                Assert.True(testIndex.Disabled);                  // Because the disable endpoint returns an updated snapshot

                await service.Server.RestartAsync(2 * 60 * 1000); // Because you can't re-enable an index without a restart

                await service.LogOnAsync();

                testIndex = await service.Indexes.GetAsync(indexName);

                await testIndex.EnableAsync(); // Because the enable endpoint returns an updated snapshot

                Assert.False(testIndex.Disabled);

                await testIndex.RemoveAsync();

                await SdkHelper.ThrowsAsync <ResourceNotFoundException>(async() =>
                {
                    await testIndex.GetAsync();
                });

                testIndex = await indexes.GetOrNullAsync(indexName);

                Assert.Null(testIndex);
            }
        }