private void InitFakeJiraRepository(out FakeJiraApiService fakeJiraApiService, out FakeJiraIssueStorage fakeJiraIssueStorage, out JiraIssueRepository jiraIssueRepository, out BundleRepository bundleRepository) { var settings = Options.Create(new SuperDumpSettings { UseJiraIntegration = true, JiraIntegrationSettings = new JiraIntegrationSettings { } }); var pathHelper = new PathHelper("", "", ""); var dumpStorage = new FakeDumpStorage(CreateFakeDumps()); var bundleStorage = dumpStorage; var dumpRepo = new DumpRepository(dumpStorage, pathHelper, settings); bundleRepository = new BundleRepository(bundleStorage, dumpRepo); fakeJiraApiService = new FakeJiraApiService(); fakeJiraIssueStorage = new FakeJiraIssueStorage(); var identicalDumpStorage = new FakeIdenticalDumpStorage(); var identicalDumpRepository = new IdenticalDumpRepository(identicalDumpStorage, bundleRepository); var loggerFactory = new LoggerFactory(); jiraIssueRepository = new JiraIssueRepository(settings, fakeJiraApiService, bundleRepository, fakeJiraIssueStorage, identicalDumpRepository, loggerFactory); }
public async Task TestSlackNotification() { var settings = Options.Create(new SuperDumpSettings()); var fakeDump = CreateFakeDump(); var pathHelper = new PathHelper("", "", ""); var dumpStorage = new FakeDumpStorage(new FakeDump[] { fakeDump }); var dumpRepo = new DumpRepository(dumpStorage, pathHelper, settings); var slackNotificationService = new SlackNotificationService(settings, dumpRepo); var msg = await slackNotificationService.GetMessageModel(fakeDump.MetaInfo); // these assertions are bare mininum for now. Could be improved. Assert.Equal(1, msg.NumNativeExceptions); var msgStr = await slackNotificationService.GetMessage(fakeDump.MetaInfo); Assert.NotNull(msgStr); }
public SimilarityServiceBenchmarks() { /// fake a repository of N very similar dumps. Then let similarity calculation run /// simulate filesystem access with Thread.Sleep in FakeDumpStorage N = 1000; var settings = Options.Create(new SuperDumpSettings { SimilarityDetectionEnabled = true, SimilarityDetectionMaxDays = 30 }); this.pathHelper = new PathHelper("", "", ""); this.dumpStorage = new FakeDumpStorage(CreateFakeDumps(N)); this.dumpRepo = new DumpRepository(dumpStorage, pathHelper, settings); this.relationshipStorage = new FakeRelationshipStorage(); this.relationshipRepo = new RelationshipRepository(relationshipStorage, dumpRepo, settings); this.similarityService = new SimilarityService(dumpRepo, relationshipRepo, settings, Dynatrace.OneAgent.Sdk.Api.OneAgentSdkFactory.CreateInstance()); }
public SearchServiceBenchmarks() { /// fake a repository of N very similar dumps. Then let similarity calculation run /// simulate filesystem access with Thread.Sleep in FakeDumpStorage N = 100000; var settings = Options.Create(new SuperDumpSettings { WarnBeforeDeletionInDays = 2, UseJiraIntegration = false, JiraIntegrationSettings = new JiraIntegrationSettings() }); var settingsWithJira = Options.Create(new SuperDumpSettings { WarnBeforeDeletionInDays = 2, UseJiraIntegration = true, JiraIntegrationSettings = new JiraIntegrationSettings() }); this.pathHelper = new PathHelper("", "", ""); this.loggerFactory = new LoggerFactory(); this.dumpStorage = new FakeDumpStorage(CreateFakeDumps(N)); this.dumpRepo = new DumpRepository(dumpStorage, pathHelper, settings); this.bundleRepo = new BundleRepository(dumpStorage, dumpRepo); this.identicalDumpStorage = new FakeIdenticalDumpStorage(); this.identicalDumpRepository = new IdenticalDumpRepository(identicalDumpStorage, bundleRepo); this.jiraIssueStorage = new FakeJiraIssueStorage(); this.jiraApiService = new FakeJiraApiService(); this.jiraIssueRepository = new JiraIssueRepository(settings, jiraApiService, bundleRepo, jiraIssueStorage, identicalDumpRepository, loggerFactory); // The Similarity Service and Elastic Search Service is not initialized since it is not required for testing the SimpleSearch this.searchService = new SearchService(bundleRepo, dumpRepo, null, null, settings, jiraIssueRepository); this.searchServiceWithJira = new SearchService(bundleRepo, dumpRepo, null, null, settingsWithJira, jiraIssueRepository); }
public async Task TestJiraIssueRepository() { // setup dependencies var settings = Options.Create(new SuperDumpSettings { UseJiraIntegration = true, JiraIntegrationSettings = new JiraIntegrationSettings { } }); var pathHelper = new PathHelper("", "", ""); var dumpStorage = new FakeDumpStorage(CreateFakeDumps()); var bundleStorage = dumpStorage; var dumpRepo = new DumpRepository(dumpStorage, pathHelper); var bundleRepo = new BundleRepository(bundleStorage, dumpRepo); var jiraApiService = new FakeJiraApiService(); var jiraIssueStorage = new FakeJiraIssueStorage(); var identicalDumpStorage = new FakeIdenticalDumpStorage(); var identicalDumpRepository = new IdenticalDumpRepository(identicalDumpStorage, bundleRepo); var loggerFactory = new LoggerFactory(); var jiraIssueRepository = new JiraIssueRepository(settings, jiraApiService, bundleRepo, jiraIssueStorage, identicalDumpRepository, loggerFactory); // population await jiraIssueStorage.Store("bundle1", new List <JiraIssueModel> { new JiraIssueModel("JRA-1111") }); await jiraIssueStorage.Store("bundle2", new List <JiraIssueModel> { new JiraIssueModel("JRA-2222"), new JiraIssueModel("JRA-3333") }); await jiraIssueStorage.Store("bundle9", new List <JiraIssueModel> { new JiraIssueModel("JRA-9999") }); await bundleRepo.Populate(); await jiraIssueRepository.Populate(); // actual test Assert.Collection(jiraIssueRepository.GetIssues("bundle1"), item => Assert.Equal("JRA-1111", item.Key)); Assert.Collection(jiraIssueRepository.GetIssues("bundle2"), item => Assert.Equal("JRA-2222", item.Key), item => Assert.Equal("JRA-3333", item.Key)); Assert.Collection(jiraIssueRepository.GetIssues("bundle9"), item => Assert.Equal("JRA-9999", item.Key)); Assert.Empty(jiraIssueRepository.GetIssues("bundle3")); // fake, that in jira some bundles have been referenced in new issues jiraApiService.SetFakeJiraIssues("bundle1", new JiraIssueModel[] { new JiraIssueModel("JRA-1111") }); // same jiraApiService.SetFakeJiraIssues("bundle2", new JiraIssueModel[] { new JiraIssueModel("JRA-2222"), new JiraIssueModel("JRA-4444") }); // one added, one removed jiraApiService.SetFakeJiraIssues("bundle3", new JiraIssueModel[] { new JiraIssueModel("JRA-1111"), new JiraIssueModel("JRA-5555") }); // new jiraApiService.SetFakeJiraIssues("bundle9", null); // removed jira issues await jiraIssueRepository.SearchBundleIssuesAsync(bundleRepo.GetAll(), true); Assert.Collection(jiraIssueRepository.GetIssues("bundle1"), item => Assert.Equal("JRA-1111", item.Key)); Assert.Collection(jiraIssueRepository.GetIssues("bundle2"), item => Assert.Equal("JRA-2222", item.Key), item => Assert.Equal("JRA-4444", item.Key)); Assert.Collection(jiraIssueRepository.GetIssues("bundle3"), item => Assert.Equal("JRA-1111", item.Key), item => Assert.Equal("JRA-5555", item.Key)); Assert.Empty(jiraIssueRepository.GetIssues("bundle9")); var res = await jiraIssueRepository.GetAllIssuesByBundleIdsWithoutWait(new string[] { "bundle1", "bundle2", "bundle7", "bundle666", "bundle9" }); Assert.Equal(2, res.Count()); Assert.Collection(res["bundle1"], item => Assert.Equal("JRA-1111", item.Key)); Assert.Collection(res["bundle2"], item => Assert.Equal("JRA-2222", item.Key), item => Assert.Equal("JRA-4444", item.Key)); Assert.Empty(jiraIssueRepository.GetIssues("bundle7")); Assert.Empty(jiraIssueRepository.GetIssues("bundle666")); Assert.Empty(jiraIssueRepository.GetIssues("bundle9")); }