@Test public void shouldNotAddWarningWhenConfigRepoLooseObjectCountIsBelowTheConfiguredThreshold() throws Exception { when(systemEnvironment.get(SystemEnvironment.GO_CONFIG_REPO_GC_LOOSE_OBJECT_WARNING_THRESHOLD)).thenReturn(10L); when(configRepository.getLooseObjectCount()).thenReturn(1L); service.checkRepoAndAddWarningIfRequired(); List<ServerHealthState> healthStates = serverHealthService.filterByScope(HealthStateScope.forConfigRepo("GC")); assertThat(healthStates.isEmpty(), is(true)); }
public PartialConfigParseResult get(String fingerprint) { PartialConfigParseResult result = fingerprintOfPartialToParseResultMap.get(fingerprint); // config repository was never parsed, check if there are any material clone or update related errors if (result == null) { HealthStateScope healthStateScope = HealthStateScope.forMaterialConfig(configRepoService.findByFingerprint(fingerprint).getMaterialConfig()); List<ServerHealthState> serverHealthStates = serverHealthService.filterByScope(healthStateScope); if (!serverHealthStates.isEmpty()) { result = PartialConfigParseResult.parseFailed(null, represent(serverHealthStates.get(0))); } } //config repository was parsed, but does not have merge or clone related errors. if (result != null && result.getLastFailure() == null) { HealthStateScope healthStateScope = HealthStateScope.forPartialConfigRepo(fingerprint); List<ServerHealthState> serverHealthStates = serverHealthService.filterByScope(healthStateScope); if (!serverHealthStates.isEmpty()) { result.setException(represent(serverHealthStates.get(0))); //clear out the good modification, in case good modification is same as of latest parsed modification if (result.getLatestParsedModification().equals(result.getGoodModification())) { result.setGoodModification(null); result.setPartialConfig(null); } } } return result; }
@Test public void shouldRemoteExistingWarningAboutGCIfLooseObjectCountGoesBelowTheSetThreshold() throws Exception { serverHealthService.update(ServerHealthState.warning("message", "description", HealthStateType.general(HealthStateScope.forConfigRepo("GC")))); assertThat(serverHealthService.filterByScope(HealthStateScope.forConfigRepo("GC")).isEmpty(), is(false)); when(systemEnvironment.get(SystemEnvironment.GO_CONFIG_REPO_GC_LOOSE_OBJECT_WARNING_THRESHOLD)).thenReturn(10L); when(configRepository.getLooseObjectCount()).thenReturn(1L); service.checkRepoAndAddWarningIfRequired(); assertThat(serverHealthService.filterByScope(HealthStateScope.forConfigRepo("GC")).isEmpty(), is(true)); }
@Test public void shouldAddWarningWhenConfigRepoLooseObjectCountGoesBeyondTheConfiguredThreshold() throws Exception { when(systemEnvironment.get(SystemEnvironment.GO_CONFIG_REPO_GC_LOOSE_OBJECT_WARNING_THRESHOLD)).thenReturn(10L); when(configRepository.getLooseObjectCount()).thenReturn(20L); service.checkRepoAndAddWarningIfRequired(); List<ServerHealthState> healthStates = serverHealthService.filterByScope(HealthStateScope.forConfigRepo("GC")); String message = "Action required: Run 'git gc' on config.git repo"; String description = "Number of loose objects in your Configuration repository(config.git) has grown beyond " + "the configured threshold. As the size of config repo increases, the config save operations tend to slow down " + "drastically. It is recommended that you run 'git gc' from " + "'<go server installation directory>/db/config.git/' to address this problem. Go can do this " + "automatically on a periodic basis if you enable automatic GC. <a target='_blank' href='" + docsUrl("/advanced_usage/config_repo.html") + "'>read more...</a>"; assertThat(healthStates.get(0).getDescription(), is(description)); assertThat(healthStates.get(0).getLogLevel(), is(HealthStateLevel.WARNING)); assertThat(healthStates.get(0).getMessage(), is(message)); }