Create on boarding docker
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / config / Config.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.ci.tests.config;
22
23 import java.io.File;
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;
29
30 import org.yaml.snakeyaml.Yaml;
31
32 public class Config {
33
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;
39         
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;
49
50
51         private String errorConfigurationFile;
52         private String resourceConfigDir;
53         private String componentsConfigDir;
54         private String importResourceConfigDir;
55         private String importResourceTestsConfigDir;
56         private String importTypesConfigDir;
57
58         private String testSuites;
59
60         private String catalogFeHost;
61         private String catalogFePort;
62         private String catalogBePort;
63         private String catalogBeTlsPort;
64
65         private String onboardingBeHost;
66         private String onboardingBePort;
67
68         private String neoDBusername;
69         private String neoDBpassword;
70
71         private String titanPropertiesFile;
72         private List<String> packages;
73         private List<String> bugs;
74         private List<String> resourcesNotToDelete;
75         private List<String> resourceCategoriesNotToDelete;
76         private List<String> serviceCategoriesNotToDelete;
77         private boolean stopOnClassFailure = false;
78
79         private String outputFolder;
80         private String reportName;
81         private String url;
82         private String remoteTestingMachineIP;
83         private String remoteTestingMachinePort;
84         private boolean remoteTesting;
85
86         private String cassandraHost;
87         private String cassandraAuditKeySpace;
88         private String cassandraArtifactKeySpace;
89         private boolean cassandraAuthenticate;
90         private String cassandraUsername;
91         private String cassandraPassword;
92         private boolean cassandraSsl;
93         private String cassandraTruststorePath;
94         private String cassandraTruststorePassword;
95         private String windowsDownloadDirectory;
96         private boolean captureTraffic;
97         private boolean useBrowserMobProxy;
98         private String sdcHttpMethod;
99         private String localDataCenter;
100         private boolean uiSimulator;
101
102         public String getLocalDataCenter() {
103                 return localDataCenter;
104         }
105
106         public void setLocalDataCenter(String localDataCenter) {
107                 this.localDataCenter = localDataCenter;
108         }
109
110         private static Config configIt = null;
111
112         private static Yaml yaml = new Yaml();
113
114         
115         private Config() {
116                 super();
117         }
118
119         public String getOnboardingBePort() {
120                 return onboardingBePort;
121         }
122
123         public void setOnboardingBePort(String onboardingBePort) {
124                 this.onboardingBePort = onboardingBePort;
125         }
126
127         public String getOnboardingBeHost() {
128                 return onboardingBeHost;
129         }
130
131         public void setOnboardingBeHost(String onboardingBeHost) {
132                 this.onboardingBeHost = onboardingBeHost;
133         }
134
135         public static class TestPackages {
136
137                 List<String> packages;
138                 List<String> bugs;
139
140                 public List<String> getPackages() {
141                         return packages;
142                 }
143
144                 public void setPackages(List<String> packages) {
145                         this.packages = packages;
146                 }
147
148                 public List<String> getBugs() {
149                         return bugs;
150                 }
151
152                 public void setBugs(List<String> bugs) {
153                         this.bugs = bugs;
154                 }
155
156                 @Override
157                 public String toString() {
158                         return "TestPackages [packages=" + packages + ", bugs=" + bugs + "]";
159                 }
160
161         }
162
163         public synchronized static Config instance() {
164                 if (configIt == null) {
165                         try {
166                                 configIt = init();
167                         } catch (IOException e) {
168                                 e.printStackTrace();
169                                 return null;
170                         }
171                 }
172                 return configIt;
173         }
174
175         private static Config init() throws IOException {
176
177                 Config config = null;
178
179                 String configFile = System.getProperty("config.resource");
180                 if (configFile == null) {
181                         if (System.getProperty("os.name").contains("Windows")) {
182                                 configFile = WINDOWS_CONFIG_FILE;
183                         } else if (System.getProperty("os.name").contains("Mac")) {
184                                 configFile = WINDOWS_CONFIG_FILE;
185                         } else {
186                                 throw new RuntimeException("Please Add Jvm Argument config.resource");
187                         }
188                 }
189
190                 File file = new File(configFile);
191                 if (false == file.exists()) {
192                         throw new RuntimeException("The config file " + configFile + " cannot be found.");
193                 }
194
195                 InputStream in = null;
196                 try {
197
198                         in = Files.newInputStream(Paths.get(configFile));
199
200                         config = yaml.loadAs(in, Config.class);
201
202                         setPackagesAndBugs(configFile, config);
203
204                 } finally {
205                         if (in != null) {
206                                 try {
207                                         in.close();
208                                 } catch (IOException e) {
209                                         e.printStackTrace();
210                                 }
211                         }
212                 }
213
214                 // JsonReader jsonReader = new JsonReader(new FileReader(configFile));
215                 // Config configAttOdlIt = new Gson().fromJson(jsonReader,
216                 // Config.class);
217
218                 return config;
219         }
220
221         public boolean isUiSimulator() {
222                 return uiSimulator;
223         }
224
225         public void setUiSimulator(boolean uiSimulator) {
226                 this.uiSimulator = uiSimulator;
227         }
228
229         private static void setPackagesAndBugs(String path, Config config) throws IOException {
230
231                 int separator = Math.max(path.lastIndexOf("\\"), path.lastIndexOf("/"));
232                 String dirPath = path.substring(0, separator + 1);
233                 String packagesFile = dirPath + File.separator + "attsdc-packages.yaml";
234                 File file = new File(packagesFile);
235                 if (false == file.exists()) {
236                         throw new RuntimeException("The config file " + packagesFile + " cannot be found.");
237                 }
238
239                 TestPackages testPackages = null;
240                 InputStream in = null;
241                 try {
242
243                         in = Files.newInputStream(Paths.get(packagesFile));
244
245                         testPackages = yaml.loadAs(in, TestPackages.class);
246
247                         List<String> bugs = testPackages.getBugs();
248                         List<String> packages = testPackages.getPackages();
249
250                         config.setBugs(bugs);
251                         config.setPackages(packages);
252
253                 } finally {
254                         if (in != null) {
255                                 try {
256                                         in.close();
257                                 } catch (IOException e) {
258                                         e.printStackTrace();
259                                 }
260                         }
261                 }
262
263         }
264
265         // public Config(String catalogBeHost, String esHost, String esPort, String
266         // resourceConfigDir, String componentsConfigDir, String catalogFeHost,
267         // String catalogFePort, String catalogBePort) {
268         // super();
269         // this.catalogBeHost = catalogBeHost;
270         // this.esHost = esHost;
271         // this.esPort = esPort;
272         // this.resourceConfigDir = resourceConfigDir;
273         // this.componentsConfigDir = componentsConfigDir;
274         // this.catalogFeHost = catalogFeHost;
275         // this.catalogFePort = catalogFePort;
276         // this.catalogBePort = catalogBePort;
277         // }
278
279         String configurationFile;
280         
281         public boolean getSystemUnderDebug() {
282                 return systemUnderDebug;
283         }
284
285         public void setSystemUnderDebug(boolean systemUnderDebug) {
286                 this.systemUnderDebug = systemUnderDebug;
287         }
288
289         public String getSdcHttpMethod() {
290                 return sdcHttpMethod;
291         }
292
293         public void setSdcHttpMethod(String sdcHttpMethod) {
294                 this.sdcHttpMethod = sdcHttpMethod;
295         }
296
297         public boolean getRerun() {
298                 return rerun;
299         }
300
301         public void setRerun(boolean rerun) {
302                 this.rerun = rerun;
303         }
304         
305         public String getReportDBhost() {
306                 return reportDBhost;
307         }
308
309         public void setReportDBhost(String reportDBhost) {
310                 this.reportDBhost = reportDBhost;
311         }
312
313         public int getReportDBport() {
314                 return reportDBport;
315         }
316
317         public void setReportDBport(int reportDBport) {
318                 this.reportDBport = reportDBport;
319         }
320 //      public boolean isUsingBrowserMobProxy() {
321 //              return useBrowserMobProxy;
322 //      }
323 //
324 //      public void setUsingBrowserMobProxy(boolean usingBrowserMobProxy) {
325 //              this.useBrowserMobProxy = usingBrowserMobProxy;
326 //      } 
327
328         
329         
330         
331         public String getBrowser() {
332                 return browser;
333         }
334         
335         public boolean getUseBrowserMobProxy() {
336                 return useBrowserMobProxy;
337         }
338
339         public void setUseBrowserMobProxy(boolean useBrowserMobProxy) {
340                 this.useBrowserMobProxy = useBrowserMobProxy;
341         }
342
343
344
345         public boolean getCaptureTraffic() {
346                 return captureTraffic;
347         }
348
349         public void setCaptureTraffic(boolean captureTraffic) {
350                 this.captureTraffic = captureTraffic;
351         }
352
353         public void setBrowser(String browser) {
354                 this.browser = browser;
355         }
356
357         public String getConfigurationFile() {
358                 return configurationFile;
359         }
360
361         public void setConfigurationFile(String configurationFile) {
362                 this.configurationFile = configurationFile;
363         }
364
365         public boolean getIsDistributionClientRunning() {
366                 return isDistributionClientRunning;
367         }
368
369         public void setIsDistributionClientRunning(boolean isDistributionClientRunning) {
370                 this.isDistributionClientRunning = isDistributionClientRunning;
371         }
372         
373         public String getCatalogBePort() {
374                 return catalogBePort;
375         }
376
377         public String getDisributionClientHost() {
378                 return disributionClientHost;
379         }
380
381         public void setDisributionClientHost(String disributionClientHost) {
382                 this.disributionClientHost = disributionClientHost;
383         }
384
385         public String getDisributionClientPort() {
386                 return disributionClientPort;
387         }
388
389         public void setDisributionClientPort(String disributionClientPort) {
390                 this.disributionClientPort = disributionClientPort;
391         }
392
393         public void setCatalogBePort(String catalogBePort) {
394                 this.catalogBePort = catalogBePort;
395         }
396
397         public String getCatalogFeHost() {
398                 return catalogFeHost;
399         }
400
401         public void setCatalogFeHost(String catalogFeHost) {
402                 this.catalogFeHost = catalogFeHost;
403         }
404
405         public String getCatalogFePort() {
406                 return catalogFePort;
407         }
408
409         public void setCatalogFePort(String catalogFePort) {
410                 this.catalogFePort = catalogFePort;
411         }
412
413         public String getCatalogBeHost() {
414                 return catalogBeHost;
415         }
416
417         public void setCatalogBeHost(String catalogBeHost) {
418                 this.catalogBeHost = catalogBeHost;
419         }
420
421         public String getEsHost() {
422                 return esHost;
423         }
424
425         public void setEsHost(String esHost) {
426                 this.esHost = esHost;
427         }
428
429         public String getEsPort() {
430                 return esPort;
431         }
432
433         public void setEsPort(String esPort) {
434                 this.esPort = esPort;
435         }
436
437         public String getResourceConfigDir() {
438                 return resourceConfigDir;
439         }
440
441         public void setResourceConfigDir(String resourceConfigDir) {
442                 this.resourceConfigDir = resourceConfigDir;
443         }
444
445         public String getComponentsConfigDir() {
446                 return componentsConfigDir;
447         }
448
449         public void setComponentsConfigDir(String componentsConfigDir) {
450                 this.componentsConfigDir = componentsConfigDir;
451         }
452
453         public String getOutputFolder() {
454                 return outputFolder;
455         }
456
457         public void setOutputFolder(String outputFolder) {
458                 this.outputFolder = outputFolder;
459         }
460
461         public String getReportName() {
462                 return reportName;
463         }
464
465         public void setReportName(String reportName) {
466                 this.reportName = reportName;
467         }
468
469         public String getNeoPort() {
470                 return neoPort;
471         }
472
473         public void setNeoPort(String neoPort) {
474                 this.neoPort = neoPort;
475         }
476
477         public String getNeoHost() {
478                 return neoHost;
479         }
480
481         public void setNeoHost(String neoHost) {
482                 this.neoHost = neoHost;
483         }
484
485         public String getNeoDBpassword() {
486                 return neoDBpassword;
487         }
488
489         public String getNeoDBusername() {
490                 return neoDBusername;
491         }
492
493         public void setNeoDBusername(String neoDBusername) {
494                 this.neoDBusername = neoDBusername;
495         }
496
497         public void setNeoDBpassword(String neoDBpassword) {
498                 this.neoDBpassword = neoDBpassword;
499         }
500
501         public String getTitanPropertiesFile() {
502                 return titanPropertiesFile;
503         }
504
505         public void setTitanPropertiesFile(String titanPropertiesFile) {
506                 this.titanPropertiesFile = titanPropertiesFile;
507         }
508
509         public List<String> getPackages() {
510                 return packages;
511         }
512
513         public void setPackages(List<String> packages) {
514                 this.packages = packages;
515         }
516
517         public List<String> getBugs() {
518                 return bugs;
519         }
520
521         public void setBugs(List<String> bugs) {
522                 this.bugs = bugs;
523         }
524
525         public boolean isStopOnClassFailure() {
526                 return stopOnClassFailure;
527         }
528
529         public void setStopOnClassFailure(boolean stopOnClassFailure) {
530                 this.stopOnClassFailure = stopOnClassFailure;
531         }
532
533         public String getImportResourceConfigDir() {
534                 return importResourceConfigDir;
535         }
536
537         public void setImportResourceConfigDir(String importResourceConfigDir) {
538                 this.importResourceConfigDir = importResourceConfigDir;
539         }
540
541         public String getImportResourceTestsConfigDir() {
542                 return importResourceTestsConfigDir;
543         }
544
545         public void setImportResourceTestsConfigDir(String importResourceTestsConfigDir) {
546                 this.importResourceTestsConfigDir = importResourceTestsConfigDir;
547         }
548
549         public String getErrorConfigurationFile() {
550                 return errorConfigurationFile;
551         }
552
553         public void setErrorConfigurationFile(String errorConfigurationFile) {
554                 this.errorConfigurationFile = errorConfigurationFile;
555         }
556
557         public String getCatalogBeTlsPort() {
558                 return catalogBeTlsPort;
559         }
560
561         public void setCatalogBeTlsPort(String catalogBeTlsPort) {
562                 this.catalogBeTlsPort = catalogBeTlsPort;
563         }
564
565         public List<String> getResourcesNotToDelete() {
566                 return resourcesNotToDelete;
567         }
568
569         public void setResourcesNotToDelete(List<String> resourcesNotToDelete) {
570                 this.resourcesNotToDelete = resourcesNotToDelete;
571         }
572
573         public List<String> getResourceCategoriesNotToDelete() {
574                 return resourceCategoriesNotToDelete;
575         }
576
577         public void setResourceCategoriesNotToDelete(List<String> resourceCategoriesNotToDelete) {
578                 this.resourceCategoriesNotToDelete = resourceCategoriesNotToDelete;
579         }
580
581         public List<String> getServiceCategoriesNotToDelete() {
582                 return serviceCategoriesNotToDelete;
583         }
584
585         public void setServiceCategoriesNotToDelete(List<String> serviceCategoriesNotToDelete) {
586                 this.serviceCategoriesNotToDelete = serviceCategoriesNotToDelete;
587         }
588
589         public String getImportTypesConfigDir() {
590                 return importTypesConfigDir;
591         }
592
593         public void setImportTypesConfigDir(String importTypesConfigDir) {
594                 this.importTypesConfigDir = importTypesConfigDir;
595         }
596
597         public String getCassandraHost() {
598                 return cassandraHost;
599         }
600
601         public void setCassandraHost(String cassandraHost) {
602                 this.cassandraHost = cassandraHost;
603         }
604
605         public String getCassandraAuditKeySpace() {
606                 return cassandraAuditKeySpace;
607         }
608
609         public void setCassandraAuditKeySpace(String cassandraAuditKeySpace) {
610                 this.cassandraAuditKeySpace = cassandraAuditKeySpace;
611         }
612
613         public String getCassandraArtifactKeySpace() {
614                 return cassandraArtifactKeySpace;
615         }
616
617         public void setCassandraArtifactKeySpace(String cassandraArtifactKeySpace) {
618                 this.cassandraArtifactKeySpace = cassandraArtifactKeySpace;
619         }
620
621         
622         public String getWindowsDownloadDirectory() {
623                 return windowsDownloadDirectory;
624         }
625         
626         public void setWindowsDownloadDirectory(String windowsDownloadDirectory) {
627                 this.windowsDownloadDirectory = windowsDownloadDirectory;
628         }
629         
630         @Override
631         public String toString() {
632                 return "Config [systemUnderDebug=" + systemUnderDebug + ", rerun=" + rerun + ", reportDBhost=" + reportDBhost
633                                 + ", reportDBport=" + reportDBport + ", browser=" + browser + ", catalogBeHost=" + catalogBeHost
634                                 + ", esHost=" + esHost + ", esPort=" + esPort + ", neoHost=" + neoHost + ", neoPort=" + neoPort
635                                 + ", disributionClientHost=" + disributionClientHost + ", disributionClientPort="
636                                 + disributionClientPort + ", isDistributionClientRunning=" + isDistributionClientRunning
637                                 + ", errorConfigurationFile=" + errorConfigurationFile + ", resourceConfigDir=" + resourceConfigDir
638                                 + ", componentsConfigDir=" + componentsConfigDir + ", importResourceConfigDir="
639                                 + importResourceConfigDir + ", importResourceTestsConfigDir=" + importResourceTestsConfigDir
640                                 + ", importTypesConfigDir=" + importTypesConfigDir + ", testSuites=" + testSuites + ", catalogFeHost="
641                                 + catalogFeHost + ", catalogFePort=" + catalogFePort + ", catalogBePort=" + catalogBePort
642                                 + ", catalogBeTlsPort=" + catalogBeTlsPort + ", neoDBusername=" + neoDBusername + ", neoDBpassword="
643                                 + neoDBpassword + ", titanPropertiesFile=" + titanPropertiesFile + ", packages=" + packages + ", bugs="
644                                 + bugs + ", resourcesNotToDelete=" + resourcesNotToDelete + ", resourceCategoriesNotToDelete="
645                                 + resourceCategoriesNotToDelete + ", serviceCategoriesNotToDelete=" + serviceCategoriesNotToDelete
646                                 + ", stopOnClassFailure=" + stopOnClassFailure + ", outputFolder=" + outputFolder + ", reportName="
647                                 + reportName + ", url=" + url + ", remoteTestingMachineIP=" + remoteTestingMachineIP
648                                 + ", remoteTestingMachinePort=" + remoteTestingMachinePort + ", remoteTesting=" + remoteTesting
649                                 + ", cassandraHost=" + cassandraHost + ", cassandraAuditKeySpace=" + cassandraAuditKeySpace
650                                 + ", cassandraArtifactKeySpace=" + cassandraArtifactKeySpace + ", cassandraAuthenticate="
651                                 + cassandraAuthenticate + ", cassandraUsername=" + cassandraUsername + ", cassandraPassword="
652                                 + cassandraPassword + ", cassandraSsl=" + cassandraSsl + ", cassandraTruststorePath="
653                                 + cassandraTruststorePath + ", cassandraTruststorePassword=" + cassandraTruststorePassword
654                                 + ", windowsDownloadDirectory=" + windowsDownloadDirectory + ", captureTraffic=" + captureTraffic
655                                 + ", useBrowserMobProxy=" + useBrowserMobProxy + ", configurationFile=" + configurationFile + "]";
656         }
657
658         public boolean isRemoteTesting() {
659                 return remoteTesting;
660         }
661
662         public void setRemoteTesting(boolean remoteTesting) {
663                 this.remoteTesting = remoteTesting;
664         }
665
666         public String getUrl() {
667                 try {
668                         return url;
669                 } catch (Exception e) {
670                         return null;
671                 }
672         }
673
674         public void setUrl(String url) {
675                 this.url = url;
676         }
677
678         public String getRemoteTestingMachineIP() {
679                 return remoteTestingMachineIP;
680         }
681
682         public void setRemoteTestingMachineIP(String remoteTestingMachineIP) {
683                 this.remoteTestingMachineIP = remoteTestingMachineIP;
684         }
685
686         public String getRemoteTestingMachinePort() {
687                 return remoteTestingMachinePort;
688         }
689
690         public void setRemoteTestingMachinePort(String remoteTestingMachinePort) {
691                 this.remoteTestingMachinePort = remoteTestingMachinePort;
692         }
693
694         public boolean getCassandraAuthenticate() {
695                 return cassandraAuthenticate;
696         }
697
698         public void setCassandraAuthenticate(boolean cassandraAuthenticate) {
699                 this.cassandraAuthenticate = cassandraAuthenticate;
700         }
701
702         public String getCassandraUsername() {
703                 return cassandraUsername;
704         }
705
706         public void setCassandraUsername(String cassandraUsername) {
707                 this.cassandraUsername = cassandraUsername;
708         }
709
710         public String getCassandraPassword() {
711                 return cassandraPassword;
712         }
713
714         public void setCassandraPassword(String cassandraPassword) {
715                 this.cassandraPassword = cassandraPassword;
716         }
717
718         public boolean getCassandraSsl() {
719                 return cassandraSsl;
720         }
721
722         public void setCassandraSsl(boolean cassandraSsl) {
723                 this.cassandraSsl = cassandraSsl;
724         }
725
726         public String getCassandraTruststorePath() {
727                 return cassandraTruststorePath;
728         }
729
730         public void setCassandraTruststorePath(String cassandraTruststorePath) {
731                 this.cassandraTruststorePath = cassandraTruststorePath;
732         }
733
734         public String getCassandraTruststorePassword() {
735                 return cassandraTruststorePassword;
736         }
737
738         public void setCassandraTruststorePassword(String cassandraTruststorePassword) {
739                 this.cassandraTruststorePassword = cassandraTruststorePassword;
740         }
741
742 }