aboutsummaryrefslogtreecommitdiffstats
path: root/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java
blob: 82fdde4b8404fc7d535978898806feb50fb40e87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
/*-
 * ============LICENSE_START=======================================================
 * SDC
 * ================================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.openecomp.sdc.ci.tests.config;

import org.yaml.snakeyaml.Yaml;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

public class Config {

	private static String WINDOWS_CONFIG_FILE = "src/main/resources/ci/conf/attsdc.yaml";
	private boolean systemUnderDebug;
	private boolean rerun;
	private String reportDBhost;
	private int reportDBport;
	
	private String browser;
	private String catalogBeHost;
	private String esHost;
	private String esPort;
	private String neoHost;
	private String neoPort;
	private String disributionClientHost;
	private String disributionClientPort;
	private boolean isDistributionClientRunning;


	private String errorConfigurationFile;
	private String resourceConfigDir;
	private String componentsConfigDir;
	private String importResourceConfigDir;
	private String importResourceTestsConfigDir;
	private String importTypesConfigDir;

	private String testSuites;

	private String catalogFeHost;
	private String catalogFePort;
	private String catalogBePort;
	private String catalogBeTlsPort;

	private String onboardingBeHost;
	private String onboardingBePort;

	private String neoDBusername;
	private String neoDBpassword;

	private String janusGraphPropertiesFile;
	private List<String> packages;
	private List<String> bugs;
	private List<String> resourcesNotToDelete;
	private List<String> resourceCategoriesNotToDelete;
	private List<String> serviceCategoriesNotToDelete;
	private boolean stopOnClassFailure = false;

	private String outputFolder;
	private String reportName;
	private String url;
	private String remoteTestingMachineIP;
	private String remoteTestingMachinePort;
	private boolean remoteTesting;

	private String cassandraHost;
	private String cassandraAuditKeySpace;
	private String cassandraArtifactKeySpace;
	private boolean cassandraAuthenticate;
	private String cassandraUsername;
	private String cassandraPassword;
	private boolean cassandraSsl;
	private String cassandraTruststorePath;
	private String cassandraTruststorePassword;
	private String windowsDownloadDirectory;
	private boolean captureTraffic;
	private boolean useBrowserMobProxy;
	private String sdcHttpMethod;
	private String localDataCenter;
	private boolean uiSimulator;

	public String getLocalDataCenter() {
		return localDataCenter;
	}

	public void setLocalDataCenter(String localDataCenter) {
		this.localDataCenter = localDataCenter;
	}

	private static Config configIt = null;

	private static Yaml yaml = new Yaml();

	
	private Config() {
		super();
	}

	public String getOnboardingBePort() {
		return onboardingBePort;
	}

	public void setOnboardingBePort(String onboardingBePort) {
		this.onboardingBePort = onboardingBePort;
	}

	public String getOnboardingBeHost() {
		return onboardingBeHost;
	}

	public void setOnboardingBeHost(String onboardingBeHost) {
		this.onboardingBeHost = onboardingBeHost;
	}

	public static class TestPackages {

		List<String> packages;
		List<String> bugs;

		public List<String> getPackages() {
			return packages;
		}

		public void setPackages(List<String> packages) {
			this.packages = packages;
		}

		public List<String> getBugs() {
			return bugs;
		}

		public void setBugs(List<String> bugs) {
			this.bugs = bugs;
		}

		@Override
		public String toString() {
			return "TestPackages [packages=" + packages + ", bugs=" + bugs + "]";
		}

	}

	public synchronized static Config instance() {
		if (configIt == null) {
			try {
				configIt = init();
			} catch (IOException e) {
				e.printStackTrace();
				return null;
			}
		}
		return configIt;
	}

	private static Config init() throws IOException {

		Config config = null;

		String configFile = System.getProperty("config.resource");
		if (configFile == null) {
			configFile = WINDOWS_CONFIG_FILE;
		}

		File file = new File(configFile);
		if (false == file.exists()) {
			throw new RuntimeException("The config file " + configFile + " cannot be found.");
		}

		InputStream in = null;
		try {

			in = Files.newInputStream(Paths.get(configFile));

			config = yaml.loadAs(in, Config.class);

			setPackagesAndBugs(configFile, config);

		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}

		// JsonReader jsonReader = new JsonReader(new FileReader(configFile));
		// Config configAttOdlIt = new Gson().fromJson(jsonReader,
		// Config.class);

		return config;
	}

	public boolean isUiSimulator() {
		return uiSimulator;
	}

	public void setUiSimulator(boolean uiSimulator) {
		this.uiSimulator = uiSimulator;
	}

	private static void setPackagesAndBugs(String path, Config config) throws IOException {

		int separator = Math.max(path.lastIndexOf("\\"), path.lastIndexOf("/"));
		String dirPath = path.substring(0, separator + 1);
		String packagesFile = dirPath + File.separator + "attsdc-packages.yaml";
		File file = new File(packagesFile);
		if (false == file.exists()) {
			throw new RuntimeException("The config file " + packagesFile + " cannot be found.");
		}

		TestPackages testPackages = null;
		InputStream in = null;
		try {

			in = Files.newInputStream(Paths.get(packagesFile));

			testPackages = yaml.loadAs(in, TestPackages.class);

			List<String> bugs = testPackages.getBugs();
			List<String> packages = testPackages.getPackages();

			config.setBugs(bugs);
			config.setPackages(packages);

		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}

	}

	// public Config(String catalogBeHost, String esHost, String esPort, String
	// resourceConfigDir, String componentsConfigDir, String catalogFeHost,
	// String catalogFePort, String catalogBePort) {
	// super();
	// this.catalogBeHost = catalogBeHost;
	// this.esHost = esHost;
	// this.esPort = esPort;
	// this.resourceConfigDir = resourceConfigDir;
	// this.componentsConfigDir = componentsConfigDir;
	// this.catalogFeHost = catalogFeHost;
	// this.catalogFePort = catalogFePort;
	// this.catalogBePort = catalogBePort;
	// }

	String configurationFile;
	
	public boolean getSystemUnderDebug() {
		return systemUnderDebug;
	}

	public void setSystemUnderDebug(boolean systemUnderDebug) {
		this.systemUnderDebug = systemUnderDebug;
	}

	public String getSdcHttpMethod() {
		return sdcHttpMethod;
	}

	public void setSdcHttpMethod(String sdcHttpMethod) {
		this.sdcHttpMethod = sdcHttpMethod;
	}

	public boolean getRerun() {
		return rerun;
	}

	public void setRerun(boolean rerun) {
		this.rerun = rerun;
	}
	
	public String getReportDBhost() {
		return reportDBhost;
	}

	public void setReportDBhost(String reportDBhost) {
		this.reportDBhost = reportDBhost;
	}

	public int getReportDBport() {
		return reportDBport;
	}

	public void setReportDBport(int reportDBport) {
		this.reportDBport = reportDBport;
	}
//	public boolean isUsingBrowserMobProxy() {
//		return useBrowserMobProxy;
//	}
//
//	public void setUsingBrowserMobProxy(boolean usingBrowserMobProxy) {
//		this.useBrowserMobProxy = usingBrowserMobProxy;
//	} 

	
	
	
	public String getBrowser() {
		return browser;
	}
	
	public boolean getUseBrowserMobProxy() {
		return useBrowserMobProxy;
	}

	public void setUseBrowserMobProxy(boolean useBrowserMobProxy) {
		this.useBrowserMobProxy = useBrowserMobProxy;
	}



	public boolean getCaptureTraffic() {
		return captureTraffic;
	}

	public void setCaptureTraffic(boolean captureTraffic) {
		this.captureTraffic = captureTraffic;
	}

	public void setBrowser(String browser) {
		this.browser = browser;
	}

	public String getConfigurationFile() {
		return configurationFile;
	}

	public void setConfigurationFile(String configurationFile) {
		this.configurationFile = configurationFile;
	}

	public boolean getIsDistributionClientRunning() {
		return isDistributionClientRunning;
	}

	public void setIsDistributionClientRunning(boolean isDistributionClientRunning) {
		this.isDistributionClientRunning = isDistributionClientRunning;
	}
	
	public String getCatalogBePort() {
		return catalogBePort;
	}

	public String getDisributionClientHost() {
		return disributionClientHost;
	}

	public void setDisributionClientHost(String disributionClientHost) {
		this.disributionClientHost = disributionClientHost;
	}

	public String getDisributionClientPort() {
		return disributionClientPort;
	}

	public void setDisributionClientPort(String disributionClientPort) {
		this.disributionClientPort = disributionClientPort;
	}

	public void setCatalogBePort(String catalogBePort) {
		this.catalogBePort = catalogBePort;
	}

	public String getCatalogFeHost() {
		return catalogFeHost;
	}

	public void setCatalogFeHost(String catalogFeHost) {
		this.catalogFeHost = catalogFeHost;
	}

	public String getCatalogFePort() {
		return catalogFePort;
	}

	public void setCatalogFePort(String catalogFePort) {
		this.catalogFePort = catalogFePort;
	}

	public String getCatalogBeHost() {
		return catalogBeHost;
	}

	public void setCatalogBeHost(String catalogBeHost) {
		this.catalogBeHost = catalogBeHost;
	}

	public String getEsHost() {
		return esHost;
	}

	public void setEsHost(String esHost) {
		this.esHost = esHost;
	}

	public String getEsPort() {
		return esPort;
	}

	public void setEsPort(String esPort) {
		this.esPort = esPort;
	}

	public String getResourceConfigDir() {
		return resourceConfigDir;
	}

	public void setResourceConfigDir(String resourceConfigDir) {
		this.resourceConfigDir = resourceConfigDir;
	}

	public String getComponentsConfigDir() {
		return componentsConfigDir;
	}

	public void setComponentsConfigDir(String componentsConfigDir) {
		this.componentsConfigDir = componentsConfigDir;
	}

	public String getOutputFolder() {
		return outputFolder;
	}

	public void setOutputFolder(String outputFolder) {
		this.outputFolder = outputFolder;
	}

	public String getReportName() {
		return reportName;
	}

	public void setReportName(String reportName) {
		this.reportName = reportName;
	}

	public String getNeoPort() {
		return neoPort;
	}

	public void setNeoPort(String neoPort) {
		this.neoPort = neoPort;
	}

	public String getNeoHost() {
		return neoHost;
	}

	public void setNeoHost(String neoHost) {
		this.neoHost = neoHost;
	}

	public String getNeoDBpassword() {
		return neoDBpassword;
	}

	public String getNeoDBusername() {
		return neoDBusername;
	}

	public void setNeoDBusername(String neoDBusername) {
		this.neoDBusername = neoDBusername;
	}

	public void setNeoDBpassword(String neoDBpassword) {
		this.neoDBpassword = neoDBpassword;
	}

	public String getjanusGraphPropertiesFile() {
		return janusGraphPropertiesFile;
	}

	public void setjanusGraphPropertiesFile(String janusGraphPropertiesFile) {
		this.janusGraphPropertiesFile = janusGraphPropertiesFile;
	}

	public List<String> getPackages() {
		return packages;
	}

	public void setPackages(List<String> packages) {
		this.packages = packages;
	}

	public List<String> getBugs() {
		return bugs;
	}

	public void setBugs(List<String> bugs) {
		this.bugs = bugs;
	}

	public boolean isStopOnClassFailure() {
		return stopOnClassFailure;
	}

	public void setStopOnClassFailure(boolean stopOnClassFailure) {
		this.stopOnClassFailure = stopOnClassFailure;
	}

	public String getImportResourceConfigDir() {
		return importResourceConfigDir;
	}

	public void setImportResourceConfigDir(String importResourceConfigDir) {
		this.importResourceConfigDir = importResourceConfigDir;
	}

	public String getImportResourceTestsConfigDir() {
		return importResourceTestsConfigDir;
	}

	public void setImportResourceTestsConfigDir(String importResourceTestsConfigDir) {
		this.importResourceTestsConfigDir = importResourceTestsConfigDir;
	}

	public String getErrorConfigurationFile() {
		return errorConfigurationFile;
	}

	public void setErrorConfigurationFile(String errorConfigurationFile) {
		this.errorConfigurationFile = errorConfigurationFile;
	}

	public String getCatalogBeTlsPort() {
		return catalogBeTlsPort;
	}

	public void setCatalogBeTlsPort(String catalogBeTlsPort) {
		this.catalogBeTlsPort = catalogBeTlsPort;
	}

	public List<String> getResourcesNotToDelete() {
		return resourcesNotToDelete;
	}

	public void setResourcesNotToDelete(List<String> resourcesNotToDelete) {
		this.resourcesNotToDelete = resourcesNotToDelete;
	}

	public List<String> getResourceCategoriesNotToDelete() {
		return resourceCategoriesNotToDelete;
	}

	public void setResourceCategoriesNotToDelete(List<String> resourceCategoriesNotToDelete) {
		this.resourceCategoriesNotToDelete = resourceCategoriesNotToDelete;
	}

	public List<String> getServiceCategoriesNotToDelete() {
		return serviceCategoriesNotToDelete;
	}

	public void setServiceCategoriesNotToDelete(List<String> serviceCategoriesNotToDelete) {
		this.serviceCategoriesNotToDelete = serviceCategoriesNotToDelete;
	}

	public String getImportTypesConfigDir() {
		return importTypesConfigDir;
	}

	public void setImportTypesConfigDir(String importTypesConfigDir) {
		this.importTypesConfigDir = importTypesConfigDir;
	}

	public String getCassandraHost() {
		return cassandraHost;
	}

	public void setCassandraHost(String cassandraHost) {
		this.cassandraHost = cassandraHost;
	}

	public String getCassandraAuditKeySpace() {
		return cassandraAuditKeySpace;
	}

	public void setCassandraAuditKeySpace(String cassandraAuditKeySpace) {
		this.cassandraAuditKeySpace = cassandraAuditKeySpace;
	}

	public String getCassandraArtifactKeySpace() {
		return cassandraArtifactKeySpace;
	}

	public void setCassandraArtifactKeySpace(String cassandraArtifactKeySpace) {
		this.cassandraArtifactKeySpace = cassandraArtifactKeySpace;
	}

	
	public String getWindowsDownloadDirectory() {
		return windowsDownloadDirectory;
	}
	
	public void setWindowsDownloadDirectory(String windowsDownloadDirectory) {
		this.windowsDownloadDirectory = windowsDownloadDirectory;
	}
	
	@Override
	public String toString() {
		return "Config [systemUnderDebug=" + systemUnderDebug + ", rerun=" + rerun + ", reportDBhost=" + reportDBhost
				+ ", reportDBport=" + reportDBport + ", browser=" + browser + ", catalogBeHost=" + catalogBeHost
				+ ", esHost=" + esHost + ", esPort=" + esPort + ", neoHost=" + neoHost + ", neoPort=" + neoPort
				+ ", disributionClientHost=" + disributionClientHost + ", disributionClientPort="
				+ disributionClientPort + ", isDistributionClientRunning=" + isDistributionClientRunning
				+ ", errorConfigurationFile=" + errorConfigurationFile + ", resourceConfigDir=" + resourceConfigDir
				+ ", componentsConfigDir=" + componentsConfigDir + ", importResourceConfigDir="
				+ importResourceConfigDir + ", importResourceTestsConfigDir=" + importResourceTestsConfigDir
				+ ", importTypesConfigDir=" + importTypesConfigDir + ", testSuites=" + testSuites + ", catalogFeHost="
				+ catalogFeHost + ", catalogFePort=" + catalogFePort + ", catalogBePort=" + catalogBePort
				+ ", catalogBeTlsPort=" + catalogBeTlsPort + ", neoDBusername=" + neoDBusername + ", neoDBpassword="
				+ neoDBpassword + ", janusGraphPropertiesFile=" + janusGraphPropertiesFile + ", packages=" + packages + ", bugs="
				+ bugs + ", resourcesNotToDelete=" + resourcesNotToDelete + ", resourceCategoriesNotToDelete="
				+ resourceCategoriesNotToDelete + ", serviceCategoriesNotToDelete=" + serviceCategoriesNotToDelete
				+ ", stopOnClassFailure=" + stopOnClassFailure + ", outputFolder=" + outputFolder + ", reportName="
				+ reportName + ", url=" + url + ", remoteTestingMachineIP=" + remoteTestingMachineIP
				+ ", remoteTestingMachinePort=" + remoteTestingMachinePort + ", remoteTesting=" + remoteTesting
				+ ", cassandraHost=" + cassandraHost + ", cassandraAuditKeySpace=" + cassandraAuditKeySpace
				+ ", cassandraArtifactKeySpace=" + cassandraArtifactKeySpace + ", cassandraAuthenticate="
				+ cassandraAuthenticate + ", cassandraUsername=" + cassandraUsername + ", cassandraPassword="
				+ cassandraPassword + ", cassandraSsl=" + cassandraSsl + ", cassandraTruststorePath="
				+ cassandraTruststorePath + ", cassandraTruststorePassword=" + cassandraTruststorePassword
				+ ", windowsDownloadDirectory=" + windowsDownloadDirectory + ", captureTraffic=" + captureTraffic
				+ ", useBrowserMobProxy=" + useBrowserMobProxy + ", configurationFile=" + configurationFile + "]";
	}

	public boolean isRemoteTesting() {
		return remoteTesting;
	}

	public void setRemoteTesting(boolean remoteTesting) {
		this.remoteTesting = remoteTesting;
	}

	public String getUrl() {
		try {
			return url;
		} catch (Exception e) {
			return null;
		}
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getRemoteTestingMachineIP() {
		return remoteTestingMachineIP;
	}

	public void setRemoteTestingMachineIP(String remoteTestingMachineIP) {
		this.remoteTestingMachineIP = remoteTestingMachineIP;
	}

	public String getRemoteTestingMachinePort() {
		return remoteTestingMachinePort;
	}

	public void setRemoteTestingMachinePort(String remoteTestingMachinePort) {
		this.remoteTestingMachinePort = remoteTestingMachinePort;
	}

	public boolean getCassandraAuthenticate() {
		return cassandraAuthenticate;
	}

	public void setCassandraAuthenticate(boolean cassandraAuthenticate) {
		this.cassandraAuthenticate = cassandraAuthenticate;
	}

	public String getCassandraUsername() {
		return cassandraUsername;
	}

	public void setCassandraUsername(String cassandraUsername) {
		this.cassandraUsername = cassandraUsername;
	}

	public String getCassandraPassword() {
		return cassandraPassword;
	}

	public void setCassandraPassword(String cassandraPassword) {
		this.cassandraPassword = cassandraPassword;
	}

	public boolean getCassandraSsl() {
		return cassandraSsl;
	}

	public void setCassandraSsl(boolean cassandraSsl) {
		this.cassandraSsl = cassandraSsl;
	}

	public String getCassandraTruststorePath() {
		return cassandraTruststorePath;
	}

	public void setCassandraTruststorePath(String cassandraTruststorePath) {
		this.cassandraTruststorePath = cassandraTruststorePath;
	}

	public String getCassandraTruststorePassword() {
		return cassandraTruststorePassword;
	}

	public void setCassandraTruststorePassword(String cassandraTruststorePassword) {
		this.cassandraTruststorePassword = cassandraTruststorePassword;
	}

}