@Test public void creates_error_entry_for_flag_data_of_undefined_flag() throws IOException { FlagData prodUsEast3Data = flagData("flags/my-flag/main.prod.us-east-3.json"); FlagsClient flagsClient = mock(FlagsClient.class); when(flagsClient.listFlagData(prodUsEast3Target)) .thenReturn(List.of()); when(flagsClient.listDefinedFlags(prodUsEast3Target)) .thenReturn(List.of()); SystemFlagsDataArchive archive = new SystemFlagsDataArchive.Builder() .addFile("main.prod.us-east-3.json", prodUsEast3Data) .build(); SystemFlagsDeployer deployer = new SystemFlagsDeployer(flagsClient, SYSTEM, Set.of(prodUsEast3Target)); SystemFlagsDeployResult result = deployer.deployFlags(archive, true); assertThat(result.errors()) .containsOnly(SystemFlagsDeployResult.OperationError.createFailed("Flag not defined in target zone", prodUsEast3Target, prodUsEast3Data)); }
SystemFlagsDeployResult deployFlags(SystemFlagsDataArchive archive, boolean dryRun) { Map<FlagsTarget, Future<SystemFlagsDeployResult>> futures = new HashMap<>(); for (FlagsTarget target : targets) { futures.put(target, executor.submit(() -> deployFlags(target, archive.flagData(target), dryRun))); } List<SystemFlagsDeployResult> results = new ArrayList<>(); futures.forEach((target, future) -> { try { results.add(future.get()); } catch (InterruptedException | ExecutionException e) { log.log(Level.SEVERE, String.format("Failed to deploy flags for target '%s': %s", target, e.getMessage()), e); throw new RuntimeException(e); } }); try { archive.validateAllFilesAreForTargets(system, targets); } catch (IllegalArgumentException e) { results.add(new SystemFlagsDeployResult(List.of(OperationError.archiveValidationFailed(e.getMessage())))); } return SystemFlagsDeployResult.merge(results); }
SystemFlagsDeployer { SystemFlagsDeployResult deployFlags(SystemFlagsDataArchive archive, boolean dryRun) { Map<FlagsTarget, Future<SystemFlagsDeployResult>> futures = new HashMap<>(); for (FlagsTarget target : targets) { futures.put(target, executor.submit(() -> deployFlags(target, archive.flagData(target), dryRun))); } List<SystemFlagsDeployResult> results = new ArrayList<>(); futures.forEach((target, future) -> { try { results.add(future.get()); } catch (InterruptedException | ExecutionException e) { log.log(Level.SEVERE, String.format("Failed to deploy flags for target '%s': %s", target, e.getMessage()), e); throw new RuntimeException(e); } }); try { archive.validateAllFilesAreForTargets(system, targets); } catch (IllegalArgumentException e) { results.add(new SystemFlagsDeployResult(List.of(OperationError.archiveValidationFailed(e.getMessage())))); } return SystemFlagsDeployResult.merge(results); } }
SystemFlagsDeployer { SystemFlagsDeployResult deployFlags(SystemFlagsDataArchive archive, boolean dryRun) { Map<FlagsTarget, Future<SystemFlagsDeployResult>> futures = new HashMap<>(); for (FlagsTarget target : targets) { futures.put(target, executor.submit(() -> deployFlags(target, archive.flagData(target), dryRun))); } List<SystemFlagsDeployResult> results = new ArrayList<>(); futures.forEach((target, future) -> { try { results.add(future.get()); } catch (InterruptedException | ExecutionException e) { log.log(Level.SEVERE, String.format("Failed to deploy flags for target '%s': %s", target, e.getMessage()), e); throw new RuntimeException(e); } }); try { archive.validateAllFilesAreForTargets(system, targets); } catch (IllegalArgumentException e) { results.add(new SystemFlagsDeployResult(List.of(OperationError.archiveValidationFailed(e.getMessage())))); } return SystemFlagsDeployResult.merge(results); } SystemFlagsDeployer(ServiceIdentityProvider identityProvider, SystemName system, Set<FlagsTarget> targets);   SystemFlagsDeployer(FlagsClient client, SystemName system, Set<FlagsTarget> targets); }
SystemFlagsDeployer { SystemFlagsDeployResult deployFlags(SystemFlagsDataArchive archive, boolean dryRun) { Map<FlagsTarget, Future<SystemFlagsDeployResult>> futures = new HashMap<>(); for (FlagsTarget target : targets) { futures.put(target, executor.submit(() -> deployFlags(target, archive.flagData(target), dryRun))); } List<SystemFlagsDeployResult> results = new ArrayList<>(); futures.forEach((target, future) -> { try { results.add(future.get()); } catch (InterruptedException | ExecutionException e) { log.log(Level.SEVERE, String.format("Failed to deploy flags for target '%s': %s", target, e.getMessage()), e); throw new RuntimeException(e); } }); try { archive.validateAllFilesAreForTargets(system, targets); } catch (IllegalArgumentException e) { results.add(new SystemFlagsDeployResult(List.of(OperationError.archiveValidationFailed(e.getMessage())))); } return SystemFlagsDeployResult.merge(results); } SystemFlagsDeployer(ServiceIdentityProvider identityProvider, SystemName system, Set<FlagsTarget> targets);   SystemFlagsDeployer(FlagsClient client, SystemName system, Set<FlagsTarget> targets);  }
SystemFlagsDeployer { SystemFlagsDeployResult deployFlags(SystemFlagsDataArchive archive, boolean dryRun) { Map<FlagsTarget, Future<SystemFlagsDeployResult>> futures = new HashMap<>(); for (FlagsTarget target : targets) { futures.put(target, executor.submit(() -> deployFlags(target, archive.flagData(target), dryRun))); } List<SystemFlagsDeployResult> results = new ArrayList<>(); futures.forEach((target, future) -> { try { results.add(future.get()); } catch (InterruptedException | ExecutionException e) { log.log(Level.SEVERE, String.format("Failed to deploy flags for target '%s': %s", target, e.getMessage()), e); throw new RuntimeException(e); } }); try { archive.validateAllFilesAreForTargets(system, targets); } catch (IllegalArgumentException e) { results.add(new SystemFlagsDeployResult(List.of(OperationError.archiveValidationFailed(e.getMessage())))); } return SystemFlagsDeployResult.merge(results); } SystemFlagsDeployer(ServiceIdentityProvider identityProvider, SystemName system, Set<FlagsTarget> targets);   SystemFlagsDeployer(FlagsClient client, SystemName system, Set<FlagsTarget> targets);   }