Exemplo n.º 1
0
        public async Task ListCreateAndRemoveAggreationTableForAPeriod_ValidRequest_TableExists()
        {
            var testAggregationPeriod = DateTimeOffset.Parse("2018-10-11 13:00", null, DateTimeStyles.AssumeUniversal);
            var tableName             = AggregationWriter.GetTableName(testAggregationPeriod);

            // Try and remove the table if it already exists
            if ((await DatamartClient.GetAggregationTablesAsync().ConfigureAwait(false)).Contains(tableName))
            {
                await DatamartClient
                .DropAggregationTableAsync(testAggregationPeriod)
                .ConfigureAwait(false);
            }

            // Assert the table does not exist
            (await DatamartClient.GetAggregationTablesAsync().ConfigureAwait(false)).Should().NotContain(tableName);

            // Create the table
            await DatamartClient
            .EnsureTableExistsAsync(testAggregationPeriod)
            .ConfigureAwait(false);

            // Check the table is there
            (await DatamartClient.GetAggregationTablesAsync().ConfigureAwait(false)).Should().Contain(tableName);

            // Tidy up by removing the table
            await DatamartClient
            .DropAggregationTableAsync(testAggregationPeriod)
            .ConfigureAwait(false);

            // Check it's no longer there
            (await DatamartClient.GetAggregationTablesAsync().ConfigureAwait(false)).Should().NotContain(tableName);
        }
Exemplo n.º 2
0
        protected TestWithOutput(ITestOutputHelper iTestOutputHelper)
        {
            ITestOutputHelper = iTestOutputHelper;
            var nowUtc = DateTimeOffset.UtcNow;

            StartEpoch = nowUtc.AddDays(-30).ToUnixTimeSeconds();
            EndEpoch   = nowUtc.ToUnixTimeSeconds();
            var configuration           = LoadConfiguration("appsettings.json");
            var logicMonitorCredentials = configuration.LogicMonitorCredentials;

            Configuration.LoggerFactory             = new PrefixLoggerFactory(logicMonitorCredentials.Account, LogFactory.Create(iTestOutputHelper));
            Configuration.LogicMonitorClientOptions = new LogicMonitorClientOptions
            {
                Account   = logicMonitorCredentials.Account,
                AccessId  = logicMonitorCredentials.AccessId,
                AccessKey = logicMonitorCredentials.AccessKey,
                Logger    = Configuration.LoggerFactory.CreateLogger <LogicMonitorClient>()
            };
            Configuration.DatabaseType       = configuration.DatabaseType;
            Configuration.DatabaseServerName = configuration.DatabaseServer;
            Configuration.DatabaseName       = configuration.DatabaseName;
            Configuration.DatabaseUsername   = configuration.DatabaseUsername;
            Configuration.DatabasePassword   = configuration.DatabasePassword;


            DatamartClient = new DatamartClient(Configuration);

            DatamartClient.EnsureDatabaseCreatedAndSchemaUpdatedAsync().GetAwaiter().GetResult();

            Stopwatch = Stopwatch.StartNew();

            LoggerFactory = LogFactory.Create(iTestOutputHelper);
        }
Exemplo n.º 3
0
        public async void UpdateDevices()
        {
            var utcNow = DateTime.UtcNow;

            await DatamartClient
            .AddOrUpdate <Device, DeviceStoreItem>(context => context.Devices, LoggerFactory.CreateLogger(nameof(AlertTests)), default)
            .ConfigureAwait(false);
        }