2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.config;
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.nio.file.Files;
27 import java.nio.file.Paths;
28 import java.util.List;
30 import org.yaml.snakeyaml.Yaml;
34 private static String WINDOWS_CONFIG_FILE = "src/main/resources/ci/conf/attsdc.yaml";
35 private boolean systemUnderDebug;
36 private boolean rerun;
37 private String reportDBhost;
38 private int reportDBport;
40 private String browser;
41 private String catalogBeHost;
42 private String esHost;
43 private String esPort;
44 private String neoHost;
45 private String neoPort;
46 private String disributionClientHost;
47 private String disributionClientPort;
48 private boolean isDistributionClientRunning;
51 private String errorConfigurationFile;
52 private String resourceConfigDir;
53 private String componentsConfigDir;
54 private String importResourceConfigDir;
55 private String importResourceTestsConfigDir;
56 private String importTypesConfigDir;
58 private String testSuites;
60 private String catalogFeHost;
61 private String catalogFePort;
62 private String catalogBePort;
63 private String catalogBeTlsPort;
65 private String neoDBusername;
66 private String neoDBpassword;
68 private String titanPropertiesFile;
69 private List<String> packages;
70 private List<String> bugs;
71 private List<String> resourcesNotToDelete;
72 private List<String> resourceCategoriesNotToDelete;
73 private List<String> serviceCategoriesNotToDelete;
74 private boolean stopOnClassFailure = false;
76 private String outputFolder;
77 private String reportName;
79 private String remoteTestingMachineIP;
80 private String remoteTestingMachinePort;
81 private boolean remoteTesting;
83 private String cassandraHost;
84 private String cassandraAuditKeySpace;
85 private String cassandraArtifactKeySpace;
86 private boolean cassandraAuthenticate;
87 private String cassandraUsername;
88 private String cassandraPassword;
89 private boolean cassandraSsl;
90 private String cassandraTruststorePath;
91 private String cassandraTruststorePassword;
92 private String windowsDownloadDirectory;
93 private boolean captureTraffic;
94 private boolean useBrowserMobProxy;
95 private String sdcHttpMethod;
96 private String localDataCenter;
98 public String getLocalDataCenter() {
99 return localDataCenter;
102 public void setLocalDataCenter(String localDataCenter) {
103 this.localDataCenter = localDataCenter;
106 private static Config configIt = null;
108 private static Yaml yaml = new Yaml();
115 public static class TestPackages {
117 List<String> packages;
120 public List<String> getPackages() {
124 public void setPackages(List<String> packages) {
125 this.packages = packages;
128 public List<String> getBugs() {
132 public void setBugs(List<String> bugs) {
137 public String toString() {
138 return "TestPackages [packages=" + packages + ", bugs=" + bugs + "]";
143 public synchronized static Config instance() {
144 if (configIt == null) {
147 } catch (IOException e) {
155 private static Config init() throws IOException {
157 Config config = null;
159 String configFile = System.getProperty("config.resource");
160 if (configFile == null) {
161 if (System.getProperty("os.name").contains("Windows")) {
162 configFile = WINDOWS_CONFIG_FILE;
163 } else if (System.getProperty("os.name").contains("Mac")) {
164 configFile = WINDOWS_CONFIG_FILE;
166 throw new RuntimeException("Please Add Jvm Argument config.resource");
170 File file = new File(configFile);
171 if (false == file.exists()) {
172 throw new RuntimeException("The config file " + configFile + " cannot be found.");
175 InputStream in = null;
178 in = Files.newInputStream(Paths.get(configFile));
180 config = yaml.loadAs(in, Config.class);
182 setPackagesAndBugs(configFile, config);
188 } catch (IOException e) {
194 // JsonReader jsonReader = new JsonReader(new FileReader(configFile));
195 // Config configAttOdlIt = new Gson().fromJson(jsonReader,
201 private static void setPackagesAndBugs(String path, Config config) throws IOException {
203 int separator = Math.max(path.lastIndexOf("\\"), path.lastIndexOf("/"));
204 String dirPath = path.substring(0, separator + 1);
205 String packagesFile = dirPath + File.separator + "attsdc-packages.yaml";
206 File file = new File(packagesFile);
207 if (false == file.exists()) {
208 throw new RuntimeException("The config file " + packagesFile + " cannot be found.");
211 TestPackages testPackages = null;
212 InputStream in = null;
215 in = Files.newInputStream(Paths.get(packagesFile));
217 testPackages = yaml.loadAs(in, TestPackages.class);
219 List<String> bugs = testPackages.getBugs();
220 List<String> packages = testPackages.getPackages();
222 config.setBugs(bugs);
223 config.setPackages(packages);
229 } catch (IOException e) {
237 // public Config(String catalogBeHost, String esHost, String esPort, String
238 // resourceConfigDir, String componentsConfigDir, String catalogFeHost,
239 // String catalogFePort, String catalogBePort) {
241 // this.catalogBeHost = catalogBeHost;
242 // this.esHost = esHost;
243 // this.esPort = esPort;
244 // this.resourceConfigDir = resourceConfigDir;
245 // this.componentsConfigDir = componentsConfigDir;
246 // this.catalogFeHost = catalogFeHost;
247 // this.catalogFePort = catalogFePort;
248 // this.catalogBePort = catalogBePort;
251 String configurationFile;
253 public boolean getSystemUnderDebug() {
254 return systemUnderDebug;
257 public void setSystemUnderDebug(boolean systemUnderDebug) {
258 this.systemUnderDebug = systemUnderDebug;
261 public String getSdcHttpMethod() {
262 return sdcHttpMethod;
265 public void setSdcHttpMethod(String sdcHttpMethod) {
266 this.sdcHttpMethod = sdcHttpMethod;
269 public boolean getRerun() {
273 public void setRerun(boolean rerun) {
277 public String getReportDBhost() {
281 public void setReportDBhost(String reportDBhost) {
282 this.reportDBhost = reportDBhost;
285 public int getReportDBport() {
289 public void setReportDBport(int reportDBport) {
290 this.reportDBport = reportDBport;
292 // public boolean isUsingBrowserMobProxy() {
293 // return useBrowserMobProxy;
296 // public void setUsingBrowserMobProxy(boolean usingBrowserMobProxy) {
297 // this.useBrowserMobProxy = usingBrowserMobProxy;
303 public String getBrowser() {
307 public boolean getUseBrowserMobProxy() {
308 return useBrowserMobProxy;
311 public void setUseBrowserMobProxy(boolean useBrowserMobProxy) {
312 this.useBrowserMobProxy = useBrowserMobProxy;
317 public boolean getCaptureTraffic() {
318 return captureTraffic;
321 public void setCaptureTraffic(boolean captureTraffic) {
322 this.captureTraffic = captureTraffic;
325 public void setBrowser(String browser) {
326 this.browser = browser;
329 public String getConfigurationFile() {
330 return configurationFile;
333 public void setConfigurationFile(String configurationFile) {
334 this.configurationFile = configurationFile;
337 public boolean getIsDistributionClientRunning() {
338 return isDistributionClientRunning;
341 public void setIsDistributionClientRunning(boolean isDistributionClientRunning) {
342 this.isDistributionClientRunning = isDistributionClientRunning;
345 public String getCatalogBePort() {
346 return catalogBePort;
349 public String getDisributionClientHost() {
350 return disributionClientHost;
353 public void setDisributionClientHost(String disributionClientHost) {
354 this.disributionClientHost = disributionClientHost;
357 public String getDisributionClientPort() {
358 return disributionClientPort;
361 public void setDisributionClientPort(String disributionClientPort) {
362 this.disributionClientPort = disributionClientPort;
365 public void setCatalogBePort(String catalogBePort) {
366 this.catalogBePort = catalogBePort;
369 public String getCatalogFeHost() {
370 return catalogFeHost;
373 public void setCatalogFeHost(String catalogFeHost) {
374 this.catalogFeHost = catalogFeHost;
377 public String getCatalogFePort() {
378 return catalogFePort;
381 public void setCatalogFePort(String catalogFePort) {
382 this.catalogFePort = catalogFePort;
385 public String getCatalogBeHost() {
386 return catalogBeHost;
389 public void setCatalogBeHost(String catalogBeHost) {
390 this.catalogBeHost = catalogBeHost;
393 public String getEsHost() {
397 public void setEsHost(String esHost) {
398 this.esHost = esHost;
401 public String getEsPort() {
405 public void setEsPort(String esPort) {
406 this.esPort = esPort;
409 public String getResourceConfigDir() {
410 return resourceConfigDir;
413 public void setResourceConfigDir(String resourceConfigDir) {
414 this.resourceConfigDir = resourceConfigDir;
417 public String getComponentsConfigDir() {
418 return componentsConfigDir;
421 public void setComponentsConfigDir(String componentsConfigDir) {
422 this.componentsConfigDir = componentsConfigDir;
425 public String getOutputFolder() {
429 public void setOutputFolder(String outputFolder) {
430 this.outputFolder = outputFolder;
433 public String getReportName() {
437 public void setReportName(String reportName) {
438 this.reportName = reportName;
441 public String getNeoPort() {
445 public void setNeoPort(String neoPort) {
446 this.neoPort = neoPort;
449 public String getNeoHost() {
453 public void setNeoHost(String neoHost) {
454 this.neoHost = neoHost;
457 public String getNeoDBpassword() {
458 return neoDBpassword;
461 public String getNeoDBusername() {
462 return neoDBusername;
465 public void setNeoDBusername(String neoDBusername) {
466 this.neoDBusername = neoDBusername;
469 public void setNeoDBpassword(String neoDBpassword) {
470 this.neoDBpassword = neoDBpassword;
473 public String getTitanPropertiesFile() {
474 return titanPropertiesFile;
477 public void setTitanPropertiesFile(String titanPropertiesFile) {
478 this.titanPropertiesFile = titanPropertiesFile;
481 public List<String> getPackages() {
485 public void setPackages(List<String> packages) {
486 this.packages = packages;
489 public List<String> getBugs() {
493 public void setBugs(List<String> bugs) {
497 public boolean isStopOnClassFailure() {
498 return stopOnClassFailure;
501 public void setStopOnClassFailure(boolean stopOnClassFailure) {
502 this.stopOnClassFailure = stopOnClassFailure;
505 public String getImportResourceConfigDir() {
506 return importResourceConfigDir;
509 public void setImportResourceConfigDir(String importResourceConfigDir) {
510 this.importResourceConfigDir = importResourceConfigDir;
513 public String getImportResourceTestsConfigDir() {
514 return importResourceTestsConfigDir;
517 public void setImportResourceTestsConfigDir(String importResourceTestsConfigDir) {
518 this.importResourceTestsConfigDir = importResourceTestsConfigDir;
521 public String getErrorConfigurationFile() {
522 return errorConfigurationFile;
525 public void setErrorConfigurationFile(String errorConfigurationFile) {
526 this.errorConfigurationFile = errorConfigurationFile;
529 public String getCatalogBeTlsPort() {
530 return catalogBeTlsPort;
533 public void setCatalogBeTlsPort(String catalogBeTlsPort) {
534 this.catalogBeTlsPort = catalogBeTlsPort;
537 public List<String> getResourcesNotToDelete() {
538 return resourcesNotToDelete;
541 public void setResourcesNotToDelete(List<String> resourcesNotToDelete) {
542 this.resourcesNotToDelete = resourcesNotToDelete;
545 public List<String> getResourceCategoriesNotToDelete() {
546 return resourceCategoriesNotToDelete;
549 public void setResourceCategoriesNotToDelete(List<String> resourceCategoriesNotToDelete) {
550 this.resourceCategoriesNotToDelete = resourceCategoriesNotToDelete;
553 public List<String> getServiceCategoriesNotToDelete() {
554 return serviceCategoriesNotToDelete;
557 public void setServiceCategoriesNotToDelete(List<String> serviceCategoriesNotToDelete) {
558 this.serviceCategoriesNotToDelete = serviceCategoriesNotToDelete;
561 public String getImportTypesConfigDir() {
562 return importTypesConfigDir;
565 public void setImportTypesConfigDir(String importTypesConfigDir) {
566 this.importTypesConfigDir = importTypesConfigDir;
569 public String getCassandraHost() {
570 return cassandraHost;
573 public void setCassandraHost(String cassandraHost) {
574 this.cassandraHost = cassandraHost;
577 public String getCassandraAuditKeySpace() {
578 return cassandraAuditKeySpace;
581 public void setCassandraAuditKeySpace(String cassandraAuditKeySpace) {
582 this.cassandraAuditKeySpace = cassandraAuditKeySpace;
585 public String getCassandraArtifactKeySpace() {
586 return cassandraArtifactKeySpace;
589 public void setCassandraArtifactKeySpace(String cassandraArtifactKeySpace) {
590 this.cassandraArtifactKeySpace = cassandraArtifactKeySpace;
594 public String getWindowsDownloadDirectory() {
595 return windowsDownloadDirectory;
598 public void setWindowsDownloadDirectory(String windowsDownloadDirectory) {
599 this.windowsDownloadDirectory = windowsDownloadDirectory;
603 public String toString() {
604 return "Config [systemUnderDebug=" + systemUnderDebug + ", rerun=" + rerun + ", reportDBhost=" + reportDBhost
605 + ", reportDBport=" + reportDBport + ", browser=" + browser + ", catalogBeHost=" + catalogBeHost
606 + ", esHost=" + esHost + ", esPort=" + esPort + ", neoHost=" + neoHost + ", neoPort=" + neoPort
607 + ", disributionClientHost=" + disributionClientHost + ", disributionClientPort="
608 + disributionClientPort + ", isDistributionClientRunning=" + isDistributionClientRunning
609 + ", errorConfigurationFile=" + errorConfigurationFile + ", resourceConfigDir=" + resourceConfigDir
610 + ", componentsConfigDir=" + componentsConfigDir + ", importResourceConfigDir="
611 + importResourceConfigDir + ", importResourceTestsConfigDir=" + importResourceTestsConfigDir
612 + ", importTypesConfigDir=" + importTypesConfigDir + ", testSuites=" + testSuites + ", catalogFeHost="
613 + catalogFeHost + ", catalogFePort=" + catalogFePort + ", catalogBePort=" + catalogBePort
614 + ", catalogBeTlsPort=" + catalogBeTlsPort + ", neoDBusername=" + neoDBusername + ", neoDBpassword="
615 + neoDBpassword + ", titanPropertiesFile=" + titanPropertiesFile + ", packages=" + packages + ", bugs="
616 + bugs + ", resourcesNotToDelete=" + resourcesNotToDelete + ", resourceCategoriesNotToDelete="
617 + resourceCategoriesNotToDelete + ", serviceCategoriesNotToDelete=" + serviceCategoriesNotToDelete
618 + ", stopOnClassFailure=" + stopOnClassFailure + ", outputFolder=" + outputFolder + ", reportName="
619 + reportName + ", url=" + url + ", remoteTestingMachineIP=" + remoteTestingMachineIP
620 + ", remoteTestingMachinePort=" + remoteTestingMachinePort + ", remoteTesting=" + remoteTesting
621 + ", cassandraHost=" + cassandraHost + ", cassandraAuditKeySpace=" + cassandraAuditKeySpace
622 + ", cassandraArtifactKeySpace=" + cassandraArtifactKeySpace + ", cassandraAuthenticate="
623 + cassandraAuthenticate + ", cassandraUsername=" + cassandraUsername + ", cassandraPassword="
624 + cassandraPassword + ", cassandraSsl=" + cassandraSsl + ", cassandraTruststorePath="
625 + cassandraTruststorePath + ", cassandraTruststorePassword=" + cassandraTruststorePassword
626 + ", windowsDownloadDirectory=" + windowsDownloadDirectory + ", captureTraffic=" + captureTraffic
627 + ", useBrowserMobProxy=" + useBrowserMobProxy + ", configurationFile=" + configurationFile + "]";
630 public boolean isRemoteTesting() {
631 return remoteTesting;
634 public void setRemoteTesting(boolean remoteTesting) {
635 this.remoteTesting = remoteTesting;
638 public String getUrl() {
641 } catch (Exception e) {
646 public void setUrl(String url) {
650 public String getRemoteTestingMachineIP() {
651 return remoteTestingMachineIP;
654 public void setRemoteTestingMachineIP(String remoteTestingMachineIP) {
655 this.remoteTestingMachineIP = remoteTestingMachineIP;
658 public String getRemoteTestingMachinePort() {
659 return remoteTestingMachinePort;
662 public void setRemoteTestingMachinePort(String remoteTestingMachinePort) {
663 this.remoteTestingMachinePort = remoteTestingMachinePort;
666 public boolean getCassandraAuthenticate() {
667 return cassandraAuthenticate;
670 public void setCassandraAuthenticate(boolean cassandraAuthenticate) {
671 this.cassandraAuthenticate = cassandraAuthenticate;
674 public String getCassandraUsername() {
675 return cassandraUsername;
678 public void setCassandraUsername(String cassandraUsername) {
679 this.cassandraUsername = cassandraUsername;
682 public String getCassandraPassword() {
683 return cassandraPassword;
686 public void setCassandraPassword(String cassandraPassword) {
687 this.cassandraPassword = cassandraPassword;
690 public boolean getCassandraSsl() {
694 public void setCassandraSsl(boolean cassandraSsl) {
695 this.cassandraSsl = cassandraSsl;
698 public String getCassandraTruststorePath() {
699 return cassandraTruststorePath;
702 public void setCassandraTruststorePath(String cassandraTruststorePath) {
703 this.cassandraTruststorePath = cassandraTruststorePath;
706 public String getCassandraTruststorePassword() {
707 return cassandraTruststorePassword;
710 public void setCassandraTruststorePassword(String cassandraTruststorePassword) {
711 this.cassandraTruststorePassword = cassandraTruststorePassword;