1 package org.kuali.common.devops.archive.test; 2 3 import static java.lang.String.format; 4 import static java.util.Arrays.asList; 5 import static org.kuali.common.util.FormatUtils.getCount; 6 import static org.kuali.common.util.FormatUtils.getSize; 7 import static org.kuali.common.util.FormatUtils.getTime; 8 import static org.kuali.common.util.log.Loggers.newLogger; 9 10 import java.util.List; 11 12 import org.junit.Test; 13 import org.kuali.common.devops.archive.DefaultScanService; 14 import org.kuali.common.devops.archive.ScanRequest; 15 import org.kuali.common.devops.archive.ScanResult; 16 import org.kuali.common.devops.archive.ScanService; 17 import org.kuali.common.devops.archive.evaluate.FileSizeFunction; 18 import org.kuali.common.devops.jenkins.archive.DefaultJenkinsService; 19 import org.kuali.common.devops.jenkins.archive.JenkinsMaster; 20 import org.kuali.common.devops.jenkins.archive.JenkinsService; 21 import org.slf4j.Logger; 22 23 public class ScanBuildsTest { 24 25 private static final Logger logger = newLogger(); 26 27 @Test 28 public void test() { 29 try { 30 JenkinsService jenkins = new DefaultJenkinsService(); 31 JenkinsMaster master = jenkins.buildMaster(); 32 logger.info(format("hostname -> %s", master.getHostname())); 33 logger.info(format("home -> %s", master.getHome())); 34 List<String> includes = asList("**/jobs/**/builds/**"); 35 ScanRequest request = ScanRequest.builder(master.getHome()).withIncludes(includes).noSymLinks().build(); 36 ScanService service = new DefaultScanService(); 37 ScanResult result = service.scan(request); 38 long size = FileSizeFunction.INSTANCE.apply(result.getFiles()); 39 int count = result.getFiles().size(); 40 logger.info(format("files -> %s", getCount(count))); 41 logger.info(format("size -> %s", getSize(size))); 42 logger.info(format("elapsed -> %s", getTime(result.getTiming().getElapsed()))); 43 } catch (Throwable e) { 44 e.printStackTrace(); 45 } 46 } 47 48 }