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;
96 private static Config configIt = null;
98 private static Yaml yaml = new Yaml();
105 public static class TestPackages {
107 List<String> packages;
110 public List<String> getPackages() {
114 public void setPackages(List<String> packages) {
115 this.packages = packages;
118 public List<String> getBugs() {
122 public void setBugs(List<String> bugs) {
127 public String toString() {
128 return "TestPackages [packages=" + packages + ", bugs=" + bugs + "]";
133 public synchronized static Config instance() {
134 if (configIt == null) {
137 } catch (IOException e) {
145 private static Config init() throws IOException {
147 Config config = null;
149 String configFile = System.getProperty("config.resource");
150 if (configFile == null) {
151 if (System.getProperty("os.name").contains("Windows")) {
152 configFile = WINDOWS_CONFIG_FILE;
154 throw new RuntimeException("Please Add Jvm Argument config.resource");
158 File file = new File(configFile);
159 if (false == file.exists()) {
160 throw new RuntimeException("The config file " + configFile + " cannot be found.");
163 InputStream in = null;
166 in = Files.newInputStream(Paths.get(configFile));
168 config = yaml.loadAs(in, Config.class);
170 setPackagesAndBugs(configFile, config);
176 } catch (IOException e) {
177 // TODO Auto-generated catch block
183 // JsonReader jsonReader = new JsonReader(new FileReader(configFile));
184 // Config configAttOdlIt = new Gson().fromJson(jsonReader,
190 private static void setPackagesAndBugs(String path, Config config) throws IOException {
192 int separator = Math.max(path.lastIndexOf("\\"), path.lastIndexOf("/"));
193 String dirPath = path.substring(0, separator + 1);
194 String packagesFile = dirPath + File.separator + "attsdc-packages.yaml";
195 File file = new File(packagesFile);
196 if (false == file.exists()) {
197 throw new RuntimeException("The config file " + packagesFile + " cannot be found.");
200 TestPackages testPackages = null;
201 InputStream in = null;
204 in = Files.newInputStream(Paths.get(packagesFile));
206 testPackages = yaml.loadAs(in, TestPackages.class);
208 List<String> bugs = testPackages.getBugs();
209 List<String> packages = testPackages.getPackages();
211 config.setBugs(bugs);
212 config.setPackages(packages);
218 } catch (IOException e) {
219 // TODO Auto-generated catch block
227 // public Config(String catalogBeHost, String esHost, String esPort, String
228 // resourceConfigDir, String componentsConfigDir, String catalogFeHost,
229 // String catalogFePort, String catalogBePort) {
231 // this.catalogBeHost = catalogBeHost;
232 // this.esHost = esHost;
233 // this.esPort = esPort;
234 // this.resourceConfigDir = resourceConfigDir;
235 // this.componentsConfigDir = componentsConfigDir;
236 // this.catalogFeHost = catalogFeHost;
237 // this.catalogFePort = catalogFePort;
238 // this.catalogBePort = catalogBePort;
241 String configurationFile;
243 public boolean getSystemUnderDebug() {
244 return systemUnderDebug;
247 public void setSystemUnderDebug(boolean systemUnderDebug) {
248 this.systemUnderDebug = systemUnderDebug;
251 public boolean getRerun() {
255 public void setRerun(boolean rerun) {
259 public String getReportDBhost() {
263 public void setReportDBhost(String reportDBhost) {
264 this.reportDBhost = reportDBhost;
267 public int getReportDBport() {
271 public void setReportDBport(int reportDBport) {
272 this.reportDBport = reportDBport;
274 // public boolean isUsingBrowserMobProxy() {
275 // return useBrowserMobProxy;
278 // public void setUsingBrowserMobProxy(boolean usingBrowserMobProxy) {
279 // this.useBrowserMobProxy = usingBrowserMobProxy;
285 public String getBrowser() {
289 public boolean getUseBrowserMobProxy() {
290 return useBrowserMobProxy;
293 public void setUseBrowserMobProxy(boolean useBrowserMobProxy) {
294 this.useBrowserMobProxy = useBrowserMobProxy;
299 public boolean getCaptureTraffic() {
300 return captureTraffic;
303 public void setCaptureTraffic(boolean captureTraffic) {
304 this.captureTraffic = captureTraffic;
307 public void setBrowser(String browser) {
308 this.browser = browser;
311 public String getConfigurationFile() {
312 return configurationFile;
315 public void setConfigurationFile(String configurationFile) {
316 this.configurationFile = configurationFile;
319 public boolean getIsDistributionClientRunning() {
320 return isDistributionClientRunning;
323 public void setIsDistributionClientRunning(boolean isDistributionClientRunning) {
324 this.isDistributionClientRunning = isDistributionClientRunning;
327 public String getCatalogBePort() {
328 return catalogBePort;
331 public String getDisributionClientHost() {
332 return disributionClientHost;
335 public void setDisributionClientHost(String disributionClientHost) {
336 this.disributionClientHost = disributionClientHost;
339 public String getDisributionClientPort() {
340 return disributionClientPort;
343 public void setDisributionClientPort(String disributionClientPort) {
344 this.disributionClientPort = disributionClientPort;
347 public void setCatalogBePort(String catalogBePort) {
348 this.catalogBePort = catalogBePort;
351 public String getCatalogFeHost() {
352 return catalogFeHost;
355 public void setCatalogFeHost(String catalogFeHost) {
356 this.catalogFeHost = catalogFeHost;
359 public String getCatalogFePort() {
360 return catalogFePort;
363 public void setCatalogFePort(String catalogFePort) {
364 this.catalogFePort = catalogFePort;
367 public String getCatalogBeHost() {
368 return catalogBeHost;
371 public void setCatalogBeHost(String catalogBeHost) {
372 this.catalogBeHost = catalogBeHost;
375 public String getEsHost() {
379 public void setEsHost(String esHost) {
380 this.esHost = esHost;
383 public String getEsPort() {
387 public void setEsPort(String esPort) {
388 this.esPort = esPort;
391 public String getResourceConfigDir() {
392 return resourceConfigDir;
395 public void setResourceConfigDir(String resourceConfigDir) {
396 this.resourceConfigDir = resourceConfigDir;
399 public String getComponentsConfigDir() {
400 return componentsConfigDir;
403 public void setComponentsConfigDir(String componentsConfigDir) {
404 this.componentsConfigDir = componentsConfigDir;
407 public String getOutputFolder() {
411 public void setOutputFolder(String outputFolder) {
412 this.outputFolder = outputFolder;
415 public String getReportName() {
419 public void setReportName(String reportName) {
420 this.reportName = reportName;
423 public String getNeoPort() {
427 public void setNeoPort(String neoPort) {
428 this.neoPort = neoPort;
431 public String getNeoHost() {
435 public void setNeoHost(String neoHost) {
436 this.neoHost = neoHost;
439 public String getNeoDBpassword() {
440 return neoDBpassword;
443 public String getNeoDBusername() {
444 return neoDBusername;
447 public void setNeoDBusername(String neoDBusername) {
448 this.neoDBusername = neoDBusername;
451 public void setNeoDBpassword(String neoDBpassword) {
452 this.neoDBpassword = neoDBpassword;
455 public String getTitanPropertiesFile() {
456 return titanPropertiesFile;
459 public void setTitanPropertiesFile(String titanPropertiesFile) {
460 this.titanPropertiesFile = titanPropertiesFile;
463 public List<String> getPackages() {
467 public void setPackages(List<String> packages) {
468 this.packages = packages;
471 public List<String> getBugs() {
475 public void setBugs(List<String> bugs) {
479 public boolean isStopOnClassFailure() {
480 return stopOnClassFailure;
483 public void setStopOnClassFailure(boolean stopOnClassFailure) {
484 this.stopOnClassFailure = stopOnClassFailure;
487 public String getImportResourceConfigDir() {
488 return importResourceConfigDir;
491 public void setImportResourceConfigDir(String importResourceConfigDir) {
492 this.importResourceConfigDir = importResourceConfigDir;
495 public String getImportResourceTestsConfigDir() {
496 return importResourceTestsConfigDir;
499 public void setImportResourceTestsConfigDir(String importResourceTestsConfigDir) {
500 this.importResourceTestsConfigDir = importResourceTestsConfigDir;
503 public String getErrorConfigurationFile() {
504 return errorConfigurationFile;
507 public void setErrorConfigurationFile(String errorConfigurationFile) {
508 this.errorConfigurationFile = errorConfigurationFile;
511 public String getCatalogBeTlsPort() {
512 return catalogBeTlsPort;
515 public void setCatalogBeTlsPort(String catalogBeTlsPort) {
516 this.catalogBeTlsPort = catalogBeTlsPort;
519 public List<String> getResourcesNotToDelete() {
520 return resourcesNotToDelete;
523 public void setResourcesNotToDelete(List<String> resourcesNotToDelete) {
524 this.resourcesNotToDelete = resourcesNotToDelete;
527 public List<String> getResourceCategoriesNotToDelete() {
528 return resourceCategoriesNotToDelete;
531 public void setResourceCategoriesNotToDelete(List<String> resourceCategoriesNotToDelete) {
532 this.resourceCategoriesNotToDelete = resourceCategoriesNotToDelete;
535 public List<String> getServiceCategoriesNotToDelete() {
536 return serviceCategoriesNotToDelete;
539 public void setServiceCategoriesNotToDelete(List<String> serviceCategoriesNotToDelete) {
540 this.serviceCategoriesNotToDelete = serviceCategoriesNotToDelete;
543 public String getImportTypesConfigDir() {
544 return importTypesConfigDir;
547 public void setImportTypesConfigDir(String importTypesConfigDir) {
548 this.importTypesConfigDir = importTypesConfigDir;
551 public String getCassandraHost() {
552 return cassandraHost;
555 public void setCassandraHost(String cassandraHost) {
556 this.cassandraHost = cassandraHost;
559 public String getCassandraAuditKeySpace() {
560 return cassandraAuditKeySpace;
563 public void setCassandraAuditKeySpace(String cassandraAuditKeySpace) {
564 this.cassandraAuditKeySpace = cassandraAuditKeySpace;
567 public String getCassandraArtifactKeySpace() {
568 return cassandraArtifactKeySpace;
571 public void setCassandraArtifactKeySpace(String cassandraArtifactKeySpace) {
572 this.cassandraArtifactKeySpace = cassandraArtifactKeySpace;
576 public String getWindowsDownloadDirectory() {
577 return windowsDownloadDirectory;
580 public void setWindowsDownloadDirectory(String windowsDownloadDirectory) {
581 this.windowsDownloadDirectory = windowsDownloadDirectory;
585 public String toString() {
586 return "Config [systemUnderDebug=" + systemUnderDebug + ", rerun=" + rerun + ", reportDBhost=" + reportDBhost
587 + ", reportDBport=" + reportDBport + ", browser=" + browser + ", catalogBeHost=" + catalogBeHost
588 + ", esHost=" + esHost + ", esPort=" + esPort + ", neoHost=" + neoHost + ", neoPort=" + neoPort
589 + ", disributionClientHost=" + disributionClientHost + ", disributionClientPort="
590 + disributionClientPort + ", isDistributionClientRunning=" + isDistributionClientRunning
591 + ", errorConfigurationFile=" + errorConfigurationFile + ", resourceConfigDir=" + resourceConfigDir
592 + ", componentsConfigDir=" + componentsConfigDir + ", importResourceConfigDir="
593 + importResourceConfigDir + ", importResourceTestsConfigDir=" + importResourceTestsConfigDir
594 + ", importTypesConfigDir=" + importTypesConfigDir + ", testSuites=" + testSuites + ", catalogFeHost="
595 + catalogFeHost + ", catalogFePort=" + catalogFePort + ", catalogBePort=" + catalogBePort
596 + ", catalogBeTlsPort=" + catalogBeTlsPort + ", neoDBusername=" + neoDBusername + ", neoDBpassword="
597 + neoDBpassword + ", titanPropertiesFile=" + titanPropertiesFile + ", packages=" + packages + ", bugs="
598 + bugs + ", resourcesNotToDelete=" + resourcesNotToDelete + ", resourceCategoriesNotToDelete="
599 + resourceCategoriesNotToDelete + ", serviceCategoriesNotToDelete=" + serviceCategoriesNotToDelete
600 + ", stopOnClassFailure=" + stopOnClassFailure + ", outputFolder=" + outputFolder + ", reportName="
601 + reportName + ", url=" + url + ", remoteTestingMachineIP=" + remoteTestingMachineIP
602 + ", remoteTestingMachinePort=" + remoteTestingMachinePort + ", remoteTesting=" + remoteTesting
603 + ", cassandraHost=" + cassandraHost + ", cassandraAuditKeySpace=" + cassandraAuditKeySpace
604 + ", cassandraArtifactKeySpace=" + cassandraArtifactKeySpace + ", cassandraAuthenticate="
605 + cassandraAuthenticate + ", cassandraUsername=" + cassandraUsername + ", cassandraPassword="
606 + cassandraPassword + ", cassandraSsl=" + cassandraSsl + ", cassandraTruststorePath="
607 + cassandraTruststorePath + ", cassandraTruststorePassword=" + cassandraTruststorePassword
608 + ", windowsDownloadDirectory=" + windowsDownloadDirectory + ", captureTraffic=" + captureTraffic
609 + ", useBrowserMobProxy=" + useBrowserMobProxy + ", configurationFile=" + configurationFile + "]";
612 public boolean isRemoteTesting() {
613 return remoteTesting;
616 public void setRemoteTesting(boolean remoteTesting) {
617 this.remoteTesting = remoteTesting;
620 public String getUrl() {
623 } catch (Exception e) {
628 public void setUrl(String url) {
632 public String getRemoteTestingMachineIP() {
633 return remoteTestingMachineIP;
636 public void setRemoteTestingMachineIP(String remoteTestingMachineIP) {
637 this.remoteTestingMachineIP = remoteTestingMachineIP;
640 public String getRemoteTestingMachinePort() {
641 return remoteTestingMachinePort;
644 public void setRemoteTestingMachinePort(String remoteTestingMachinePort) {
645 this.remoteTestingMachinePort = remoteTestingMachinePort;
648 public boolean getCassandraAuthenticate() {
649 return cassandraAuthenticate;
652 public void setCassandraAuthenticate(boolean cassandraAuthenticate) {
653 this.cassandraAuthenticate = cassandraAuthenticate;
656 public String getCassandraUsername() {
657 return cassandraUsername;
660 public void setCassandraUsername(String cassandraUsername) {
661 this.cassandraUsername = cassandraUsername;
664 public String getCassandraPassword() {
665 return cassandraPassword;
668 public void setCassandraPassword(String cassandraPassword) {
669 this.cassandraPassword = cassandraPassword;
672 public boolean getCassandraSsl() {
676 public void setCassandraSsl(boolean cassandraSsl) {
677 this.cassandraSsl = cassandraSsl;
680 public String getCassandraTruststorePath() {
681 return cassandraTruststorePath;
684 public void setCassandraTruststorePath(String cassandraTruststorePath) {
685 this.cassandraTruststorePath = cassandraTruststorePath;
688 public String getCassandraTruststorePassword() {
689 return cassandraTruststorePassword;
692 public void setCassandraTruststorePassword(String cassandraTruststorePassword) {
693 this.cassandraTruststorePassword = cassandraTruststorePassword;