@Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = ".*Missing environment var.*", dataProvider = "missingEnvVarProvider" ) public void testProcessAllResourcePoolsMissingEnvVar(String missingVar) { setupValidEnvironment(); environmentMap.remove(missingVar); streamEntry.processAllResourcePools(new SchedulerRequest()); }
protected void processAllResourcePools(SchedulerRequest request) { String endpointURL = getEnvironmentVar(ENV_ENDPOINT_URL); String rawLaunchLambdaList = getEnvironmentVar(ENV_RESOURCEPOOL_LAMBDA_LAUNCH_LIST); String resourcePoolEndpointPath = getEnvironmentVar(ENV_RESOURCEPOOL_ENDPOINT_PATH); HttpObjectClient<ResourcePool> resourcePoolClient = objectClientFactory.createClient( environmentLookupUtils.getAPIEndpointURL(endpointURL, request.getStageId(), resourcePoolEndpointPath), ResourcePool.class); List<String> lambdasToLaunch = Arrays.stream(StringUtils.split(rawLaunchLambdaList, ",")) .map(String::trim).collect(Collectors.toList()); try { DataObjectResponse<ResourcePool> response = resourcePoolClient.getObjects(new ArrayList<>()); if(response.isError()) { logger.error("Failed to get all ResourcePools: {}", response.getErrorResponse().getServerStackTrace()); return; } response.getAll().forEach( resourcePool -> launchResourcePoolLambda(lambdasToLaunch, resourcePool, request) ); } catch (Throwable t) { throw new RuntimeException("Error processing resource pools.", t); } }
AWSLambdaStreamEntry implements RequestStreamHandler { protected void processAllResourcePools(SchedulerRequest request) { String endpointURL = getEnvironmentVar(ENV_ENDPOINT_URL); String rawLaunchLambdaList = getEnvironmentVar(ENV_RESOURCEPOOL_LAMBDA_LAUNCH_LIST); String resourcePoolEndpointPath = getEnvironmentVar(ENV_RESOURCEPOOL_ENDPOINT_PATH); HttpObjectClient<ResourcePool> resourcePoolClient = objectClientFactory.createClient( environmentLookupUtils.getAPIEndpointURL(endpointURL, request.getStageId(), resourcePoolEndpointPath), ResourcePool.class); List<String> lambdasToLaunch = Arrays.stream(StringUtils.split(rawLaunchLambdaList, ",")) .map(String::trim).collect(Collectors.toList()); try { DataObjectResponse<ResourcePool> response = resourcePoolClient.getObjects(new ArrayList<>()); if(response.isError()) { logger.error("Failed to get all ResourcePools: {}", response.getErrorResponse().getServerStackTrace()); return; } response.getAll().forEach( resourcePool -> launchResourcePoolLambda(lambdasToLaunch, resourcePool, request) ); } catch (Throwable t) { throw new RuntimeException("Error processing resource pools.", t); } } }
AWSLambdaStreamEntry implements RequestStreamHandler { protected void processAllResourcePools(SchedulerRequest request) { String endpointURL = getEnvironmentVar(ENV_ENDPOINT_URL); String rawLaunchLambdaList = getEnvironmentVar(ENV_RESOURCEPOOL_LAMBDA_LAUNCH_LIST); String resourcePoolEndpointPath = getEnvironmentVar(ENV_RESOURCEPOOL_ENDPOINT_PATH); HttpObjectClient<ResourcePool> resourcePoolClient = objectClientFactory.createClient( environmentLookupUtils.getAPIEndpointURL(endpointURL, request.getStageId(), resourcePoolEndpointPath), ResourcePool.class); List<String> lambdasToLaunch = Arrays.stream(StringUtils.split(rawLaunchLambdaList, ",")) .map(String::trim).collect(Collectors.toList()); try { DataObjectResponse<ResourcePool> response = resourcePoolClient.getObjects(new ArrayList<>()); if(response.isError()) { logger.error("Failed to get all ResourcePools: {}", response.getErrorResponse().getServerStackTrace()); return; } response.getAll().forEach( resourcePool -> launchResourcePoolLambda(lambdasToLaunch, resourcePool, request) ); } catch (Throwable t) { throw new RuntimeException("Error processing resource pools.", t); } } AWSLambdaStreamEntry(AWSLambdaFactory awsLambdaFactory, HttpObjectClientFactory objectClientFactory);  AWSLambdaStreamEntry(); }
AWSLambdaStreamEntry implements RequestStreamHandler { protected void processAllResourcePools(SchedulerRequest request) { String endpointURL = getEnvironmentVar(ENV_ENDPOINT_URL); String rawLaunchLambdaList = getEnvironmentVar(ENV_RESOURCEPOOL_LAMBDA_LAUNCH_LIST); String resourcePoolEndpointPath = getEnvironmentVar(ENV_RESOURCEPOOL_ENDPOINT_PATH); HttpObjectClient<ResourcePool> resourcePoolClient = objectClientFactory.createClient( environmentLookupUtils.getAPIEndpointURL(endpointURL, request.getStageId(), resourcePoolEndpointPath), ResourcePool.class); List<String> lambdasToLaunch = Arrays.stream(StringUtils.split(rawLaunchLambdaList, ",")) .map(String::trim).collect(Collectors.toList()); try { DataObjectResponse<ResourcePool> response = resourcePoolClient.getObjects(new ArrayList<>()); if(response.isError()) { logger.error("Failed to get all ResourcePools: {}", response.getErrorResponse().getServerStackTrace()); return; } response.getAll().forEach( resourcePool -> launchResourcePoolLambda(lambdasToLaunch, resourcePool, request) ); } catch (Throwable t) { throw new RuntimeException("Error processing resource pools.", t); } } AWSLambdaStreamEntry(AWSLambdaFactory awsLambdaFactory, HttpObjectClientFactory objectClientFactory);  AWSLambdaStreamEntry(); void handleRequest(InputStream inputStream, OutputStream outputStream, Context context); AWSLambdaStreamEntry setAwsLambdaFactory(AWSLambdaFactory awsLambdaFactory); AWSLambdaStreamEntry setEnvironmentFacade(EnvironmentFacade environmentFacade); AWSLambdaStreamEntry setEnvironmentLookupUtils(EnvironmentLookupUtils environmentLookupUtils); }
AWSLambdaStreamEntry implements RequestStreamHandler { protected void processAllResourcePools(SchedulerRequest request) { String endpointURL = getEnvironmentVar(ENV_ENDPOINT_URL); String rawLaunchLambdaList = getEnvironmentVar(ENV_RESOURCEPOOL_LAMBDA_LAUNCH_LIST); String resourcePoolEndpointPath = getEnvironmentVar(ENV_RESOURCEPOOL_ENDPOINT_PATH); HttpObjectClient<ResourcePool> resourcePoolClient = objectClientFactory.createClient( environmentLookupUtils.getAPIEndpointURL(endpointURL, request.getStageId(), resourcePoolEndpointPath), ResourcePool.class); List<String> lambdasToLaunch = Arrays.stream(StringUtils.split(rawLaunchLambdaList, ",")) .map(String::trim).collect(Collectors.toList()); try { DataObjectResponse<ResourcePool> response = resourcePoolClient.getObjects(new ArrayList<>()); if(response.isError()) { logger.error("Failed to get all ResourcePools: {}", response.getErrorResponse().getServerStackTrace()); return; } response.getAll().forEach( resourcePool -> launchResourcePoolLambda(lambdasToLaunch, resourcePool, request) ); } catch (Throwable t) { throw new RuntimeException("Error processing resource pools.", t); } } AWSLambdaStreamEntry(AWSLambdaFactory awsLambdaFactory, HttpObjectClientFactory objectClientFactory);  AWSLambdaStreamEntry(); void handleRequest(InputStream inputStream, OutputStream outputStream, Context context); AWSLambdaStreamEntry setAwsLambdaFactory(AWSLambdaFactory awsLambdaFactory); AWSLambdaStreamEntry setEnvironmentFacade(EnvironmentFacade environmentFacade); AWSLambdaStreamEntry setEnvironmentLookupUtils(EnvironmentLookupUtils environmentLookupUtils); static final String ENV_IDM_ENCRYPTED_PASS; static final String ENV_IDM_USER; static final String ENV_IDENTITY_URL; static final String ENV_ENDPOINT_URL; static final String ENV_RESOURCEPOOL_ENDPOINT_PATH; static final String ENV_RESOURCEPOOL_LAMBDA_LAUNCH_LIST; }