Exemplo n.º 1
0
        public void GHChangeFailureRateDAIntegrationTest()
        {
            //Arrange
            bool getSampleData = true;
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableAuthorization(Configuration);
            string         owner                = "samsmithnz";
            string         repo                 = "DevOpsMetrics";
            string         branch               = "main";
            string         workflowName         = "DevOpsMetrics CI/CD";
            DevOpsPlatform targetDevOpsPlatform = DevOpsPlatform.GitHub;
            int            numberOfDays         = 30;
            int            maxNumberOfItems     = 20;

            //Act
            ChangeFailureRateDA    da    = new();
            ChangeFailureRateModel model = da.GetChangeFailureRate(getSampleData, tableStorageConfig,
                                                                   targetDevOpsPlatform, owner, repo, branch, workflowName, numberOfDays, maxNumberOfItems);

            //Assert
            Assert.IsTrue(model != null);
            Assert.IsTrue(model.TargetDevOpsPlatform == targetDevOpsPlatform);
            Assert.IsTrue(model.DeploymentName != "");
            Assert.IsTrue(model.ChangeFailureRateMetric > 0f);
            Assert.IsTrue(model.ChangeFailureRateBuildList.Count <= 20f);
            Assert.AreEqual(false, string.IsNullOrEmpty(model.ChangeFailureRateMetricDescription));
            Assert.AreNotEqual("Elite", model.ChangeFailureRateMetricDescription);
            Assert.AreEqual(numberOfDays, model.NumberOfDays);
            Assert.IsTrue(model.MaxNumberOfItems > 0);
            Assert.IsTrue(model.TotalItems > 0);
        }
Exemplo n.º 2
0
        public void AzChangeFailureRateDAIntegrationTest()
        {
            //Arrange
            bool getSampleData = true;
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableAuthorization(Configuration);
            string         organization         = "samsmithnz";
            string         project              = "SamLearnsAzure";
            string         branch               = "refs/heads/master";
            string         buildName            = "SamLearnsAzure.CI";
            DevOpsPlatform targetDevOpsPlatform = DevOpsPlatform.AzureDevOps;
            int            numberOfDays         = 30;
            int            maxNumberOfItems     = 20;

            //Act
            ChangeFailureRateDA    da    = new();
            ChangeFailureRateModel model = da.GetChangeFailureRate(getSampleData, tableStorageConfig,
                                                                   targetDevOpsPlatform, organization, project, branch, buildName, numberOfDays, maxNumberOfItems);

            //Assert
            Assert.IsTrue(model != null);
            Assert.IsTrue(model.TargetDevOpsPlatform == DevOpsPlatform.AzureDevOps);
            Assert.IsTrue(model.DeploymentName != "");
            Assert.IsTrue(model.ChangeFailureRateMetric > 0f);
            Assert.IsTrue(model.ChangeFailureRateBuildList.Count <= 20f);
            Assert.AreEqual(false, string.IsNullOrEmpty(model.ChangeFailureRateMetricDescription));
            Assert.AreNotEqual("Elite", model.ChangeFailureRateMetricDescription);
            Assert.AreEqual(numberOfDays, model.NumberOfDays);
            Assert.IsTrue(model.MaxNumberOfItems > 0);
            Assert.IsTrue(model.TotalItems > 0);
        }
Exemplo n.º 3
0
        public async Task <bool> UpdateAzureDevOpsSettingInStorage(TableStorageConfiguration tableStorageConfig, string settingsTable,
                                                                   string organization, string project, string repository, string branch, string buildName, string buildId, string resourceGroupName,
                                                                   int itemOrder, bool showSetting)
        {
            string partitionKey = "AzureDevOpsSettings";
            string rowKey       = PartitionKeys.CreateAzureDevOpsSettingsPartitionKey(organization, project, repository);

            AzureDevOpsSettings settings = new AzureDevOpsSettings
            {
                RowKey                  = rowKey,
                Organization            = organization,
                Project                 = project,
                Repository              = repository,
                Branch                  = branch,
                BuildName               = buildName,
                BuildId                 = buildId,
                ProductionResourceGroup = resourceGroupName,
                ItemOrder               = itemOrder,
                ShowSetting             = showSetting
            };

            string json = JsonConvert.SerializeObject(settings);
            AzureStorageTableModel newItem = new AzureStorageTableModel(partitionKey, rowKey, json);
            TableStorageCommonDA   tableDA = new TableStorageCommonDA(tableStorageConfig, settingsTable);

            return(await tableDA.SaveItem(newItem));
        }
Exemplo n.º 4
0
        //Note that this can't be async due to performance issues with Azure Storage when you retrieve items
        public JArray GetTableStorageItemsFromStorage(TableStorageConfiguration tableStorageConfig, string tableName, string partitionKey, bool includePartitionAndRowKeys = false)
        {
            TableStorageCommonDA          tableDA = new TableStorageCommonDA(tableStorageConfig, tableName);
            List <AzureStorageTableModel> items   = tableDA.GetItems(partitionKey);
            JArray list = new JArray();

            foreach (AzureStorageTableModel item in items)
            {
                if (includePartitionAndRowKeys == true)
                {
                    string data = item.Data?.ToString();
                    list.Add(
                        new JObject(
                            new JProperty("PartitionKey", item.PartitionKey),
                            new JProperty("RowKey", item.RowKey),
                            new JProperty("Data", data))
                        );
                }
                else
                {
                    list.Add(JToken.Parse(item.Data));
                }
            }
            return(list);
        }
Exemplo n.º 5
0
        public void TimeToRestoreServiceDALiveIntegrationTest()
        {
            //Arrange
            bool getSampleData = false;
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableAuthorization(base.Configuration);
            string         resourceGroup        = "SamLearnsAzureProd";
            DevOpsPlatform targetDevOpsPlatform = DevOpsPlatform.AzureDevOps;
            int            numberOfDays         = 60;
            int            maxNumberOfItems     = 20;

            //Act
            MeanTimeToRestoreDA    da    = new();
            MeanTimeToRestoreModel model = da.GetAzureMeanTimeToRestore(getSampleData, tableStorageConfig, targetDevOpsPlatform, resourceGroup, numberOfDays, maxNumberOfItems);

            //Assert
            Assert.IsTrue(model != null);
            Assert.IsTrue(model.TargetDevOpsPlatform == targetDevOpsPlatform);
            Assert.AreEqual(resourceGroup, model.ResourceGroup);
            Assert.IsTrue(model.MeanTimeToRestoreEvents.Count >= 0);
            Assert.IsTrue(model.MTTRAverageDurationInHours >= 0);
            Assert.IsTrue(model.MTTRAverageDurationDescription != "");
            Assert.AreEqual(numberOfDays, model.NumberOfDays);
            Assert.IsTrue(model.MaxNumberOfItems >= 0);
            Assert.IsTrue(model.TotalItems >= 0);
        }
Exemplo n.º 6
0
        public async Task <bool> UpdateGitHubSettingInStorage(TableStorageConfiguration tableStorageConfig, string settingsTable,
                                                              string owner, string repo, string branch, string workflowName, string workflowId, string resourceGroupName,
                                                              int itemOrder, bool showSetting)
        {
            string         partitionKey = "GitHubSettings";
            string         rowKey       = PartitionKeys.CreateGitHubSettingsPartitionKey(owner, repo);
            GitHubSettings settings     = new GitHubSettings
            {
                RowKey                  = rowKey,
                Owner                   = owner,
                Repo                    = repo,
                Branch                  = branch,
                WorkflowName            = workflowName,
                WorkflowId              = workflowId,
                ProductionResourceGroup = resourceGroupName,
                ItemOrder               = itemOrder,
                ShowSetting             = showSetting
            };

            string json = JsonConvert.SerializeObject(settings);
            AzureStorageTableModel newItem = new AzureStorageTableModel(partitionKey, rowKey, json);
            TableStorageCommonDA   tableDA = new TableStorageCommonDA(tableStorageConfig, settingsTable);

            return(await tableDA.SaveItem(newItem));
        }
        public async Task AzDeploymentFrequencyDAIntegrationTest()
        {
            //Arrange
            bool   getSampleData = true;
            string patToken      = base.Configuration["AppSettings:AzureDevOpsPatToken"];
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableAuthorization(base.Configuration);
            string organization     = "samsmithnz";
            string project          = "SamLearnsAzure";
            string branch           = "refs/heads/master";
            string buildName        = "SamLearnsAzure.CI";
            int    numberOfDays     = 30;
            int    maxNumberOfItems = 20;
            bool   useCache         = true;

            //Act
            DeploymentFrequencyDA    da    = new();
            DeploymentFrequencyModel model = await da.GetAzureDevOpsDeploymentFrequency(getSampleData, patToken, tableStorageConfig, organization, project, branch, buildName, numberOfDays, maxNumberOfItems, useCache);

            //Assert
            Assert.IsTrue(model.DeploymentsPerDayMetric > 0f);
            Assert.AreEqual(false, string.IsNullOrEmpty(model.DeploymentsPerDayMetricDescription));
            Assert.AreNotEqual("Unknown", model.DeploymentsPerDayMetricDescription);
            Assert.AreEqual(10f, model.DeploymentsToDisplayMetric);
            Assert.AreEqual("per day", model.DeploymentsToDisplayUnit);
            Assert.AreEqual(numberOfDays, model.NumberOfDays);
            Assert.IsTrue(model.MaxNumberOfItems > 0);
            Assert.IsTrue(model.TotalItems > 0);
            Assert.IsTrue(model.IsProjectView == false);
            Assert.IsTrue(model.ItemOrder == 0);
        }
        public async Task GHDeploymentFrequencyDAIntegrationTest()
        {
            //Arrange
            bool   getSampleData = true;
            string clientId      = base.Configuration["AppSettings:GitHubClientId"];
            string clientSecret  = base.Configuration["AppSettings:GitHubClientSecret"];
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableAuthorization(base.Configuration);
            string owner            = "samsmithnz";
            string repo             = "DevOpsMetrics";
            string branch           = "main";
            string workflowName     = "DevOpsMetrics CI/CD";
            string workflowId       = "1162561";
            int    numberOfDays     = 30;
            int    maxNumberOfItems = 20;
            bool   useCache         = true;

            //Act
            DeploymentFrequencyDA    da    = new();
            DeploymentFrequencyModel model = await da.GetGitHubDeploymentFrequency(getSampleData, clientId, clientSecret, tableStorageConfig, owner, repo, branch, workflowName, workflowId, numberOfDays, maxNumberOfItems, useCache);

            //Assert
            Assert.IsTrue(model.DeploymentsPerDayMetric > 0f);
            Assert.AreEqual(false, string.IsNullOrEmpty(model.DeploymentsPerDayMetricDescription));
            Assert.AreNotEqual("Unknown", model.DeploymentsPerDayMetricDescription);
            Assert.AreEqual(10f, model.DeploymentsToDisplayMetric);
            Assert.AreEqual("per day", model.DeploymentsToDisplayUnit);
            Assert.AreEqual(numberOfDays, model.NumberOfDays);
            Assert.IsTrue(model.MaxNumberOfItems > 0);
            Assert.IsTrue(model.TotalItems > 0);
            Assert.IsTrue(model.IsProjectView == false);
            Assert.IsTrue(model.ItemOrder == 0);
        }
Exemplo n.º 9
0
        public async Task <bool> UpdateGitHubSetting(string clientId, string clientSecret,
                                                     string owner, string repo,
                                                     string branch, string workflowName, string workflowId, string resourceGroup,
                                                     int itemOrder, bool showSetting)
        {
            //Save the Client Id and Client Secret to the key vault
            string clientIdName = PartitionKeys.CreateGitHubSettingsPartitionKeyClientId(owner, repo);

            clientIdName = SecretsProcessing.CleanKey(clientIdName);
            if (clientIdName.Length > 10)
            {
                await CreateKeyVaultSecret(clientIdName, clientId);
            }
            string clientSecretName = PartitionKeys.CreateGitHubSettingsPartitionKeyClientSecret(owner, repo);

            clientSecretName = SecretsProcessing.CleanKey(clientSecretName);
            if (clientSecretName.Length > 14)
            {
                await CreateKeyVaultSecret(clientSecretName, clientSecret);
            }

            //Save everything else to table storage
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration);

            return(await AzureTableStorageDA.UpdateGitHubSettingInStorage(tableStorageConfig, tableStorageConfig.TableGitHubSettings,
                                                                          owner, repo, branch, workflowName, workflowId, resourceGroup, itemOrder, showSetting));
        }
Exemplo n.º 10
0
        public List <GitHubSettings> GetGitHubSettings(string rowKey = null)
        {
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration);
            List <GitHubSettings>     settings           = AzureTableStorageDA.GetGitHubSettingsFromStorage(tableStorageConfig, tableStorageConfig.TableGitHubSettings, rowKey);

            return(settings);
        }
Exemplo n.º 11
0
        public async Task <bool> UpdateProjectLogInStorage(TableStorageConfiguration tableStorageConfig, ProjectLog log)
        {
            AzureStorageTableModel newItem = new AzureStorageTableModel(log.PartitionKey, log.RowKey, log.Json);
            TableStorageCommonDA   tableDA = new TableStorageCommonDA(tableStorageConfig, tableStorageConfig.TableLog);

            return(await tableDA.SaveItem(newItem));
        }
Exemplo n.º 12
0
        public void AzGetPRCommitsDAIntegrationTest()
        {
            //Arrange
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableAuthorization(base.Configuration);
            string organization = "samsmithnz";
            string project      = "SamLearnsAzure";

            //Act
            AzureTableStorageDA da = new();
            JArray prList          = da.GetTableStorageItemsFromStorage(tableStorageConfig, tableStorageConfig.TableAzureDevOpsPRs, PartitionKeys.CreateAzureDevOpsPRPartitionKey(organization, project));
            int    itemsAdded      = 0;

            foreach (JToken item in prList)
            {
                AzureDevOpsPR pullRequest   = JsonConvert.DeserializeObject <AzureDevOpsPR>(item.ToString());
                string        pullRequestId = pullRequest.PullRequestId;
                JArray        list          = da.GetTableStorageItemsFromStorage(tableStorageConfig, tableStorageConfig.TableAzureDevOpsPRCommits, PartitionKeys.CreateAzureDevOpsPRCommitPartitionKey(organization, project, pullRequestId));
                if (list.Count > 0)
                {
                    itemsAdded = list.Count;
                    break;
                }
            }

            //Assert
            Assert.IsTrue(itemsAdded >= 0);
        }
Exemplo n.º 13
0
        public async Task <int> UpdateAzureDevOpsBuilds(
            string organization, string project, string repository, string branch,
            string buildName, string buildId,
            int numberOfDays, int maxNumberOfItems)
        {
            int numberOfRecordsSaved;

            try
            {
                TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration);

                //Get the PAT token from the key vault
                string patTokenName = PartitionKeys.CreateAzureDevOpsSettingsPartitionKeyPatToken(organization, project, repository);
                patTokenName = SecretsProcessing.CleanKey(patTokenName);
                string patToken = Configuration[patTokenName];
                if (string.IsNullOrEmpty(patToken) == true)
                {
                    throw new Exception($"patToken '{patTokenName}' not found in key vault");
                }

                numberOfRecordsSaved = await AzureTableStorageDA.UpdateAzureDevOpsBuildsInStorage(patToken, tableStorageConfig, organization, project, branch, buildName, buildId, numberOfDays, maxNumberOfItems);
            }
            catch (Exception ex)
            {
                if (ex.Message == "Response status code does not indicate success: 403 (rate limit exceeded).")
                {
                    numberOfRecordsSaved = -1;
                }
                else
                {
                    throw;
                }
            }
            return(numberOfRecordsSaved);
        }
Exemplo n.º 14
0
        public List <ProjectLog> GetAzureDevOpsProjectLog(string organization, string project, string repository)
        {
            string partitionKey = PartitionKeys.CreateAzureDevOpsSettingsPartitionKey(organization, project, repository);

            TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration);

            return(AzureTableStorageDA.GetProjectLogsFromStorage(tableStorageConfig, partitionKey));
        }
Exemplo n.º 15
0
        public List <ProjectLog> GetGitHubProjectLog(string owner, string repo)
        {
            string partitionKey = PartitionKeys.CreateGitHubSettingsPartitionKey(owner, repo);

            TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration);

            return(AzureTableStorageDA.GetProjectLogsFromStorage(tableStorageConfig, partitionKey));
        }
Exemplo n.º 16
0
        public void ThenTheTenantedCloudTableShouldBeNamedUsingAHashOfTheNameSpecifiedInTheBlobConfiguration()
        {
            TableStorageConfiguration tableStorageConfiguration = this.tenancyBindings.RootTenant.GetTableStorageConfiguration(this.TableStorageTableDefinition);

            string expectedNamePlain = tableStorageConfiguration.TableName !;
            string expectedName      = AzureStorageNameHelper.HashAndEncodeTableName(expectedNamePlain);

            Assert.AreEqual(expectedName, this.CloudTable.Name);
        }
Exemplo n.º 17
0
        public async Task AzureMonitorProcessingTest()
        {
            //Arrange
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableAuthorization(base.Configuration);
            MonitoringEvent           monitoringEvent    = new(@"
{
  ""schemaId"": ""AzureMonitorMetricAlert"",
  ""data"": {
    ""version"": ""2.0"",
    ""properties"": null,
    ""status"": ""Activated"",
    ""context"": {
      ""timestamp"": ""2020-05-25T00:11:28.7763615Z"",
      ""id"": ""/subscriptions/07db7d0b-a6cb-4e58-b07e-e1d541c39f5b/resourceGroups/SamLearnsAzureFeatureFlags/providers/microsoft.insights/metricAlerts/ServerErrors%20featureflags-data-eu-service"",
      ""name"": ""ServerErrors featureflags-data-eu-service"",
      ""description"": """",
      ""conditionType"": ""SingleResourceMultipleMetricCriteria"",
      ""severity"": ""3"",
      ""condition"": {
        ""windowSize"": ""PT5M"",
        ""allOf"": [
          {
            ""metricName"": ""Http5xx"",
            ""metricNamespace"": ""Microsoft.Web/sites"",
            ""operator"": ""GreaterThan"",
            ""threshold"": ""10"",
            ""timeAggregation"": ""Total"",
            ""dimensions"": [
              {
                ""name"": ""ResourceId"",
                ""value"": ""featureflags-data-eu-service.azurewebsites.net""
              }
            ],
            ""metricValue"": 11.0,
            ""webTestName"": null
          }
        ]
      },
      ""subscriptionId"": ""07db7d0b-a6cb-4e58-b07e-e1d541c39f5b"",
      ""resourceGroupName"": ""SamLearnsAzureTest"",
      ""resourceName"": ""featureflags-data-eu-service"",
      ""resourceType"": ""Microsoft.Web/sites"",
      ""resourceId"": ""/subscriptions/07db7d0b-a6cb-4e58-b07e-e1d541c39f5b/resourceGroups/SamLearnsAzureFeatureFlags/providers/Microsoft.Web/sites/featureflags-data-eu-service"",
      ""portalLink"": ""https://portal.azure.com/#resource/subscriptions/07db7d0b-a6cb-4e58-b07e-e1d541c39f5b/resourceGroups/SamLearnsAzureFeatureFlags/providers/Microsoft.Web/sites/featureflags-data-eu-service""
    }
  }
}
");

            //Act
            AzureTableStorageDA da = new();
            bool result            = await da.UpdateDevOpsMonitoringEventInStorage(tableStorageConfig, monitoringEvent);

            //Assert
            Assert.IsTrue(result == true);
        }
Exemplo n.º 18
0
        public async Task <bool> UpdateDevOpsMonitoringEventInStorage(TableStorageConfiguration tableStorageConfig, MonitoringEvent monitoringEvent)
        {
            string partitionKey            = monitoringEvent.PartitionKey;
            string rowKey                  = monitoringEvent.RowKey;
            string json                    = monitoringEvent.RequestBody;
            AzureStorageTableModel newItem = new AzureStorageTableModel(partitionKey, rowKey, json);
            TableStorageCommonDA   tableDA = new TableStorageCommonDA(tableStorageConfig, tableStorageConfig.TableMTTR);

            return(await tableDA.SaveItem(newItem));
        }
        public async Task <bool> UpdateChangeFailureRate(string organization_owner, string project_repo,
                                                         string buildName_workflowName, int percentComplete, int numberOfDays)
        {
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration);
            ChangeFailureRateDA       da = new();

            return(await da.UpdateChangeFailureRate(tableStorageConfig,
                                                    organization_owner, project_repo, buildName_workflowName,
                                                    percentComplete, numberOfDays));
        }
Exemplo n.º 20
0
        private static EnrollmentConfigurationItem[] GetUserNotificationsConfig(FeatureContext featureContext)
        {
            IConfiguration configuration = ContainerBindings
                                           .GetServiceProvider(featureContext)
                                           .GetRequiredService <IConfiguration>();

            // Can't create a logger using the generic type of this class because it's static, so we'll do it using
            // the feature context instead.
            ILogger <FeatureContext> logger = ContainerBindings
                                              .GetServiceProvider(featureContext)
                                              .GetRequiredService <ILogger <FeatureContext> >();

            // Load the config items we need:
            TableStorageConfiguration tableStorageConfiguration =
                configuration.GetSection("TestTableStorageConfiguration").Get <TableStorageConfiguration>()
                ?? new TableStorageConfiguration();

            if (string.IsNullOrEmpty(tableStorageConfiguration.AccountName))
            {
                logger.LogDebug("No configuration value 'TestTableStorageConfiguration:AccountName' provided; using local storage emulator.");
            }

            BlobStorageConfiguration blobStorageConfiguration =
                configuration.GetSection("TestBlobStorageConfiguration").Get <BlobStorageConfiguration>()
                ?? new BlobStorageConfiguration();

            if (string.IsNullOrEmpty(blobStorageConfiguration.AccountName))
            {
                logger.LogDebug("No configuration value 'TestBlobStorageConfiguration:AccountName' provided; using local storage emulator.");
            }

            return(new EnrollmentConfigurationItem[]
            {
                new EnrollmentTableStorageConfigurationItem
                {
                    Key = "userNotificationStore",
                    Configuration = tableStorageConfiguration,
                },
                new EnrollmentBlobStorageConfigurationItem
                {
                    Key = "operationsStore",
                    Configuration = blobStorageConfiguration,
                },
                new EnrollmentBlobStorageConfigurationItem
                {
                    Key = "userPreferencesStore",
                    Configuration = blobStorageConfiguration,
                },
                new EnrollmentBlobStorageConfigurationItem
                {
                    Key = "templateStore",
                    Configuration = blobStorageConfiguration,
                },
            });
        }
Exemplo n.º 21
0
        protected void ConfigureProvider(bool autoCreateTable = false, bool autoCreateToggle = false)
        {
            var config = new TableStorageConfiguration {
                ConnectionString = "UseDevelopmentStorage=true"
            };

            config.AutoCreateTable   = autoCreateTable;
            config.AutoCreateFeature = autoCreateToggle;
            config.TableName         = tableName;

            TableStorageProvider.Configure(config);
        }
Exemplo n.º 22
0
        public async Task <bool> UpdateGitHubProjectLog(string owner, string repo,
                                                        int buildsUpdated, int prsUpdated, string buildUrl, string prUrl,
                                                        string exceptionMessage, string exceptionStackTrace)
        {
            ProjectLog log = new(
                PartitionKeys.CreateGitHubSettingsPartitionKey(owner, repo),
                buildsUpdated, prsUpdated, HttpUtility.UrlDecode(buildUrl), HttpUtility.UrlDecode(prUrl), exceptionMessage, exceptionStackTrace);

            TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration);

            return(await AzureTableStorageDA.UpdateProjectLogInStorage(tableStorageConfig, log));
        }
Exemplo n.º 23
0
        public List <ProjectLog> GetProjectLogsFromStorage(TableStorageConfiguration tableStorageConfig, string partitionKey)
        {
            List <ProjectLog> logs = null;
            JArray            list = GetTableStorageItemsFromStorage(tableStorageConfig, tableStorageConfig.TableLog, partitionKey, true);

            if (list != null)
            {
                logs = JsonConvert.DeserializeObject <List <ProjectLog> >(list.ToString());
            }

            return(logs);
        }
        public ChangeFailureRateModel GetChangeFailureRate(bool getSampleData,
                                                           DevOpsPlatform targetDevOpsPlatform, string organization_owner, string project_repo, string branch, string buildName_workflowName,
                                                           int numberOfDays, int maxNumberOfItems)
        {
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration);
            ChangeFailureRateDA       da    = new();
            ChangeFailureRateModel    model = da.GetChangeFailureRate(getSampleData, tableStorageConfig, targetDevOpsPlatform,
                                                                      organization_owner, project_repo, branch, buildName_workflowName,
                                                                      numberOfDays, maxNumberOfItems);

            return(model);
        }
        public MeanTimeToRestoreModel GetAzureMeanTimeToRestore(bool getSampleData,
                                                                DevOpsPlatform targetDevOpsPlatform, string resourceGroup,
                                                                int numberOfDays, int maxNumberOfItems)
        {
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration);
            MeanTimeToRestoreDA       da    = new();
            MeanTimeToRestoreModel    model = da.GetAzureMeanTimeToRestore(getSampleData, tableStorageConfig,
                                                                           targetDevOpsPlatform, resourceGroup,
                                                                           numberOfDays, maxNumberOfItems);

            return(model);
        }
Exemplo n.º 26
0
        public void GHGetSamLearnsAzureSettingDAIntegrationTest()
        {
            //Arrange
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableAuthorization(base.Configuration);

            //Act
            AzureTableStorageDA   da      = new();
            List <GitHubSettings> results = da.GetGitHubSettingsFromStorage(tableStorageConfig, tableStorageConfig.TableGitHubSettings, null);

            //Assert
            Assert.IsTrue(results.Count > 0);
        }
Exemplo n.º 27
0
        public void GHGetPRsDAIntegrationTest()
        {
            //Arrange
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableAuthorization(base.Configuration);
            string owner = "samsmithnz";
            string repo  = "DevOpsMetrics";

            //Act
            AzureTableStorageDA da = new();
            JArray list            = da.GetTableStorageItemsFromStorage(tableStorageConfig, tableStorageConfig.TableGitHubPRs, PartitionKeys.CreateGitHubPRPartitionKey(owner, repo));

            //Assert
            Assert.IsTrue(list.Count >= 0);
        }
Exemplo n.º 28
0
        public void AzGetPRsDAIntegrationTest()
        {
            //Arrange
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableAuthorization(base.Configuration);
            string organization = "samsmithnz";
            string project      = "SamLearnsAzure";

            //Act
            AzureTableStorageDA da = new();
            JArray list            = da.GetTableStorageItemsFromStorage(tableStorageConfig, tableStorageConfig.TableAzureDevOpsBuilds, PartitionKeys.CreateAzureDevOpsPRPartitionKey(organization, project));

            //Assert
            Assert.IsTrue(list.Count >= 0);
        }
Exemplo n.º 29
0
        public void GHGetSamsFeatureFlagsLogsDAIntegrationTest()
        {
            //Arrange
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableAuthorization(base.Configuration);
            string owner = "samsmithnz";
            string repo  = "SamsFeatureFlags";

            //Act
            AzureTableStorageDA da   = new();
            List <ProjectLog>   logs = da.GetProjectLogsFromStorage(tableStorageConfig, PartitionKeys.CreateGitHubSettingsPartitionKey(owner, repo));

            //Assert
            Assert.IsTrue(logs != null);
            Assert.IsTrue(logs.Count > 0);
        }
Exemplo n.º 30
0
        public void AzGetSamLearnsAzureLogsDAIntegrationTest()
        {
            //Arrange
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableAuthorization(base.Configuration);
            string organization = "samsmithnz";
            string project      = "SamLearnsAzure";
            string repository   = "SamLearnsAzure";

            //Act
            AzureTableStorageDA da   = new();
            List <ProjectLog>   logs = da.GetProjectLogsFromStorage(tableStorageConfig, PartitionKeys.CreateAzureDevOpsSettingsPartitionKey(organization, project, repository));

            //Assert
            Assert.IsTrue(logs != null);
            Assert.IsTrue(logs.Count > 0);
        }