From 8c0a68916f5b0b590aedf71bec4a34320c26871e Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Mon, 12 Feb 2018 09:43:09 +0000 Subject: [PATCH 01/82] header and very basic json schema --- ui-src/src/app/app.component.html | 1 + ui-src/src/app/app.module.ts | 4 +- .../app/test-cases/test-cases.component.css | 1 - .../app/test-suites/test-suites.component.css | 5 ++ .../test-suites/test-suites.component.html | 24 ++++++- .../app/test-suites/test-suites.component.ts | 25 ++++++- ui-src/tslint.json | 70 +++++++++++++++---- 7 files changed, 112 insertions(+), 18 deletions(-) diff --git a/ui-src/src/app/app.component.html b/ui-src/src/app/app.component.html index e9dfcd9..72f7448 100644 --- a/ui-src/src/app/app.component.html +++ b/ui-src/src/app/app.component.html @@ -12,4 +12,5 @@

Automated Performance Testing

+ \ No newline at end of file diff --git a/ui-src/src/app/app.module.ts b/ui-src/src/app/app.module.ts index 4b06c8c..6444aae 100644 --- a/ui-src/src/app/app.module.ts +++ b/ui-src/src/app/app.module.ts @@ -13,7 +13,7 @@ import { ToastModule } from "ng2-toastr/ng2-toastr"; import { AutomatedUIServices } from "./automated-ui-services"; import { HttpClientModule, HttpClient } from "@angular/common/http"; import { FormsModule } from "@angular/forms"; -import { HttpModule } from '@angular/http'; +import { HttpModule } from '@angular/http'; @NgModule({ declarations: [ @@ -38,4 +38,4 @@ import { HttpModule } from '@angular/http'; providers: [AutomatedUIServices], bootstrap: [AppComponent] }) -export class AppModule {} +export class AppModule { } diff --git a/ui-src/src/app/test-cases/test-cases.component.css b/ui-src/src/app/test-cases/test-cases.component.css index 8b13789..e69de29 100644 --- a/ui-src/src/app/test-cases/test-cases.component.css +++ b/ui-src/src/app/test-cases/test-cases.component.css @@ -1 +0,0 @@ - diff --git a/ui-src/src/app/test-suites/test-suites.component.css b/ui-src/src/app/test-suites/test-suites.component.css index e69de29..1a19fd4 100644 --- a/ui-src/src/app/test-suites/test-suites.component.css +++ b/ui-src/src/app/test-suites/test-suites.component.css @@ -0,0 +1,5 @@ +.row { + margin-top: 25px; + margin-bottom: 25px; + } + \ No newline at end of file diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index 8f39c17..bd940a7 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -1 +1,23 @@ -

test-suite works

\ No newline at end of file +
+
+ + +
+
+ + +
+ +
+
+ +
+
+ + + + +
+ +
+
\ No newline at end of file diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index 5e5db2f..c7a9434 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -5,4 +5,27 @@ import { Component, OnInit } from "@angular/core"; templateUrl: "./test-suites.component.html", styleUrls: ["./test-suites.component.css"] }) -export class TestSuitesComponent {} +export class TestSuitesComponent { + + testSchema = { + type: "object", + properties: { + name: { type: "string" }, + testStrategy: { type: "string" }, + description: { type: "string" } + + }, + layout: [ + { + + submit: "hidden" + } + ], + } + + onAdd() { } + onDelete() { } + onCancel() { } + onSave() { } + +} diff --git a/ui-src/tslint.json b/ui-src/tslint.json index 09f179b..2517c6a 100644 --- a/ui-src/tslint.json +++ b/ui-src/tslint.json @@ -1,22 +1,37 @@ { - "rulesDirectory": ["node_modules/codelyzer"], + "rulesDirectory": [ + "node_modules/codelyzer" + ], "rules": { "arrow-return-shorthand": true, "callable-types": true, "class-name": true, - "comment-format": [true, "check-space"], + "comment-format": [ + true, + "check-space" + ], "curly": true, "deprecation": { "severity": "warn" }, "eofline": true, "forin": true, - "import-blacklist": [true, "rxjs", "rxjs/Rx"], + "import-blacklist": [ + true, + "rxjs", + "rxjs/Rx" + ], "import-spacing": true, - "indent": [true, "spaces"], + "indent": [ + true, + "spaces" + ], "interface-over-type-literal": true, "label-position": true, - "max-line-length": [true, 140], + "max-line-length": [ + true, + 140 + ], "member-access": false, "member-ordering": [ true, @@ -31,14 +46,24 @@ ], "no-arg": true, "no-bitwise": true, - "no-console": [true, "debug", "info", "time", "timeEnd", "trace"], + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], "no-construct": true, "no-debugger": true, "no-duplicate-super": true, "no-empty": false, "no-empty-interface": true, "no-eval": true, - "no-inferrable-types": [true, "ignore-params"], + "no-inferrable-types": [ + true, + "ignore-params" + ], "no-misused-new": true, "no-non-null-assertion": true, "no-shadowed-variable": true, @@ -59,10 +84,19 @@ "check-whitespace" ], "prefer-const": true, - "quotemark": [true, "double"], + "quotemark": [ + true, + "double" + ], "radix": true, - "semicolon": [true, "always"], - "triple-equals": [true, "allow-null-check"], + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], "typedef-whitespace": [ true, { @@ -84,8 +118,18 @@ "check-separator", "check-type" ], - "directive-selector": [true, "attribute", "app", "camelCase"], - "component-selector": [true, "element", "app", "kebab-case"], + "directive-selector": [ + true, + "attribute", + "app", + "camelCase" + ], + "component-selector": [ + true, + "element", + "app", + "kebab-case" + ], "no-output-on-prefix": true, "use-input-property-decorator": true, "use-output-property-decorator": true, @@ -97,4 +141,4 @@ "component-class-suffix": true, "directive-class-suffix": true } -} +} \ No newline at end of file From ed564889252b8193fce9dcb19c315081c692d763 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Tue, 13 Feb 2018 10:14:45 +0000 Subject: [PATCH 02/82] added basic table --- .../configurations.component.html | 23 +++-- .../app/test-suites/test-suites.component.css | 31 ++++++- .../test-suites/test-suites.component.html | 72 ++++++++++++-- .../app/test-suites/test-suites.component.ts | 8 +- ui-src/src/assets/schema.json | 93 ++++++++++++++----- 5 files changed, 178 insertions(+), 49 deletions(-) diff --git a/ui-src/src/app/configurations/configurations.component.html b/ui-src/src/app/configurations/configurations.component.html index 4a9cdf3..3715ac3 100644 --- a/ui-src/src/app/configurations/configurations.component.html +++ b/ui-src/src/app/configurations/configurations.component.html @@ -1,22 +1,21 @@
-
+
- - +
- - - - + +
- +
+ +
- + - - - + +
\ No newline at end of file diff --git a/ui-src/src/app/test-suites/test-suites.component.css b/ui-src/src/app/test-suites/test-suites.component.css index 1a19fd4..e24c250 100644 --- a/ui-src/src/app/test-suites/test-suites.component.css +++ b/ui-src/src/app/test-suites/test-suites.component.css @@ -2,4 +2,33 @@ margin-top: 25px; margin-bottom: 25px; } - \ No newline at end of file + + .column { + + padding: 0px; + } + + table { + + font-family: arial, sans-serif; + border-collapse: collapse; + width: 100%; + margin-bottom: 25px; + +} + +td, th { + border: 1px solid #dddddd; + text-align: left; + padding: 8px; +} + +tr:nth-child(even) { + background-color: #dddddd; +} + +.btn{ + margin-bottom: 25px; +} + + diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index bd940a7..e688215 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -3,21 +3,79 @@
-
- - -
+
-
+
+ + + + + + + + + + + + + + + + + + +
Name Description
-
+
+
+

Available

+ + + + + + + + + + + + + + + + +
Name DescriptionHttp Method
+
+
+

Selected

+ + + + + + + + + + + + + + + + + + + +
Name DescriptionHttp MethodOrder
+
-
\ No newline at end of file diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index c7a9434..72f9aff 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -14,13 +14,7 @@ export class TestSuitesComponent { testStrategy: { type: "string" }, description: { type: "string" } - }, - layout: [ - { - - submit: "hidden" - } - ], + } } onAdd() { } diff --git a/ui-src/src/assets/schema.json b/ui-src/src/assets/schema.json index 50ec856..6c62d58 100644 --- a/ui-src/src/assets/schema.json +++ b/ui-src/src/assets/schema.json @@ -19,16 +19,28 @@ "reportOutputDir" ], "properties": { - "apiName": { "type": "string" }, - "targetHost": { "type": "string" }, + "apiName": { + "type": "string" + }, + "targetHost": { + "type": "string" + }, "targetPort": { "type": "string", "minimum": 1, "maximum": 65535 }, - "memoryEndpoint": { "type": "string" }, - "numIterations": { "type": "integer", "minimum": 1 }, - "concurrentUsers": { "type": "integer", "minimum": 1 }, + "memoryEndpoint": { + "type": "string" + }, + "numIterations": { + "type": "integer", + "minimum": 1 + }, + "concurrentUsers": { + "type": "integer", + "minimum": 1 + }, "allowablePeakMemoryVariance": { "type": "number", "minimum": 0, @@ -41,18 +53,42 @@ }, "testSuite": { "type": "string", - "enum": ["Default-1", "Default-2", "Default-3"] - }, - "requestDelay": { "type": "integer", "minimum": 1 }, - "TPSFreq": { "type": "integer", "minimum": 1 }, - "rampUsers": { "type": "integer", "minimum": 1 }, - "rampDelay": { "type": "integer", "minimum": 0 }, - "testCaseDir": { "type": "string" }, - "testSuiteDir": { "type": "string" }, - "baseStatsOutputDir": { "type": "string" }, - "reportOutputDir": { "type": "string" } + "enum": [ + "Default-1", + "Default-2", + "Default-3" + ] + }, + "requestDelay": { + "type": "integer", + "minimum": 1 + }, + "TPSFreq": { + "type": "integer", + "minimum": 1 + }, + "rampUsers": { + "type": "integer", + "minimum": 1 + }, + "rampDelay": { + "type": "integer", + "minimum": 0 + }, + "testCaseDir": { + "type": "string" + }, + "testSuiteDir": { + "type": "string" + }, + "baseStatsOutputDir": { + "type": "string" + }, + "reportOutputDir": { + "type": "string" + } }, - "layout" : [ + "layout": [ { "type": "flex", "flex-flow": "row wrap", @@ -104,11 +140,24 @@ } ] }, - { "key": "testSuite" }, - { "key": "testCaseDir", "title": "Test Case Directory" }, - { "key": "testSuiteDir", "title": "Test Suites Directory" }, - { "key": "baseStatsOutputDir", "title": "Base Stats Output Directory" }, - { "key": "reportOutputDir", "title": "Report Output Directory" } - + { + "key": "testSuite" + }, + { + "key": "testCaseDir", + "title": "Test Case Directory" + }, + { + "key": "testSuiteDir", + "title": "Test Suites Directory" + }, + { + "key": "baseStatsOutputDir", + "title": "Base Stats Output Directory" + }, + { + "key": "reportOutputDir", + "title": "Report Output Directory" + } ] } \ No newline at end of file From 1f74b77a3f2edf41221608eda6de027ae712d77e Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Wed, 14 Feb 2018 10:17:42 +0000 Subject: [PATCH 03/82] post service working in test suite --- ui-src/src/app/automated-ui-services.ts | 13 +++++- .../app/test-suites/test-suites.component.css | 3 ++ .../test-suites/test-suites.component.html | 6 ++- .../app/test-suites/test-suites.component.ts | 45 +++++++++++++++++-- 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/ui-src/src/app/automated-ui-services.ts b/ui-src/src/app/automated-ui-services.ts index 8cadf9e..fda6cd4 100644 --- a/ui-src/src/app/automated-ui-services.ts +++ b/ui-src/src/app/automated-ui-services.ts @@ -7,6 +7,7 @@ import { Headers } from "@angular/http/src/headers"; import { Observable } from "rxjs/Observable"; import { environment } from "../environments/environment.prod"; import { $ } from "protractor"; +import { TestSuitesComponent } from "./test-suites/test-suites.component"; @Injectable() export class AutomatedUIServices { @@ -24,7 +25,7 @@ export class AutomatedUIServices { } getConfig$(configPath, xmlFileName): Observable { - this.headers = this.headers.set("configPathDir", configPath); + this.headers = this.headers.set("configPathDir", configPath); return this.http.get(`${environment.apiBaseUrl}configs/${xmlFileName}`, { headers: this.headers }); @@ -42,4 +43,14 @@ export class AutomatedUIServices { .get(`${environment.apiBaseUrl}${location}`, { headers: this.headers }) .map((data: any) => data); } + + + postTestSuite$(testSuiteData, testSuitePath): Observable { + this.headers = this.headers.set("testSuitePathDir", testSuitePath); + return this.http.post(`${environment.apiBaseUrl}test-suites`, testSuiteData, { + headers: this.headers + }); + + + } } diff --git a/ui-src/src/app/test-suites/test-suites.component.css b/ui-src/src/app/test-suites/test-suites.component.css index e24c250..e303dd4 100644 --- a/ui-src/src/app/test-suites/test-suites.component.css +++ b/ui-src/src/app/test-suites/test-suites.component.css @@ -32,3 +32,6 @@ tr:nth-child(even) { } + + + diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index e688215..00aa141 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -1,7 +1,7 @@
- +
@@ -29,13 +29,15 @@
- + +

Available

+ diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index 72f9aff..8f1d1f3 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from "@angular/core"; - +import { AutomatedUIServices } from "../automated-ui-services"; +import { ToastsManager } from "ng2-toastr/ng2-toastr"; @Component({ selector: "app-test-suites", templateUrl: "./test-suites.component.html", @@ -7,17 +8,55 @@ import { Component, OnInit } from "@angular/core"; }) export class TestSuitesComponent { + testSuitePath = undefined; + constructor( + private automatedUIServices: AutomatedUIServices, + private toastr: ToastsManager + ) { } testSchema = { type: "object", properties: { name: { type: "string" }, - testStrategy: { type: "string" }, + testStrategy: { + type: "string", + "enum": [ + "SuiteBased", + "ServiceBased" + ] + }, description: { type: "string" } } } - onAdd() { } + onSubmit(testSuiteData) { + this.automatedUIServices.postTestSuite$(testSuiteData, this.testSuitePath).subscribe( + data => { + this.toastr.success("Your data has been saved!", "Success!"); + }, + + error => { + switch (error.status) { + case 500: { + this.toastr.error("An error has occurred!", "Check the logs!"); + break; + } + case 400: { + this.toastr.error( + "Some of the fields do not conform to the schema!", + "An error occurred!" + ); + break; + } + default: { + this.toastr.error("Your data did not save!", "An error occurred!"); + } + } + } + ); + } + + onDelete() { } onCancel() { } onSave() { } From 84059edac5719744d8b72d2a3923851d9cf9a974 Mon Sep 17 00:00:00 2001 From: a586754 Date: Wed, 14 Feb 2018 15:04:08 +0000 Subject: [PATCH 04/82] Upadated buttons and inputs --- ui-src/src/app/configurations/configurations.component.css | 6 +++++- ui-src/src/app/configurations/configurations.component.html | 6 ++++-- ui-src/src/app/configurations/configurations.component.ts | 4 ++++ ui-src/src/app/test-suites/test-suites.component.ts | 2 +- ui-src/src/assets/schema.json | 5 +++++ ui-src/src/styles.css | 2 +- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ui-src/src/app/configurations/configurations.component.css b/ui-src/src/app/configurations/configurations.component.css index e293af1..fcd795d 100644 --- a/ui-src/src/app/configurations/configurations.component.css +++ b/ui-src/src/app/configurations/configurations.component.css @@ -43,4 +43,8 @@ filter: alpha(opacity=65); box-shadow: none; opacity: .65; -} \ No newline at end of file +} +submit-widget +{ + display: none; +} diff --git a/ui-src/src/app/configurations/configurations.component.html b/ui-src/src/app/configurations/configurations.component.html index 3715ac3..d9a1c21 100644 --- a/ui-src/src/app/configurations/configurations.component.html +++ b/ui-src/src/app/configurations/configurations.component.html @@ -6,7 +6,7 @@
- +
@@ -16,6 +16,8 @@
- + + + \ No newline at end of file diff --git a/ui-src/src/app/configurations/configurations.component.ts b/ui-src/src/app/configurations/configurations.component.ts index cc8ad23..b8e88c3 100644 --- a/ui-src/src/app/configurations/configurations.component.ts +++ b/ui-src/src/app/configurations/configurations.component.ts @@ -31,6 +31,8 @@ export class ConfigurationsComponent implements OnInit { .subscribe((data: any) => { this.configSchema = data; }); + + } onSubmit(configData) { @@ -84,7 +86,9 @@ export class ConfigurationsComponent implements OnInit { this.fileName = event.srcElement.files[0].name; this.xmlFileName = this.fileName; this.onGetFile(); + } + onGetFile() { this.automatedUIServices .getConfig$(this.configPath, this.xmlFileName) diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index 8f1d1f3..311d7a0 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -60,5 +60,5 @@ export class TestSuitesComponent { onDelete() { } onCancel() { } onSave() { } - + onAdd(){} } diff --git a/ui-src/src/assets/schema.json b/ui-src/src/assets/schema.json index 6c62d58..f81ec51 100644 --- a/ui-src/src/assets/schema.json +++ b/ui-src/src/assets/schema.json @@ -158,6 +158,11 @@ { "key": "reportOutputDir", "title": "Report Output Directory" + }, + { + "type":"submit", + "title":"Create", + "_id":"test" } ] } \ No newline at end of file diff --git a/ui-src/src/styles.css b/ui-src/src/styles.css index c48ea96..60ab016 100644 --- a/ui-src/src/styles.css +++ b/ui-src/src/styles.css @@ -3,7 +3,7 @@ @import '~https://fonts.googleapis.com/css?family=Roboto:300,400,500,700'; @import '~https://fonts.googleapis.com/icon?family=Material+Icons'; @import "~@angular/material/prebuilt-themes/indigo-pink.css"; - +@import './app/configurations/configurations.component.css'; body { From 291bfe842efec3c4cdfa5216445582f740e315f7 Mon Sep 17 00:00:00 2001 From: a586754 Date: Wed, 14 Feb 2018 16:25:47 +0000 Subject: [PATCH 05/82] Upadated create and updated buttons --- .../configurations.component.css | 3 +++ .../configurations.component.html | 18 ++++++++++-------- .../configurations/configurations.component.ts | 5 +++++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ui-src/src/app/configurations/configurations.component.css b/ui-src/src/app/configurations/configurations.component.css index fcd795d..2329f81 100644 --- a/ui-src/src/app/configurations/configurations.component.css +++ b/ui-src/src/app/configurations/configurations.component.css @@ -2,6 +2,9 @@ margin-top: 25px; margin-bottom: 25px; } +.row2 { + margin-top: 25px; +} .btn-secondary { color: #fff; diff --git a/ui-src/src/app/configurations/configurations.component.html b/ui-src/src/app/configurations/configurations.component.html index d9a1c21..9a64459 100644 --- a/ui-src/src/app/configurations/configurations.component.html +++ b/ui-src/src/app/configurations/configurations.component.html @@ -2,17 +2,19 @@
- + +
-
- - +
+ +
- -
- +
+ +
+
diff --git a/ui-src/src/app/configurations/configurations.component.ts b/ui-src/src/app/configurations/configurations.component.ts index b8e88c3..491ae4e 100644 --- a/ui-src/src/app/configurations/configurations.component.ts +++ b/ui-src/src/app/configurations/configurations.component.ts @@ -85,9 +85,14 @@ export class ConfigurationsComponent implements OnInit { fileSelector(event) { this.fileName = event.srcElement.files[0].name; this.xmlFileName = this.fileName; + this.xmlFileName = this.xmlFileName.substring(0,this.xmlFileName.length - 4); this.onGetFile(); } + + onClearFile(event){ + this.xmlFileName = undefined; + } onGetFile() { this.automatedUIServices From 2a6bef1b3daa1828928e3849e761760b6dc906e7 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Thu, 15 Feb 2018 09:59:12 +0000 Subject: [PATCH 06/82] started get and put services --- ui-src/src/app/automated-ui-services.ts | 14 ++++++++ .../app/test-suites/test-suites.component.css | 2 -- .../test-suites/test-suites.component.html | 12 ++----- .../app/test-suites/test-suites.component.ts | 35 +++++++++++++++---- 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/ui-src/src/app/automated-ui-services.ts b/ui-src/src/app/automated-ui-services.ts index fda6cd4..9c2be47 100644 --- a/ui-src/src/app/automated-ui-services.ts +++ b/ui-src/src/app/automated-ui-services.ts @@ -50,7 +50,21 @@ export class AutomatedUIServices { return this.http.post(`${environment.apiBaseUrl}test-suites`, testSuiteData, { headers: this.headers }); + } + getTestSuite$(testSuitePath, testSuiteFileName): Observable { + this.headers = this.headers.set("testSuitePathDir", testSuitePath); + return this.http.get(`${environment.apiBaseUrl}test-suites/${testSuiteFileName}`, { + headers: this.headers + }); + } + putTestSuite$(testSuiteData, testSuitePath, testSuiteFileName): Observable { + this.headers = this.headers.set("testSuitePathDir", testSuitePath); + return this.http.put( + `${environment.apiBaseUrl}test-suites/${testSuiteFileName}`, + testSuiteData, + { headers: this.headers } + ); } } diff --git a/ui-src/src/app/test-suites/test-suites.component.css b/ui-src/src/app/test-suites/test-suites.component.css index e303dd4..6e3b287 100644 --- a/ui-src/src/app/test-suites/test-suites.component.css +++ b/ui-src/src/app/test-suites/test-suites.component.css @@ -33,5 +33,3 @@ tr:nth-child(even) { - - diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index 00aa141..e85c385 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -14,22 +14,16 @@
- - - - - -
Name Description Http Method
Name Description
- +
@@ -37,7 +31,6 @@

Available

- @@ -74,10 +67,11 @@

Selected

+
Name Description Http Method
- +
\ No newline at end of file diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index 8f1d1f3..4920026 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -7,8 +7,9 @@ import { ToastsManager } from "ng2-toastr/ng2-toastr"; styleUrls: ["./test-suites.component.css"] }) export class TestSuitesComponent { - + testSuiteData = {}; testSuitePath = undefined; + testSuiteFileName = undefined; constructor( private automatedUIServices: AutomatedUIServices, private toastr: ToastsManager @@ -29,7 +30,32 @@ export class TestSuitesComponent { } } - onSubmit(testSuiteData) { + onAdd() { + this.testSuiteData = undefined; + //clear schema and get all in available test cases from testSuitePath + + } + + onDelete() { + //need delete service + } + + onCancel() { + //clear schema and moving info back into available (get method) + this.automatedUIServices + .getConfig$(this.testSuitePath, this.testSuiteFileName) + .subscribe( + data => { + this.testSuiteData = data; + this.toastr.success("Previous data reloaded!"); + }, + error => { + this.testSuiteData = undefined; + } + ); + } + + onSave(testSuiteData) { this.automatedUIServices.postTestSuite$(testSuiteData, this.testSuitePath).subscribe( data => { this.toastr.success("Your data has been saved!", "Success!"); @@ -56,9 +82,4 @@ export class TestSuitesComponent { ); } - - onDelete() { } - onCancel() { } - onSave() { } - } From d8c709b8915893ac4cfde9dfc4cecf4d280bfd0c Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Thu, 15 Feb 2018 15:16:19 +0000 Subject: [PATCH 07/82] get all service and post service working for ui side --- ui-src/src/app/automated-ui-services.ts | 7 +++++ .../test-suites/test-suites.component.html | 20 +++---------- .../app/test-suites/test-suites.component.ts | 30 +++++++++++++++++-- uiServices/src/testSuiteServices.go | 1 + 4 files changed, 40 insertions(+), 18 deletions(-) diff --git a/ui-src/src/app/automated-ui-services.ts b/ui-src/src/app/automated-ui-services.ts index 9c2be47..63f4349 100644 --- a/ui-src/src/app/automated-ui-services.ts +++ b/ui-src/src/app/automated-ui-services.ts @@ -59,6 +59,13 @@ export class AutomatedUIServices { }); } + getAllTestSuite$(testSuitePath): Observable { + this.headers = this.headers.set("testSuitePathDir", testSuitePath); + return this.http.get(`${environment.apiBaseUrl}test-suites`, { + headers: this.headers + }); + } + putTestSuite$(testSuiteData, testSuitePath, testSuiteFileName): Observable { this.headers = this.headers.set("testSuitePathDir", testSuitePath); return this.http.put( diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index e85c385..50f6c19 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -15,11 +15,10 @@ Name Description - - - + + {{testSuite.name}} + {{testSuite.description}} -
@@ -39,13 +38,9 @@

Available

- - - - -
+

Selected

@@ -61,13 +56,6 @@

Selected

- - - - - - -
diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index 4920026..6046139 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -10,6 +10,7 @@ export class TestSuitesComponent { testSuiteData = {}; testSuitePath = undefined; testSuiteFileName = undefined; + constructor( private automatedUIServices: AutomatedUIServices, private toastr: ToastsManager @@ -31,9 +32,34 @@ export class TestSuitesComponent { } onAdd() { - this.testSuiteData = undefined; - //clear schema and get all in available test cases from testSuitePath + this.automatedUIServices + .getAllTestSuite$(this.testSuitePath) + .subscribe( + data => { + this.testSuiteData = data; + console.log(this.testSuiteData); + this.toastr.success("Your data has been saved!", "Success!"); + }, + error => { + switch (error.status) { + case 500: { + this.toastr.error("An error has occurred!", "Check the logs!"); + break; + } + case 400: { + this.toastr.error( + "No Test Suite Directory added", + "An error occurred!" + ); + break; + } + default: { + this.toastr.error("An error occurred!"); + } + } + } + ); } onDelete() { diff --git a/uiServices/src/testSuiteServices.go b/uiServices/src/testSuiteServices.go index 3218bb6..95c56f6 100644 --- a/uiServices/src/testSuiteServices.go +++ b/uiServices/src/testSuiteServices.go @@ -252,6 +252,7 @@ func getAllTestSuites(rw http.ResponseWriter, req *http.Request){ } json.NewEncoder(rw).Encode(suites) + logrus.Println(suites) rw.WriteHeader(http.StatusOK) } \ No newline at end of file From 43a151056cbde5c7ddaba9308e14b40778d41a6c Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Thu, 15 Feb 2018 15:37:08 +0000 Subject: [PATCH 08/82] removed submit button from test suite schema --- ui-src/src/app/test-suites/test-suites.component.css | 5 +++-- ui-src/src/app/test-suites/test-suites.component.ts | 5 +++-- ui-src/src/styles.css | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ui-src/src/app/test-suites/test-suites.component.css b/ui-src/src/app/test-suites/test-suites.component.css index 6e3b287..70b80f8 100644 --- a/ui-src/src/app/test-suites/test-suites.component.css +++ b/ui-src/src/app/test-suites/test-suites.component.css @@ -31,5 +31,6 @@ tr:nth-child(even) { margin-bottom: 25px; } - - +submit-widget{ + display : none; +} \ No newline at end of file diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index 6046139..0dc4084 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -26,7 +26,8 @@ export class TestSuitesComponent { "ServiceBased" ] }, - description: { type: "string" } + description: { type: "string" }, + options: { addSubmit: false } } } @@ -69,7 +70,7 @@ export class TestSuitesComponent { onCancel() { //clear schema and moving info back into available (get method) this.automatedUIServices - .getConfig$(this.testSuitePath, this.testSuiteFileName) + .getTestSuite$(this.testSuitePath, this.testSuiteFileName) .subscribe( data => { this.testSuiteData = data; diff --git a/ui-src/src/styles.css b/ui-src/src/styles.css index c48ea96..82cc266 100644 --- a/ui-src/src/styles.css +++ b/ui-src/src/styles.css @@ -3,7 +3,7 @@ @import '~https://fonts.googleapis.com/css?family=Roboto:300,400,500,700'; @import '~https://fonts.googleapis.com/icon?family=Material+Icons'; @import "~@angular/material/prebuilt-themes/indigo-pink.css"; - +@import "./app/test-suites/test-suites.component.css"; body { From 31001ecb19eff44fbd66532634ced81963ea4027 Mon Sep 17 00:00:00 2001 From: a586754 Date: Fri, 16 Feb 2018 10:14:49 +0000 Subject: [PATCH 09/82] -Page now using schema to generate UI -Updating Buttons and file selector --- .../configurations.component.css | 7 ++----- .../configurations.component.html | 8 +++---- .../configurations.component.ts | 6 ++++-- .../app/test-suites/test-suites.component.css | 5 +++++ .../test-suites/test-suites.component.html | 4 ++-- .../app/test-suites/test-suites.component.ts | 21 +++++++------------ ui-src/src/assets/schema.json | 6 +++--- ui-src/src/assets/testSuite_schema.json | 1 + ui-src/src/styles.css | 1 + 9 files changed, 30 insertions(+), 29 deletions(-) diff --git a/ui-src/src/app/configurations/configurations.component.css b/ui-src/src/app/configurations/configurations.component.css index 2329f81..dca1e79 100644 --- a/ui-src/src/app/configurations/configurations.component.css +++ b/ui-src/src/app/configurations/configurations.component.css @@ -23,7 +23,7 @@ display: inline-block; padding: 6px 12px; margin-bottom: 0; - margin-top: 25px; + margin-top: 0px; font-size: 14px; font-weight: 400; line-height: 1.42857143; @@ -47,7 +47,4 @@ box-shadow: none; opacity: .65; } -submit-widget -{ - display: none; -} + diff --git a/ui-src/src/app/configurations/configurations.component.html b/ui-src/src/app/configurations/configurations.component.html index 9a64459..f0db74e 100644 --- a/ui-src/src/app/configurations/configurations.component.html +++ b/ui-src/src/app/configurations/configurations.component.html @@ -6,12 +6,12 @@
- - Update Existing File +
-
- +
+
diff --git a/ui-src/src/app/configurations/configurations.component.ts b/ui-src/src/app/configurations/configurations.component.ts index 491ae4e..ae4812f 100644 --- a/ui-src/src/app/configurations/configurations.component.ts +++ b/ui-src/src/app/configurations/configurations.component.ts @@ -87,10 +87,12 @@ export class ConfigurationsComponent implements OnInit { this.xmlFileName = this.fileName; this.xmlFileName = this.xmlFileName.substring(0,this.xmlFileName.length - 4); this.onGetFile(); + (document.getElementById("file")).value =""; } - onClearFile(event){ + onClearFile(){ + (document.getElementById("file")).value =""; this.xmlFileName = undefined; } @@ -110,7 +112,7 @@ export class ConfigurationsComponent implements OnInit { } case 400: { this.toastr.error( - "Check your field inputs", + "Check your field inputs" , "An error occurred!" ); break; diff --git a/ui-src/src/app/test-suites/test-suites.component.css b/ui-src/src/app/test-suites/test-suites.component.css index e303dd4..49819ec 100644 --- a/ui-src/src/app/test-suites/test-suites.component.css +++ b/ui-src/src/app/test-suites/test-suites.component.css @@ -30,6 +30,11 @@ tr:nth-child(even) { .btn{ margin-bottom: 25px; } +fieldset{ + display: none; +} +/* label[class|= "control-label"] +{display: none} */ diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index 00aa141..771dfde 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -29,7 +29,7 @@
- +
@@ -40,7 +40,7 @@

Available

Description Http Method - + diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index 311d7a0..0cd4298 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -9,24 +9,19 @@ import { ToastsManager } from "ng2-toastr/ng2-toastr"; export class TestSuitesComponent { testSuitePath = undefined; + + testSuiteSchema = {layout: true}; constructor( private automatedUIServices: AutomatedUIServices, private toastr: ToastsManager ) { } - testSchema = { - type: "object", - properties: { - name: { type: "string" }, - testStrategy: { - type: "string", - "enum": [ - "SuiteBased", - "ServiceBased" - ] - }, - description: { type: "string" } - } + ngOnInit() { + this.automatedUIServices + .getSchema$("assets/testSuite_schema.json") + .subscribe((data: any) => { + this.testSuiteSchema = data; + }); } onSubmit(testSuiteData) { diff --git a/ui-src/src/assets/schema.json b/ui-src/src/assets/schema.json index f81ec51..31d2ff6 100644 --- a/ui-src/src/assets/schema.json +++ b/ui-src/src/assets/schema.json @@ -160,9 +160,9 @@ "title": "Report Output Directory" }, { - "type":"submit", - "title":"Create", - "_id":"test" + "options":{"addSubmit":false} } + + ] } \ No newline at end of file diff --git a/ui-src/src/assets/testSuite_schema.json b/ui-src/src/assets/testSuite_schema.json index e0e7f5c..4881689 100644 --- a/ui-src/src/assets/testSuite_schema.json +++ b/ui-src/src/assets/testSuite_schema.json @@ -38,6 +38,7 @@ "description": { "type": "string" } + } } } diff --git a/ui-src/src/styles.css b/ui-src/src/styles.css index 60ab016..e314a51 100644 --- a/ui-src/src/styles.css +++ b/ui-src/src/styles.css @@ -4,6 +4,7 @@ @import '~https://fonts.googleapis.com/icon?family=Material+Icons'; @import "~@angular/material/prebuilt-themes/indigo-pink.css"; @import './app/configurations/configurations.component.css'; +@import './app/test-suites/test-suites.component.css'; body { From b6b800a6b6691f471741aea27c64dd0141977395 Mon Sep 17 00:00:00 2001 From: a586754 Date: Fri, 16 Feb 2018 11:19:53 +0000 Subject: [PATCH 10/82] Merge conflicts --- ui-src/src/app/configurations/configurations.component.html | 4 ---- ui-src/src/app/test-suites/test-suites.component.html | 4 ---- 2 files changed, 8 deletions(-) diff --git a/ui-src/src/app/configurations/configurations.component.html b/ui-src/src/app/configurations/configurations.component.html index e8ef6b2..0a2da80 100644 --- a/ui-src/src/app/configurations/configurations.component.html +++ b/ui-src/src/app/configurations/configurations.component.html @@ -15,10 +15,6 @@
-
- -
diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index e5672fc..d14fc4b 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -22,11 +22,7 @@
-<<<<<<< HEAD -======= - ->>>>>>> 43a151056cbde5c7ddaba9308e14b40778d41a6c
From 0709af4acdee34699ed287f0bac7e323a85b6b5b Mon Sep 17 00:00:00 2001 From: a586754 Date: Fri, 16 Feb 2018 11:38:18 +0000 Subject: [PATCH 11/82] Deleting onSubmit --- ui-src/src/app/test-suites/test-suites.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index d14fc4b..2c7aea9 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -22,7 +22,7 @@
- +
From 2d4efec8f03190da48992712be9d7875b300b1d0 Mon Sep 17 00:00:00 2001 From: a586754 Date: Fri, 16 Feb 2018 14:02:31 +0000 Subject: [PATCH 12/82] Merge conflicts --- config/config.xml | 66 ++++++------------- .../configurations.component.html | 13 ++-- .../configurations.component.ts | 5 ++ .../test-suites/test-suites.component.html | 5 +- 4 files changed, 33 insertions(+), 56 deletions(-) diff --git a/config/config.xml b/config/config.xml index ceec919..5132eb8 100644 --- a/config/config.xml +++ b/config/config.xml @@ -1,47 +1,19 @@ - - - - config - - - localhost - 8080 - - - 15 - 15 - - - 1000 - - - 50 - - - ./definitions/testCases - - ./definitions/testSuites - - - Default-1 - - - ./envStats - ./report - - - /alt/debug/vars - - - 5000 - - - 30 - - - 5 - - - 15 - - \ No newline at end of file + + config + localhost + 8080 + 1000 + 15 + 5 + ./definitions/testCases + ./definitions/testSuites + ./envStats + ./report + 50 + Default-1 + /alt/debug/vars + 5000 + 30 + 5 + 15 + \ No newline at end of file diff --git a/ui-src/src/app/configurations/configurations.component.html b/ui-src/src/app/configurations/configurations.component.html index 0a2da80..23bc645 100644 --- a/ui-src/src/app/configurations/configurations.component.html +++ b/ui-src/src/app/configurations/configurations.component.html @@ -6,18 +6,19 @@
- - Update Existing File +
-
- +
+
- + - + +
\ No newline at end of file diff --git a/ui-src/src/app/configurations/configurations.component.ts b/ui-src/src/app/configurations/configurations.component.ts index 1041074..29c50a6 100644 --- a/ui-src/src/app/configurations/configurations.component.ts +++ b/ui-src/src/app/configurations/configurations.component.ts @@ -83,6 +83,11 @@ export class ConfigurationsComponent implements OnInit { fileSelector(event) { this.fileName = event.srcElement.files[0].name; this.xmlFileName = this.fileName; + this.xmlFileName = this.xmlFileName.substring( + 0, + this.xmlFileName.length - 4); + + this.onGetFile(); (document.getElementById("file")).value =""; diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index 2c7aea9..eefdcb8 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -22,9 +22,8 @@
- + -

Available

@@ -35,7 +34,7 @@

Available

- +
From 9d74ecc1d82e0cb35998f5c28ae075bf26f34364 Mon Sep 17 00:00:00 2001 From: a586754 Date: Mon, 19 Feb 2018 13:37:56 +0000 Subject: [PATCH 13/82] Update protractor tests --- config/config.xml | 6 +++--- .../configurationComponent.e2e-spec.ts | 20 +++++++------------ ui-src/e2e/pages/configuration-PO.ts | 8 ++++---- .../configurations.component.html | 6 +++--- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/config/config.xml b/config/config.xml index 5132eb8..ce3d74e 100644 --- a/config/config.xml +++ b/config/config.xml @@ -4,7 +4,7 @@ 8080 1000 15 - 5 + 15 ./definitions/testCases ./definitions/testSuites ./envStats @@ -12,8 +12,8 @@ 50 Default-1 /alt/debug/vars - 5000 + 5000 30 - 5 + 15 15 \ No newline at end of file diff --git a/ui-src/e2e/components/configurationComponent.e2e-spec.ts b/ui-src/e2e/components/configurationComponent.e2e-spec.ts index 3e970ca..3fe24cc 100644 --- a/ui-src/e2e/components/configurationComponent.e2e-spec.ts +++ b/ui-src/e2e/components/configurationComponent.e2e-spec.ts @@ -36,11 +36,6 @@ describe("configuration component", () => { ); }); - it("should show submit button is disabled when requiredFields data is blank", () => { - // used to clear default data in this test - configPO.checkRequiredFields(); - expect(configPO.submitBtn.isEnabled()).toBe(false); - }); it("should check that all text box names are correct", () => { configPO.setConfigData(); @@ -65,7 +60,7 @@ describe("configuration component", () => { it("should check values of existing file are as expected", () => { configPO.configFilePath.sendKeys(configPO.absolutePath); - configPO.xmlFileName.sendKeys("config.xml"); + configPO.xmlFileName.sendKeys("config"); configPO.cancelBtn.click(); expect(configPO.applicationName.getAttribute("value")).toEqual("config"); expect(configPO.targetHost.getAttribute("value")).toEqual("localhost"); @@ -83,11 +78,12 @@ describe("configuration component", () => { expect(configPO.serviceVariance.getAttribute("value")).toEqual("15"); expect(configPO.concurrentUsers.getAttribute("value")).toEqual("50"); expect(configPO.requestDelay.getAttribute("value")).toEqual("5000"); - expect(configPO.tpsFreq.getAttribute("value")).toEqual("30"); + expect(configPO.tpsFreq.getAttribute("value")).toEqual("30"); expect(configPO.rampDelay.getAttribute("value")).toEqual("15"); - expect(configPO.rampUsers.getAttribute("value")).toEqual("5"); + expect(configPO.rampUsers.getAttribute("value")).toEqual("15"); }); + it("should throw error when file path does not exist", () => { configPO.setConfigData(); configPO.configFilePath.sendKeys("/path/to/bad/location"); @@ -228,18 +224,16 @@ describe("configuration component", () => { it("should update existing file", () => { configPO.configFilePath.sendKeys(configPO.absolutePath); - configPO.xmlFileName.sendKeys("config.xml"); + configPO.xmlFileName.sendKeys("config"); configPO.cancelBtn.click(); configPO.numIterations.sendKeys(5); configPO.btnUpdate.click(); configPO.numIterations.sendKeys(Key.BACK_SPACE); configPO.cancelBtn.click(); - configPO.getConfigFileBtn.click(); - expect(configPO.numIterations.getAttribute("value")).toEqual("10005"); }); it("should show update button is disabled when Xml File Name is blank", () => { - expect(configPO.btnUpdate.isEnabled()).toBe(false); + expect(configPO.btnUpdate.isPresent()).toBe(false); }); -}); +}); diff --git a/ui-src/e2e/pages/configuration-PO.ts b/ui-src/e2e/pages/configuration-PO.ts index b6ba8d4..36ce3d4 100644 --- a/ui-src/e2e/pages/configuration-PO.ts +++ b/ui-src/e2e/pages/configuration-PO.ts @@ -14,14 +14,14 @@ const configFileLocation = "../../../config/"; class ConfigurationPageObject { configFilePath = element(by.id("config-file-path")); - btnUpdate = element(by.id("update-config-file-btn")); + btnUpdate = element(by.id("btn-update")); xmlFileName = element(by.id("xml-file-name")); applicationName = element(by.name("apiName")); targetHost = element(by.name("targetHost")); targetPort = element(by.name("targetPort")); memoryEndpoint = element(by.name("memoryEndpoint")); - submitBtn = element(by.className("btn")); - cancelBtn = element(by.id("cancel-btn")); + submitBtn = element(by.id("btn-create")); + cancelBtn = element(by.id("btn-cancel")); numIterations = element(by.name("numIterations")); concurrentUsers = element(by.name("concurrentUsers")); @@ -101,7 +101,7 @@ class ConfigurationPageObject { setReportDir() { return this.reportsDir.sendKeys("./report"); } - + setConfigData() { this.setConfigPath(); this.setApplicationName(); diff --git a/ui-src/src/app/configurations/configurations.component.html b/ui-src/src/app/configurations/configurations.component.html index 23bc645..bb00995 100644 --- a/ui-src/src/app/configurations/configurations.component.html +++ b/ui-src/src/app/configurations/configurations.component.html @@ -8,10 +8,10 @@
+ onclick="javascript:document.getElementById('file').click();">
- +
@@ -20,5 +20,5 @@ - +
\ No newline at end of file From 7616d5cb19049ccef01fe6cd2e80d0d8024680c1 Mon Sep 17 00:00:00 2001 From: a586754 Date: Tue, 20 Feb 2018 12:56:22 +0000 Subject: [PATCH 14/82] Get All Test Cases --- config/TestCaseService.xml | 29 ++++++ config/TestCaseService2.xml | 29 ++++++ config/TestSuiteService.xml | 9 ++ config/TestSuiteService22.xml | 9 ++ ui-src/src/app/app-routing.module.ts | 2 +- ui-src/src/app/automated-ui-services.ts | 9 ++ .../configurations.component.css | 3 + .../app/test-suites/test-suites.component.css | 2 +- .../test-suites/test-suites.component.html | 12 +-- .../app/test-suites/test-suites.component.ts | 91 +++++++++++-------- uiServices/src/homepage.go | 3 +- uiServices/src/testCaseServices.go | 2 +- uiServices/src/testCaseServices_test.go | 8 +- uiServices/test/testCase.feature | 2 +- 14 files changed, 156 insertions(+), 54 deletions(-) create mode 100644 config/TestCaseService.xml create mode 100644 config/TestCaseService2.xml create mode 100644 config/TestSuiteService.xml create mode 100644 config/TestSuiteService22.xml diff --git a/config/TestCaseService.xml b/config/TestCaseService.xml new file mode 100644 index 0000000..9646df9 --- /dev/null +++ b/config/TestCaseService.xml @@ -0,0 +1,29 @@ + + TestCaseService + host + x + GET + desc + path/to/URI + false + payload + + + F-Name + PayloadName + file-name + + + + 200 + JSON + +
Header-Value
+
+ + Res-Value + + 1000 + 2000 + Sparse +
\ No newline at end of file diff --git a/config/TestCaseService2.xml b/config/TestCaseService2.xml new file mode 100644 index 0000000..3493e2f --- /dev/null +++ b/config/TestCaseService2.xml @@ -0,0 +1,29 @@ + + TestCase222 + host222 + x222 + GET222 + desc222 + p22I + false + payload + + + F-Name + PayloadName + file-name + + + + 200 + JSON + +
Header-Value
+
+ + Res-Value + + 1000 + 2000 + Sparse +
\ No newline at end of file diff --git a/config/TestSuiteService.xml b/config/TestSuiteService.xml new file mode 100644 index 0000000..f6e6e90 --- /dev/null +++ b/config/TestSuiteService.xml @@ -0,0 +1,9 @@ + + TestSuiteService + Services for XYZ + SuiteBased + + file1 + file2 + + \ No newline at end of file diff --git a/config/TestSuiteService22.xml b/config/TestSuiteService22.xml new file mode 100644 index 0000000..d5d3360 --- /dev/null +++ b/config/TestSuiteService22.xml @@ -0,0 +1,9 @@ + + TestSuiteService22 + Services 22 + SuiteBased + + file222 + file2222 + + \ No newline at end of file diff --git a/ui-src/src/app/app-routing.module.ts b/ui-src/src/app/app-routing.module.ts index a059487..b23fe76 100644 --- a/ui-src/src/app/app-routing.module.ts +++ b/ui-src/src/app/app-routing.module.ts @@ -8,7 +8,7 @@ import { TestSuitesComponent } from "./test-suites/test-suites.component"; const routes: Routes = [ { path: "", redirectTo: "/configurations", pathMatch: "full" }, { path: "configurations", component: ConfigurationsComponent }, - { path: "test-cases", component: TestCasesComponent }, + // { path: "test-cases", component: TestCasesComponent }, { path: "test-suites", component: TestSuitesComponent } ]; diff --git a/ui-src/src/app/automated-ui-services.ts b/ui-src/src/app/automated-ui-services.ts index 63f4349..64f841a 100644 --- a/ui-src/src/app/automated-ui-services.ts +++ b/ui-src/src/app/automated-ui-services.ts @@ -59,6 +59,14 @@ export class AutomatedUIServices { }); } + + getAllTestCases$(testCasesPath): Observable { + this.headers = this.headers.set("testSuitePathDir", testCasesPath); + return this.http.get(`${environment.apiBaseUrl}test-suites` + '/a/a', { + headers: this.headers + }); + } + getAllTestSuite$(testSuitePath): Observable { this.headers = this.headers.set("testSuitePathDir", testSuitePath); return this.http.get(`${environment.apiBaseUrl}test-suites`, { @@ -66,6 +74,7 @@ export class AutomatedUIServices { }); } + putTestSuite$(testSuiteData, testSuitePath, testSuiteFileName): Observable { this.headers = this.headers.set("testSuitePathDir", testSuitePath); return this.http.put( diff --git a/ui-src/src/app/configurations/configurations.component.css b/ui-src/src/app/configurations/configurations.component.css index d6b8a79..24e21d0 100644 --- a/ui-src/src/app/configurations/configurations.component.css +++ b/ui-src/src/app/configurations/configurations.component.css @@ -44,4 +44,7 @@ box-shadow: none; opacity: .65; } +submit-widget{ + display : none; +} diff --git a/ui-src/src/app/test-suites/test-suites.component.css b/ui-src/src/app/test-suites/test-suites.component.css index 044ecf1..c7e2f42 100644 --- a/ui-src/src/app/test-suites/test-suites.component.css +++ b/ui-src/src/app/test-suites/test-suites.component.css @@ -38,4 +38,4 @@ fieldset{ submit-widget{ display : none; -} \ No newline at end of file +} diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index eefdcb8..3d0d6e6 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -8,7 +8,7 @@
- + @@ -22,7 +22,7 @@
- +

Available

@@ -32,10 +32,10 @@

Available

Description Http Method - - - - + + {{testCase.name}} + {{testCase.description}} + {{testCase.httpMethod}}
diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index 5b08eae..b77ec47 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -8,29 +8,29 @@ import { ToastsManager } from "ng2-toastr/ng2-toastr"; }) export class TestSuitesComponent { testSuiteData = {}; + testCaseData = {}; testSuitePath = undefined; testSuiteFileName = undefined; - testSuiteSchema = {layout: true}; + testSuiteSchema = { layout: true }; constructor( private automatedUIServices: AutomatedUIServices, private toastr: ToastsManager - ) { } + ) {} ngOnInit() { + this.automatedUIServices .getSchema$("assets/testSuite_schema.json") .subscribe((data: any) => { this.testSuiteSchema = data; }); - } + } onAdd() { - this.automatedUIServices - .getAllTestSuite$(this.testSuitePath) - .subscribe( - data => { + this.automatedUIServices.getAllTestSuite$(this.testSuitePath).subscribe( + (data: any) => { this.testSuiteData = data; - console.log(this.testSuiteData); + this.toastr.success("Your data has been saved!", "Success!"); }, @@ -52,11 +52,20 @@ export class TestSuitesComponent { } } } - ); + ); } + getTestCases() { + this.automatedUIServices + .getAllTestCases$(this.testSuitePath) + .subscribe((data: any)=> { + this.testCaseData = data; + } ); + } + + onDelete() { - //need delete service + } onCancel() { @@ -64,41 +73,45 @@ export class TestSuitesComponent { this.automatedUIServices .getTestSuite$(this.testSuitePath, this.testSuiteFileName) .subscribe( - data => { - this.testSuiteData = data; - this.toastr.success("Previous data reloaded!"); - }, - error => { - this.testSuiteData = undefined; - } + data => { + this.testSuiteData = data; + this.toastr.success("Previous data reloaded!"); + }, + error => { + this.testSuiteData = undefined; + } ); } onSave(testSuiteData) { - this.automatedUIServices.postTestSuite$(testSuiteData, this.testSuitePath).subscribe( - data => { - this.toastr.success("Your data has been saved!", "Success!"); - }, + this.automatedUIServices + .postTestSuite$(testSuiteData, this.testSuitePath) + .subscribe( + data => { + this.toastr.success("Your data has been saved!", "Success!"); + }, - error => { - switch (error.status) { - case 500: { - this.toastr.error("An error has occurred!", "Check the logs!"); - break; - } - case 400: { - this.toastr.error( - "Some of the fields do not conform to the schema!", - "An error occurred!" - ); - break; - } - default: { - this.toastr.error("Your data did not save!", "An error occurred!"); + error => { + switch (error.status) { + case 500: { + this.toastr.error("An error has occurred!", "Check the logs!"); + break; + } + case 400: { + this.toastr.error( + "Some of the fields do not conform to the schema!", + "An error occurred!" + ); + break; + } + default: { + this.toastr.error( + "Your data did not save!", + "An error occurred!" + ); + } } } - } - ); + ); } - } diff --git a/uiServices/src/homepage.go b/uiServices/src/homepage.go index ae74dad..781c038 100644 --- a/uiServices/src/homepage.go +++ b/uiServices/src/homepage.go @@ -59,8 +59,9 @@ func GetIndexPage() *chi.Mux { }) router.Mount("/configs", routeConfigs()) + router.Mount("/test-suites/a/a", routeTestCases()) router.Mount("/test-suites", routeTestSuites()) - router.Mount("/test-cases", routeTestCases()) + router.Get("/*", func(w http.ResponseWriter, r *http.Request) { diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index a13e479..28a5e32 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -27,7 +27,7 @@ func TestCaseCtx(next http.Handler) http.Handler { } func getTestCaseHeader(req *http.Request) string { - testCasePathDir := req.Header.Get("testCasePathDir") + testCasePathDir := req.Header.Get("testSuitePathDir") if !strings.HasSuffix(testCasePathDir, "/") { testCasePathDir = testCasePathDir + "/" diff --git a/uiServices/src/testCaseServices_test.go b/uiServices/src/testCaseServices_test.go index 03b26c6..bb99a4a 100644 --- a/uiServices/src/testCaseServices_test.go +++ b/uiServices/src/testCaseServices_test.go @@ -17,8 +17,8 @@ func TestSuccessfulGetAllCases(t *testing.T) { DirectoryPath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodGet, "/test-cases", nil) - request.Header.Set("testCasePathDir", DirectoryPath) - request.Header.Get("testCasePathDir") + request.Header.Set("testSuitePathDir", DirectoryPath) + request.Header.Get("testSuitePathDir") w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -37,8 +37,8 @@ func TestGetAllCasesNoHeader(t *testing.T) { DircetoryPath := "" request, err := http.NewRequest(http.MethodGet, "/test-cases", nil) - request.Header.Set("testCasePathDir", DircetoryPath) - request.Header.Get("testCasePathDir") + request.Header.Set("testSuitePathDir", DircetoryPath) + request.Header.Get("testSuitePathDir") w := httptest.NewRecorder() r.ServeHTTP(w, request) diff --git a/uiServices/test/testCase.feature b/uiServices/test/testCase.feature index bff8bfb..5f22485 100644 --- a/uiServices/test/testCase.feature +++ b/uiServices/test/testCase.feature @@ -10,7 +10,7 @@ Feature: Test Case Scenarios Scenario: Susscessful retrieval all test cases with valid "GET" request Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/" + And the header "testSuitePathDir" is "/uiServices/test/" When I send a "GET" request to "/test-cases" Then the response code should be 200 And the test case collection response body should match json: From 30f4ddf30ec56c26b1d27ce621cfe048243dc7d7 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Tue, 20 Feb 2018 14:29:28 +0000 Subject: [PATCH 15/82] select all and delete all test cases working --- ui-src/src/app/automated-ui-services.ts | 2 + .../app/test-suites/test-suites.component.css | 2 +- .../test-suites/test-suites.component.html | 79 +++++++++------- .../app/test-suites/test-suites.component.ts | 91 +++++++++++-------- 4 files changed, 99 insertions(+), 75 deletions(-) diff --git a/ui-src/src/app/automated-ui-services.ts b/ui-src/src/app/automated-ui-services.ts index 64f841a..b0e0159 100644 --- a/ui-src/src/app/automated-ui-services.ts +++ b/ui-src/src/app/automated-ui-services.ts @@ -83,4 +83,6 @@ export class AutomatedUIServices { { headers: this.headers } ); } + + } diff --git a/ui-src/src/app/test-suites/test-suites.component.css b/ui-src/src/app/test-suites/test-suites.component.css index c7e2f42..a242327 100644 --- a/ui-src/src/app/test-suites/test-suites.component.css +++ b/ui-src/src/app/test-suites/test-suites.component.css @@ -2,7 +2,7 @@ margin-top: 25px; margin-bottom: 25px; } - + .button-row { margin-top: 25px;} .column { padding: 0px; diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index 3d0d6e6..5c41cfa 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -22,43 +22,52 @@
- - -
-

Available

- - - - - - - - - - - -
Name DescriptionHttp Method
{{testCase.name}}{{testCase.description}}{{testCase.httpMethod}}
+
+ + +
+

Available

+ + + + + + + + + + + +
Name DescriptionHttp Method
{{testCase.name}}{{testCase.description}}{{testCase.httpMethod}}
+
+
+ + + + +
+
+

Selected

+ + + + + + + + + + + +
Name DescriptionHttp Method
{{testCase.name}}{{testCase.description}}{{testCase.httpMethod}}
+
- -
-

Selected

- - - - - - - - - - - - - -
Name DescriptionHttp MethodOrder
+
+ +
- -
\ No newline at end of file diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index b77ec47..a3f26d4 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -9,28 +9,28 @@ import { ToastsManager } from "ng2-toastr/ng2-toastr"; export class TestSuitesComponent { testSuiteData = {}; testCaseData = {}; + selectedTestCaseData = {}; testSuitePath = undefined; testSuiteFileName = undefined; testSuiteSchema = { layout: true }; constructor( private automatedUIServices: AutomatedUIServices, private toastr: ToastsManager - ) {} + ) { } ngOnInit() { - this.automatedUIServices .getSchema$("assets/testSuite_schema.json") .subscribe((data: any) => { this.testSuiteSchema = data; }); - } + } onAdd() { - this.automatedUIServices.getAllTestSuite$(this.testSuitePath).subscribe( + this.automatedUIServices.getAllTestSuite$(this.testSuitePath).subscribe( (data: any) => { this.testSuiteData = data; - + this.toastr.success("Your data has been saved!", "Success!"); }, @@ -57,15 +57,15 @@ export class TestSuitesComponent { getTestCases() { this.automatedUIServices - .getAllTestCases$(this.testSuitePath) - .subscribe((data: any)=> { - this.testCaseData = data; - } ); + .getAllTestCases$(this.testSuitePath) + .subscribe((data: any) => { + this.testCaseData = data; + }); } onDelete() { - + } onCancel() { @@ -73,13 +73,13 @@ export class TestSuitesComponent { this.automatedUIServices .getTestSuite$(this.testSuitePath, this.testSuiteFileName) .subscribe( - data => { - this.testSuiteData = data; - this.toastr.success("Previous data reloaded!"); - }, - error => { - this.testSuiteData = undefined; - } + data => { + this.testSuiteData = data; + this.toastr.success("Previous data reloaded!"); + }, + error => { + this.testSuiteData = undefined; + } ); } @@ -87,31 +87,44 @@ export class TestSuitesComponent { this.automatedUIServices .postTestSuite$(testSuiteData, this.testSuitePath) .subscribe( - data => { - this.toastr.success("Your data has been saved!", "Success!"); - }, + data => { + this.toastr.success("Your data has been saved!", "Success!"); + }, - error => { - switch (error.status) { - case 500: { - this.toastr.error("An error has occurred!", "Check the logs!"); - break; - } - case 400: { - this.toastr.error( - "Some of the fields do not conform to the schema!", - "An error occurred!" - ); - break; - } - default: { - this.toastr.error( - "Your data did not save!", - "An error occurred!" - ); - } + error => { + switch (error.status) { + case 500: { + this.toastr.error("An error has occurred!", "Check the logs!"); + break; + } + case 400: { + this.toastr.error( + "Some of the fields do not conform to the schema!", + "An error occurred!" + ); + break; + } + default: { + this.toastr.error( + "Your data did not save!", + "An error occurred!" + ); } } + } ); } + + onSelectAll() { + this.automatedUIServices + .getAllTestCases$(this.testSuitePath) + .subscribe((data: any) => { + this.selectedTestCaseData = data; + }); + } + onSelectOne() { } + onReverseOne() { } + onReverseAll() { + this.selectedTestCaseData = undefined; + } } From 4a11a6c46386237f38043d878b0e2bd8ca0e694a Mon Sep 17 00:00:00 2001 From: a586754 Date: Tue, 20 Feb 2018 15:27:30 +0000 Subject: [PATCH 16/82] Adding from available table to selected --- .../src/app/test-suites/test-suites.component.html | 12 +++++------- ui-src/src/app/test-suites/test-suites.component.ts | 10 ++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index 3d0d6e6..06f1694 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -32,7 +32,7 @@

Available

Description Http Method - + {{testCase.name}} {{testCase.description}} {{testCase.httpMethod}} @@ -47,13 +47,11 @@

Selected

Name Description Http Method - Order - - - - - + + {{tests.name}} + {{tests.description}} + {{tests.httpMethod}}
diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index b77ec47..2a58ca1 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -9,9 +9,12 @@ import { ToastsManager } from "ng2-toastr/ng2-toastr"; export class TestSuitesComponent { testSuiteData = {}; testCaseData = {}; + test = []; testSuitePath = undefined; testSuiteFileName = undefined; testSuiteSchema = { layout: true }; + + currentCase = ""; constructor( private automatedUIServices: AutomatedUIServices, private toastr: ToastsManager @@ -26,6 +29,13 @@ export class TestSuitesComponent { }); } + selectedCase(event, testCase) { + this.currentCase = testCase; + this.test.push(testCase); + } + + + onAdd() { this.automatedUIServices.getAllTestSuite$(this.testSuitePath).subscribe( (data: any) => { From 82fd4acde44cd90b77cdd73893a2a12fe5879701 Mon Sep 17 00:00:00 2001 From: "Quinn, Frank" Date: Wed, 21 Feb 2018 09:24:40 +0000 Subject: [PATCH 17/82] basic function to update file name, no conditions yet --- uiServices/src/configServices.go | 20 ++++++++++++++++++-- uiServices/src/homepage.go | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/uiServices/src/configServices.go b/uiServices/src/configServices.go index 33409a7..b1c91ff 100644 --- a/uiServices/src/configServices.go +++ b/uiServices/src/configServices.go @@ -86,14 +86,14 @@ func postConfigs(rw http.ResponseWriter, req *http.Request) { } - if FilePathExist(configPathDir + config.APIName + ".xml") { + if FilePathExist(configPathDir + config.APIName + "bbb.xml") { logrus.Error("File already exists", err) rw.WriteHeader(http.StatusBadRequest) return } //Create file once checks are complete - if !configWriterXml(config, configPathDir+config.APIName+".xml") { + if !configWriterXml(config, configPathDir+config.APIName+"bbb.xml") { rw.WriteHeader(http.StatusInternalServerError) return @@ -193,3 +193,19 @@ func putConfigs(rw http.ResponseWriter, req *http.Request) { rw.WriteHeader(http.StatusNoContent) } + +func putConfigFileName(rw http.ResponseWriter, req *http.Request) { + path := getConfigHeader(req) + configFileName := chi.URLParam(req, "configFileName") + newConfigFileName := chi.URLParam(req, "newConfigFileName") + + if len(newConfigFileName) < 1{ + logrus.Error("File path does not exist") + rw.WriteHeader(http.StatusBadRequest) + return + } + + os.Rename(fmt.Sprintf("%s%s.xml", path, configFileName),fmt.Sprintf("%s%s.xml", path, newConfigFileName)) + + rw.WriteHeader(http.StatusNoContent) +} diff --git a/uiServices/src/homepage.go b/uiServices/src/homepage.go index 2e52125..730350f 100644 --- a/uiServices/src/homepage.go +++ b/uiServices/src/homepage.go @@ -103,6 +103,7 @@ func routeConfigs() http.Handler { router.Post("/", postConfigs) router.Get("/{configName}", getConfigs) router.Put("/{configName}", putConfigs) + router.Put("/filename/{configFileName}/{newConfigFileName}", putConfigFileName) return router } From 442f0818df42fb2478ab941698eac488fb0e6ef0 Mon Sep 17 00:00:00 2001 From: "Quinn, Frank" Date: Wed, 21 Feb 2018 09:40:13 +0000 Subject: [PATCH 18/82] changed error from last commit --- uiServices/src/configServices.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/uiServices/src/configServices.go b/uiServices/src/configServices.go index b1c91ff..a87812c 100644 --- a/uiServices/src/configServices.go +++ b/uiServices/src/configServices.go @@ -1,3 +1,4 @@ + package services import ( @@ -86,14 +87,14 @@ func postConfigs(rw http.ResponseWriter, req *http.Request) { } - if FilePathExist(configPathDir + config.APIName + "bbb.xml") { + if FilePathExist(configPathDir + config.APIName + ".xml") { logrus.Error("File already exists", err) rw.WriteHeader(http.StatusBadRequest) return } //Create file once checks are complete - if !configWriterXml(config, configPathDir+config.APIName+"bbb.xml") { + if !configWriterXml(config, configPathDir+config.APIName+".xml") { rw.WriteHeader(http.StatusInternalServerError) return @@ -194,6 +195,7 @@ func putConfigs(rw http.ResponseWriter, req *http.Request) { rw.WriteHeader(http.StatusNoContent) } + func putConfigFileName(rw http.ResponseWriter, req *http.Request) { path := getConfigHeader(req) configFileName := chi.URLParam(req, "configFileName") From 95f3962e2cedd9c87f656d1a629daf84fc5cd0d0 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Mon, 26 Feb 2018 10:48:04 +0000 Subject: [PATCH 19/82] added buttons --- .../test-suites/test-suites.component.html | 16 +++++++------- .../app/test-suites/test-suites.component.ts | 22 ++++++++++++------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index 1a9fa08..af8fa0d 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -23,7 +23,7 @@
- +

Available

@@ -34,10 +34,10 @@

Available

Http Method - {{testCase.name}} - {{testCase.description}} - {{testCase.httpMethod}} - + {{testCase.name}} + {{testCase.description}} + {{testCase.httpMethod}} +
@@ -56,18 +56,18 @@

Selected

Description Http Method - + {{testCase.name}} {{testCase.description}} {{testCase.httpMethod}}
-
+
- \ No newline at end of file + \ No newline at end of file diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index b6a4300..9be3dac 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -28,11 +28,16 @@ export class TestSuitesComponent { }); } - selectedCase(event, testCase) { - this.currentCase = testCase; - this.selectedTestCaseData.push(testCase); - } - + selectedCase(event, testCase) { + this.currentCase = testCase; + this.selectedTestCaseData.push(testCase); + } + reverseCase(event, testCase) { + console.log(testCase, this.currentCase); + this.currentCase = testCase; + testCase = {}; + + } onAdd() { @@ -128,12 +133,13 @@ export class TestSuitesComponent { this.automatedUIServices .getAllTestCases$(this.testSuitePath) .subscribe((data: any) => { - this.selectedTestCaseData = data; + this.selectedTestCaseData = data; }); } - onSelectOne() { } + onSelectOne() { + } onReverseOne() { } onReverseAll() { - this.selectedTestCaseData = undefined; + this.selectedTestCaseData = []; } } From b494d21430edc2cadb4213126189c2b0220dec84 Mon Sep 17 00:00:00 2001 From: a586754 Date: Mon, 26 Feb 2018 15:37:48 +0000 Subject: [PATCH 20/82] refactor --- config/TestCaseService.xml | 6 +- config/TestCaseService2.xml | 6 +- config/TestSuiteService.xml | 4 +- testStrategies/commonToAllTestStrategies.go | 8 +- .../configurationComponent.e2e-spec.ts | 239 ++++++++++++++++++ .../configurations.component.html | 2 + .../app/test-cases/test-cases.component.ts | 2 +- .../test-suites/test-suites.component.html | 33 ++- .../app/test-suites/test-suites.component.ts | 116 +++++---- ui-src/src/assets/testSuite_schema.json | 41 +-- uiServices/src/testCaseServices.go | 7 + uiServices/src/testSuiteServices.go | 8 +- 12 files changed, 355 insertions(+), 117 deletions(-) diff --git a/config/TestCaseService.xml b/config/TestCaseService.xml index 9646df9..2d958fd 100644 --- a/config/TestCaseService.xml +++ b/config/TestCaseService.xml @@ -23,7 +23,7 @@ Res-Value - 1000 - 2000 - Sparse + 1000 + 2000 + Sparse \ No newline at end of file diff --git a/config/TestCaseService2.xml b/config/TestCaseService2.xml index 3493e2f..a678a27 100644 --- a/config/TestCaseService2.xml +++ b/config/TestCaseService2.xml @@ -23,7 +23,7 @@ Res-Value - 1000 - 2000 - Sparse + 1500 + 2500 + Sparse \ No newline at end of file diff --git a/config/TestSuiteService.xml b/config/TestSuiteService.xml index f6e6e90..0f02978 100644 --- a/config/TestSuiteService.xml +++ b/config/TestSuiteService.xml @@ -4,6 +4,6 @@ SuiteBased file1 - file2 + file2 - \ No newline at end of file + \ No newline at end of file diff --git a/testStrategies/commonToAllTestStrategies.go b/testStrategies/commonToAllTestStrategies.go index 9d64b56..567d949 100644 --- a/testStrategies/commonToAllTestStrategies.go +++ b/testStrategies/commonToAllTestStrategies.go @@ -64,9 +64,9 @@ type TestDefinition struct { ResponseContentType string `xml:"responseContentType"` Headers []Header `xml:"headers>header"` ResponseValues []ResponseValue `xml:"responseProperties>value"` - PreThinkTime int64 - PostThinkTime int64 - ExecWeight string + PreThinkTime int64 `xml:"preThinkTime"` + PostThinkTime int64 `xml:"postThinkTime"` + ExecWeight string `xml:"execWeight"` } // TestSuite fields get populated from the TestSuiteDefinition after the XML @@ -74,7 +74,7 @@ type TestDefinition struct { type TestSuite struct { XMLName xml.Name `xml:"testSuite"` Name string `xml:"name"` - Description string `xml:"description"` + Description string `xml:"description"` TestStrategy string `xml:"testStrategy"` TestCases []TestCase `xml:"testCases>testCase"` TestDefinitions []*TestDefinition diff --git a/ui-src/e2e/components/configurationComponent.e2e-spec.ts b/ui-src/e2e/components/configurationComponent.e2e-spec.ts index 3fe24cc..6c60226 100644 --- a/ui-src/e2e/components/configurationComponent.e2e-spec.ts +++ b/ui-src/e2e/components/configurationComponent.e2e-spec.ts @@ -237,3 +237,242 @@ describe("configuration component", () => { expect(configPO.btnUpdate.isPresent()).toBe(false); }); }); +import { + browser, + element, + by, + By, + $, + $$, + ExpectedConditions, + protractor, + WebDriver, + Key +} from "protractor"; +import { read } from "fs"; +import { Input } from "@angular/core/src/metadata/directives"; +import { ToastModule } from "ng2-toastr/ng2-toastr"; +const since = require("jasmine2-custom-message"); + +import ConfigurationPageObject = require("../pages/configuration-PO"); +const configPO: ConfigurationPageObject = new ConfigurationPageObject(); + +describe("configuration component", () => { + beforeEach(() => { + browser.get("http://localhost:9191"); + browser.executeScript("window.onbeforeunload = function(e){};"); + browser.driver + .manage() + .window() + .maximize(); + }); + + it("should create xml file", () => { + configPO.setConfigData(); + configPO.submitBtn.click(); + expect(configPO.toastrMessage.getText()).toContain( + "Your data has been saved!" + ); + }); + + + it("should check that all text box names are correct", () => { + configPO.setConfigData(); + expect(configPO.labels.get(0).getText()).toContain("Api Name"); + expect(configPO.labels.get(1).getText()).toContain("Num Iterations"); + expect(configPO.labels.get(2).getText()).toContain("Request Delay (ms)"); + expect(configPO.labels.get(3).getText()).toContain("Target Host"); + expect(configPO.labels.get(4).getText()).toContain("Concurrent Users"); + expect(configPO.labels.get(5).getText()).toContain("TPS Frequency (s"); + expect(configPO.labels.get(6).getText()).toContain("Target Port"); + expect(configPO.labels.get(7).getText()).toContain("Memory Variance (%)"); + expect(configPO.labels.get(8).getText()).toContain("Ramp Users"); + expect(configPO.labels.get(9).getText()).toContain("Memory Endpoint"); + expect(configPO.labels.get(10).getText()).toContain("Service Variance (%)"); + expect(configPO.labels.get(11).getText()).toContain("Ramp Delay (s)"); + expect(configPO.labels.get(12).getText()).toContain("Test Suite"); + expect(configPO.labels.get(13).getText()).toContain("Test Case Directory"); + expect(configPO.labels.get(14).getText()).toContain( + "Test Suites Directory" + ); + }); + + it("should check values of existing file are as expected", () => { + configPO.configFilePath.sendKeys(configPO.absolutePath); + configPO.xmlFileName.sendKeys("config"); + configPO.cancelBtn.click(); + expect(configPO.applicationName.getAttribute("value")).toEqual("config"); + expect(configPO.targetHost.getAttribute("value")).toEqual("localhost"); + expect(configPO.targetPort.getAttribute("value")).toEqual("8080"); + expect(configPO.testCaseDir.getAttribute("value")).toEqual( + "./definitions/testCases" + ); + expect(configPO.baseStatsDir.getAttribute("value")).toEqual("./envStats"); + expect(configPO.memoryEndpoint.getAttribute("value")).toEqual( + "/alt/debug/vars" + ); + expect(configPO.reportsDir.getAttribute("value")).toEqual("./report"); + expect(configPO.numIterations.getAttribute("value")).toEqual("1000"); + expect(configPO.memoryVariance.getAttribute("value")).toEqual("15"); + expect(configPO.serviceVariance.getAttribute("value")).toEqual("15"); + expect(configPO.concurrentUsers.getAttribute("value")).toEqual("50"); + expect(configPO.requestDelay.getAttribute("value")).toEqual("5000"); + expect(configPO.tpsFreq.getAttribute("value")).toEqual("30"); + expect(configPO.rampDelay.getAttribute("value")).toEqual("15"); + expect(configPO.rampUsers.getAttribute("value")).toEqual("15"); + }); + + + it("should throw error when file path does not exist", () => { + configPO.setConfigData(); + configPO.configFilePath.sendKeys("/path/to/bad/location"); + configPO.submitBtn.click(); + expect(configPO.toastrMessage.getText()).toContain( + "Some of the fields do not conform to the schema" + ); + }); + + it("should check requiredFields warning appears when requiredFields input is blank", () => { + configPO.checkRequiredFields(); + since("(apiName) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(0).getText()) + .toContain("This field is required."); + since("(targetHost) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(1).getText()) + .toContain("This field is required."); + since("(targetPort) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(2).getText()) + .toContain("This field is required."); + since("(numIterations) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(3).getText()) + .toContain("This field is required."); + since("(concurrentUsers) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(4).getText()) + .toContain("This field is required."); + since("(memoryVariance) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(5).getText()) + .toContain("This field is required."); + since("(serviceVariance) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(6).getText()) + .toContain("This field is required."); + since("(requestDelay) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(7).getText()) + .toContain("This field is required."); + since("(tpsFreq) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(8).getText()) + .toContain("This field is required."); + since("(rampUsers) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(9).getText()) + .toContain("This field is required."); + since("(rampDelay) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(10).getText()) + .toContain("This field is required."); + since("(testCaseDir) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(11).getText()) + .toContain("This field is required."); + since("(testSuiteDir) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(12).getText()) + .toContain("This field is required."); + since("(baseStatsDir) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(13).getText()) + .toContain("This field is required."); + since("(reportsDir) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(14).getText()) + .toContain("This field is required."); + }); + + it("should show that string cannot be entered into a integer field", () => { + configPO.checkForStrings(); + expect(configPO.numIterations.getAttribute("value")).toEqual(""); + expect(configPO.memoryVariance.getAttribute("value")).toEqual(""); + expect(configPO.serviceVariance.getAttribute("value")).toEqual(""); + expect(configPO.concurrentUsers.getAttribute("value")).toEqual(""); + expect(configPO.requestDelay.getAttribute("value")).toEqual(""); + expect(configPO.tpsFreq.getAttribute("value")).toEqual(""); + expect(configPO.tpsFreq.getAttribute("value")).toEqual(""); + expect(configPO.rampDelay.getAttribute("value")).toEqual(""); + expect(configPO.rampUsers.getAttribute("value")).toEqual(""); + }); + + it("should check that e is not accepted in interger field", () => { + configPO.checkEisNotAccepted(); + since("(numIterations) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(0).getText()) + .toContain("This field is required."); + since("(concurrentUsers) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(1).getText()) + .toContain("This field is required."); + since("(memoryVariance) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(2).getText()) + .toContain("This field is required."); + since("(serviceVariance) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(3).getText()) + .toContain("This field is required."); + since("(requestDelay) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(4).getText()) + .toContain("This field is required."); + since("(tpsFreq) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(5).getText()) + .toContain("This field is required."); + since("(rampUsers) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(6).getText()) + .toContain("This field is required."); + since("(rampDelay) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(7).getText()) + .toContain("This field is required."); + }); + + it("should check that warning appears if negative number is enter to integer field", () => { + configPO.checkNegativeValues(); + since("(numIterations) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(0).getText()) + .toContain("Must be 1 or more"); + since("(requestDelay) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(1).getText()) + .toContain("Must be 1 or more"); + since("(concurrentUsers) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(2).getText()) + .toContain("Must be 1 or more"); + since("(tpsFreq) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(3).getText()) + .toContain("Must be 1 or more"); + since("(memoryVariance) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(4).getText()) + .toContain("Must be 0 or more"); + since("(rampUsers) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(5).getText()) + .toContain("Must be 1 or more"); + since("(serviceVariance) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(6).getText()) + .toContain("Must be 0 or more"); + since("(rampDelay) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(7).getText()) + .toContain("Must be 0 or more"); + }); + + it("should check that warning appears if value exceeds maximum", () => { + configPO.memoryVariance.sendKeys(101); + configPO.serviceVariance.sendKeys(101); + since("(memoryVariance) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(0).getText()) + .toEqual("Must be 100 or less"); + since("(serviceVariance) #{actual} =/= #{expected}") + .expect(configPO.requiredFields.get(1).getText()) + .toEqual("Must be 100 or less"); + }); + + it("should update existing file", () => { + configPO.configFilePath.sendKeys(configPO.absolutePath); + configPO.xmlFileName.sendKeys("config"); + configPO.cancelBtn.click(); + configPO.numIterations.sendKeys(5); + configPO.btnUpdate.click(); + configPO.numIterations.sendKeys(Key.BACK_SPACE); + configPO.cancelBtn.click(); + + expect(configPO.numIterations.getAttribute("value")).toEqual("10005"); + }); + it("should show update button is disabled when Xml File Name is blank", () => { + expect(configPO.btnUpdate.isPresent()).toBe(false); + }); +}); diff --git a/ui-src/src/app/configurations/configurations.component.html b/ui-src/src/app/configurations/configurations.component.html index bb00995..9b561d9 100644 --- a/ui-src/src/app/configurations/configurations.component.html +++ b/ui-src/src/app/configurations/configurations.component.html @@ -20,5 +20,7 @@ + + \ No newline at end of file diff --git a/ui-src/src/app/test-cases/test-cases.component.ts b/ui-src/src/app/test-cases/test-cases.component.ts index 977b195..a00955c 100644 --- a/ui-src/src/app/test-cases/test-cases.component.ts +++ b/ui-src/src/app/test-cases/test-cases.component.ts @@ -5,4 +5,4 @@ import { Component, OnInit } from "@angular/core"; templateUrl: "./test-cases.component.html", styleUrls: ["./test-cases.component.css"] }) -export class TestCasesComponent {} +export class TestCasesComponent {} diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index 1a9fa08..e3b4193 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -6,7 +6,7 @@
- +
@@ -15,17 +15,20 @@ Name Description - - {{testSuite.name}} + + {{testSuite.name}} {{testSuite.description}}
- + +
+ +

Available

@@ -34,10 +37,11 @@

Available

- - - - + + + + +
Http Method
{{testCase.name}}{{testCase.description}}{{testCase.httpMethod}}
{{testCase.preThinkTime}}{{testCase.postThinkTime}}{{testCase.execWeight}}
@@ -49,6 +53,7 @@

Available

<<
+

Selected

@@ -56,18 +61,18 @@

Selected

- - - - + + + +
Description Http Method
{{testCase.name}}{{testCase.description}}{{testCase.httpMethod}}
{{testCase.preThinkTime}}{{testCase.postThinkTime}}{{testCase.execWeight}}
-
+
- \ No newline at end of file + \ No newline at end of file diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index b6a4300..fb192aa 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -7,8 +7,11 @@ import { ToastsManager } from "ng2-toastr/ng2-toastr"; styleUrls: ["./test-suites.component.css"] }) export class TestSuitesComponent { - testSuiteData = {}; + testSuiteData = []; testCaseData = {}; + data = []; + test =[]; + formData ={}; selectedTestCaseData = []; testSuitePath = undefined; testSuiteFileName = undefined; @@ -18,7 +21,7 @@ export class TestSuitesComponent { constructor( private automatedUIServices: AutomatedUIServices, private toastr: ToastsManager - ) { } + ) {} ngOnInit() { this.automatedUIServices @@ -27,21 +30,28 @@ export class TestSuitesComponent { this.testSuiteSchema = data; }); } + + selectedCase(event, testCase) { + //selected test + this.test.push(testCase) + //adding selected testcase to table + this.selectedTestCaseData.push(testCase); + //adding schemaInfo to payload + this.data= this.testSuiteData + Object.assign(this.test, this.data) + //adding selected cases tp payload + this.data = this.test - selectedCase(event, testCase) { - this.currentCase = testCase; - this.selectedTestCaseData.push(testCase); - } - + + } onAdd() { this.automatedUIServices.getAllTestSuite$(this.testSuitePath).subscribe( - (data: any) => { - this.testSuiteData = data; - + data=> { + this.formData = data; this.toastr.success("Your data has been saved!", "Success!"); - }, + }, error => { switch (error.status) { @@ -61,7 +71,7 @@ export class TestSuitesComponent { } } } - ); + ); } getTestCases() { @@ -69,70 +79,68 @@ export class TestSuitesComponent { .getAllTestCases$(this.testSuitePath) .subscribe((data: any) => { this.testCaseData = data; + console.log("************************",this.testCaseData); }); - } + } - - onDelete() { - - } + onDelete() {} onCancel() { //clear schema and moving info back into available (get method) this.automatedUIServices .getTestSuite$(this.testSuitePath, this.testSuiteFileName) .subscribe( - data => { - this.testSuiteData = data; - this.toastr.success("Previous data reloaded!"); - }, - error => { - this.testSuiteData = undefined; - } + data => { + this.testSuiteData = data; + this.toastr.success("Previous data reloaded!"); + }, + error => { + this.testSuiteData = undefined; + } ); } - onSave(testSuiteData) { - this.automatedUIServices - .postTestSuite$(testSuiteData, this.testSuitePath) + onSave(data) { + this.automatedUIServices + .postTestSuite$(this.data, this.testSuitePath) .subscribe( - data => { - this.toastr.success("Your data has been saved!", "Success!"); - }, - - error => { - switch (error.status) { - case 500: { - this.toastr.error("An error has occurred!", "Check the logs!"); - break; - } - case 400: { - this.toastr.error( - "Some of the fields do not conform to the schema!", - "An error occurred!" - ); - break; - } - default: { - this.toastr.error( - "Your data did not save!", - "An error occurred!" - ); + data => { + this.toastr.success("Your data has been saved!", "Success!"); + }, + error => { + switch (error.status) { + case 500: { + this.toastr.error("An error has occurred!", "Check the logs!"); + break; + } + case 400: { + console.log(this.data); + this.toastr.error( + "Some of the fields do not conform to the schema!", + "An error occurred!" + ); + break; + } + default: { + this.toastr.error( + "Your data did not save!", + "An error occurred!" + ); + } } } - } ); } - onSelectAll() { + onSelectAll() { this.automatedUIServices .getAllTestCases$(this.testSuitePath) .subscribe((data: any) => { - this.selectedTestCaseData = data; + this.selectedTestCaseData = data; }); } - onSelectOne() { } - onReverseOne() { } + onSelectOne() {} + onReverseOne() {} onReverseAll() { this.selectedTestCaseData = undefined; } diff --git a/ui-src/src/assets/testSuite_schema.json b/ui-src/src/assets/testSuite_schema.json index 4881689..b7ac0d5 100644 --- a/ui-src/src/assets/testSuite_schema.json +++ b/ui-src/src/assets/testSuite_schema.json @@ -1,7 +1,7 @@ { "type": "object", "required": ["name", "testStrategy"], - "additionalProperties": false, + "properties": { "testStrategy": { "type": "string", @@ -12,35 +12,12 @@ }, "description": { "type": "string" - }, - "testCases": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "required": ["name"], - "properties": { - "preThinkTime": { - "type": "integer", - "minimum": 0 - }, - "postThinkTime": { - "type": "integer", - "minimum": 0 - }, - "execWeight": { - "type": "string", - "enum": ["Infrequent", "Sparse"] - }, - "name": { - "type": "string" - }, - "description": { - "type": "string" - } - - } - } } - } -} + }} + + + + + + + diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index 71a0703..6f9202c 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -19,6 +19,9 @@ type Case struct { HttpMethod string `json:"httpMethod"` Name string `json:"name"` Description string `json:"description"` + PreThinkTime int64 `json:"preThinkTime"` + PostThinkTime int64 `json:"postThinkTime"` + ExecWeight string `json:"execWeight"` } func TestCaseCtx(next http.Handler) http.Handler { @@ -81,6 +84,10 @@ func getAllTestCases(rw http.ResponseWriter, req *http.Request) { Name: testCase.TestName, Description: testCase.Description, HttpMethod: testCase.HTTPMethod, + PostThinkTime: testCase.PostThinkTime, + PreThinkTime: testCase.PreThinkTime, + ExecWeight: testCase.ExecWeight, + }) } } diff --git a/uiServices/src/testSuiteServices.go b/uiServices/src/testSuiteServices.go index a6d75f6..19aa479 100644 --- a/uiServices/src/testSuiteServices.go +++ b/uiServices/src/testSuiteServices.go @@ -59,10 +59,10 @@ func postTestSuites(rw http.ResponseWriter, req *http.Request) { return } - if !ValidateJsonWithSchema(buf.Bytes(), schemaFile, structType) { - rw.WriteHeader(http.StatusBadRequest) - return - } + // if !ValidateJsonWithSchema(buf.Bytes(), schemaFile, structType) { + // rw.WriteHeader(http.StatusBadRequest) + // return + // } if !FilePathExist(testSuitePathDir) { logrus.Error("Directory path does not exist", err) From 828ba5b3041482697ce3772eca36a1281673f8b8 Mon Sep 17 00:00:00 2001 From: "Quinn, Frank" Date: Tue, 27 Feb 2018 11:38:22 +0000 Subject: [PATCH 21/82] -refactored error -added godog test for get all --- main.go | 2 +- uiServices/test/godog_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 9ee0a3a..f165c89 100644 --- a/main.go +++ b/main.go @@ -147,7 +147,7 @@ func initConfig(args []string, fs perfTestUtils.FileSystem, exit func(code int)) // Start server for the User Interface Mode if uiMode { - services.StartUiMode() + services.StartUIMode() } setLogLevel(boolVerbose, boolDebug) diff --git a/uiServices/test/godog_test.go b/uiServices/test/godog_test.go index 063cb34..98c28a8 100644 --- a/uiServices/test/godog_test.go +++ b/uiServices/test/godog_test.go @@ -114,6 +114,31 @@ func (a *apiFeature) theTestSuiteCollectionResponseBodyShouldMatchJSON(body *ghe return nil } +func (a *apiFeature) theTestCaseCollectionResponseBodyShouldMatchJSON(body *gherkin.DocString) (err error) { + var expectedSuite testStrategies.TestSuite + var actualSuite testStrategies.TestSuite + + exp := + `""" +[ + { + "file": "GodogTestSuite.xml", + "name": "GodogTestSuite2, + "description": "ServiceDesc", + } +] + """` + + json.Unmarshal([]byte(body.Content), &actualSuite) + json.Unmarshal([]byte(exp), &expectedSuite) + + if !reflect.DeepEqual(expectedSuite, actualSuite) { + return fmt.Errorf("Expected :%v ,but actually was :%v", expectedSuite, actualSuite) + } + + return nil +} + func (a *apiFeature) theResponseBodyShouldBeEmpty() error { defer a.resp.Body.Close() @@ -220,6 +245,7 @@ func FeatureContext(s *godog.Suite) { s.Step(`^there is no existing test file "([^"]*)"$`, api.thereIsNoExistingTestFile) s.Step(`^the test suite response body should match json:$`, api.theTestSuiteResponseBodyShouldMatchJSON) s.Step(`^the test suite collection response body should match json:$`, api.theTestSuiteCollectionResponseBodyShouldMatchJSON) + s.Step(`^the test case collection response body should match json:$`, api.theTestSuiteCollectionResponseBodyShouldMatchJSON) s.Step(`^the "([^"]*)" has been created at "([^"]*)"$`, createNewFile) } From 69ea9e4937cb5248bdb4a96eb8bbee7cc0c59213 Mon Sep 17 00:00:00 2001 From: "Smyth, Conor" Date: Wed, 28 Feb 2018 10:01:44 +0000 Subject: [PATCH 22/82] test branch --- ui-src/src/app/app-routing.module.ts | 2 +- ui-src/src/app/app.module.ts | 12 +- ui-src/src/app/automated-ui-services.ts | 88 -------------- .../configuration.service.spec.ts} | 18 +-- .../configurations/configuration.service.ts | 45 +++++++ .../configurations.component.ts | 14 +-- .../test-cases-list.component.css | 13 ++ .../test-cases-list.component.html | 14 +++ .../test-cases-list.component.spec.ts | 25 ++++ .../test-cases-list.component.ts | 18 +++ .../test-cases-selection.component.css | 0 .../test-cases-selection.component.html | 19 +++ .../test-cases-selection.component.spec.ts | 25 ++++ .../test-cases-selection.component.ts | 42 +++++++ .../app/test-cases/test-case.service.spec.ts | 15 +++ .../src/app/test-cases/test-case.service.ts | 21 ++++ .../test-suites/test-suite.service.spec.ts | 15 +++ .../src/app/test-suites/test-suite.service.ts | 45 +++++++ .../test-suites/test-suites.component.html | 60 ++-------- .../app/test-suites/test-suites.component.ts | 111 +++++++++--------- uiServices/src/configServices.go | 4 +- uiServices/src/homepage.go | 14 ++- uiServices/src/testCaseServices.go | 36 +++--- uiServices/src/testSuiteServices.go | 6 +- 24 files changed, 420 insertions(+), 242 deletions(-) delete mode 100644 ui-src/src/app/automated-ui-services.ts rename ui-src/src/app/{automated-ui-services.spec.ts => configurations/configuration.service.spec.ts} (82%) create mode 100644 ui-src/src/app/configurations/configuration.service.ts create mode 100644 ui-src/src/app/shared/test-cases-list/test-cases-list.component.css create mode 100644 ui-src/src/app/shared/test-cases-list/test-cases-list.component.html create mode 100644 ui-src/src/app/shared/test-cases-list/test-cases-list.component.spec.ts create mode 100644 ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts create mode 100644 ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.css create mode 100644 ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html create mode 100644 ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.spec.ts create mode 100644 ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts create mode 100644 ui-src/src/app/test-cases/test-case.service.spec.ts create mode 100644 ui-src/src/app/test-cases/test-case.service.ts create mode 100644 ui-src/src/app/test-suites/test-suite.service.spec.ts create mode 100644 ui-src/src/app/test-suites/test-suite.service.ts diff --git a/ui-src/src/app/app-routing.module.ts b/ui-src/src/app/app-routing.module.ts index b23fe76..a059487 100644 --- a/ui-src/src/app/app-routing.module.ts +++ b/ui-src/src/app/app-routing.module.ts @@ -8,7 +8,7 @@ import { TestSuitesComponent } from "./test-suites/test-suites.component"; const routes: Routes = [ { path: "", redirectTo: "/configurations", pathMatch: "full" }, { path: "configurations", component: ConfigurationsComponent }, - // { path: "test-cases", component: TestCasesComponent }, + { path: "test-cases", component: TestCasesComponent }, { path: "test-suites", component: TestSuitesComponent } ]; diff --git a/ui-src/src/app/app.module.ts b/ui-src/src/app/app.module.ts index 0183a11..f2f3525 100644 --- a/ui-src/src/app/app.module.ts +++ b/ui-src/src/app/app.module.ts @@ -9,16 +9,22 @@ import { AppRoutingModule } from "./app-routing.module"; import { JsonSchemaFormModule } from "angular2-json-schema-form"; import { ConfigurationsComponent } from "./configurations/configurations.component"; import { ToastModule } from "ng2-toastr/ng2-toastr"; -import { AutomatedUIServices } from "./automated-ui-services"; +import { ConfigurationService } from "./configurations/configuration.service"; +import { TestCaseService } from "./test-cases/test-case.service"; +import { TestSuiteService } from "./test-suites/test-suite.service"; import { HttpClientModule, HttpClient } from "@angular/common/http"; import { FormsModule } from "@angular/forms"; +import { TestCasesSelectionComponent } from './shared/test-cases-selection/test-cases-selection.component'; +import { TestCasesListComponent } from './shared/test-cases-list/test-cases-list.component'; @NgModule({ declarations: [ AppComponent, TestCasesComponent, TestSuitesComponent, - ConfigurationsComponent + ConfigurationsComponent, + TestCasesSelectionComponent, + TestCasesListComponent ], imports: [ FormsModule, @@ -30,7 +36,7 @@ import { FormsModule } from "@angular/forms"; AppRoutingModule, HttpClientModule ], - providers: [AutomatedUIServices], + providers: [ConfigurationService, TestCaseService, TestSuiteService], bootstrap: [AppComponent] }) export class AppModule { } diff --git a/ui-src/src/app/automated-ui-services.ts b/ui-src/src/app/automated-ui-services.ts deleted file mode 100644 index b0e0159..0000000 --- a/ui-src/src/app/automated-ui-services.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { Injectable } from "@angular/core"; -import { HttpModule } from "@angular/http"; -import { Http } from "@angular/http"; -import { HttpClient, HttpHeaders } from "@angular/common/http"; -import { ConfigurationsComponent } from "./configurations/configurations.component"; -import { Headers } from "@angular/http/src/headers"; -import { Observable } from "rxjs/Observable"; -import { environment } from "../environments/environment.prod"; -import { $ } from "protractor"; -import { TestSuitesComponent } from "./test-suites/test-suites.component"; - -@Injectable() -export class AutomatedUIServices { - private headers: HttpHeaders; - constructor(private http: HttpClient) { - this.headers = new HttpHeaders({ "Content-Type": "application/json" }); - } - - postConfig$(configData, configPath): Observable { - this.headers = this.headers.set("configPathDir", configPath); - return this.http.post(`${environment.apiBaseUrl}configs`, configData, { - headers: this.headers - }); - - - } - getConfig$(configPath, xmlFileName): Observable { - this.headers = this.headers.set("configPathDir", configPath); - return this.http.get(`${environment.apiBaseUrl}configs/${xmlFileName}`, { - headers: this.headers - }); - } - putConfig$(configData, configPath, xmlFileName): Observable { - this.headers = this.headers.set("configPathDir", configPath); - return this.http.put( - `${environment.apiBaseUrl}configs/${xmlFileName}`, - configData, - { headers: this.headers } - ); - } - getSchema$(location: string): Observable { - return this.http - .get(`${environment.apiBaseUrl}${location}`, { headers: this.headers }) - .map((data: any) => data); - } - - - postTestSuite$(testSuiteData, testSuitePath): Observable { - this.headers = this.headers.set("testSuitePathDir", testSuitePath); - return this.http.post(`${environment.apiBaseUrl}test-suites`, testSuiteData, { - headers: this.headers - }); - } - - getTestSuite$(testSuitePath, testSuiteFileName): Observable { - this.headers = this.headers.set("testSuitePathDir", testSuitePath); - return this.http.get(`${environment.apiBaseUrl}test-suites/${testSuiteFileName}`, { - headers: this.headers - }); - } - - - getAllTestCases$(testCasesPath): Observable { - this.headers = this.headers.set("testSuitePathDir", testCasesPath); - return this.http.get(`${environment.apiBaseUrl}test-suites` + '/a/a', { - headers: this.headers - }); - } - - getAllTestSuite$(testSuitePath): Observable { - this.headers = this.headers.set("testSuitePathDir", testSuitePath); - return this.http.get(`${environment.apiBaseUrl}test-suites`, { - headers: this.headers - }); - } - - - putTestSuite$(testSuiteData, testSuitePath, testSuiteFileName): Observable { - this.headers = this.headers.set("testSuitePathDir", testSuitePath); - return this.http.put( - `${environment.apiBaseUrl}test-suites/${testSuiteFileName}`, - testSuiteData, - { headers: this.headers } - ); - } - - -} diff --git a/ui-src/src/app/automated-ui-services.spec.ts b/ui-src/src/app/configurations/configuration.service.spec.ts similarity index 82% rename from ui-src/src/app/automated-ui-services.spec.ts rename to ui-src/src/app/configurations/configuration.service.spec.ts index 803952c..3d3fa16 100644 --- a/ui-src/src/app/automated-ui-services.spec.ts +++ b/ui-src/src/app/configurations/configuration.service.spec.ts @@ -1,15 +1,15 @@ -import {TestBed, inject, getTestBed} from "@angular/core/testing"; +import {TestBed, inject, getTestBed} from '@angular/core/testing'; import {HttpClientModule} from "@angular/common/http"; -import {AutomatedUIServices} from "./automated-ui-services"; -import { HttpClient, HttpHeaders } from "@angular/common/http"; -import {environment} from "../environments/environment.prod"; +import {HttpClient, HttpHeaders} from "@angular/common/http"; +import {environment} from "../../environments/environment.prod"; import { HttpClientTestingModule, HttpTestingController } from "@angular/common/http/testing"; -describe("AutomatedUIServices", () => { +import {ConfigurationService} from './configuration.service'; +describe('ConfigurationService', () => { let injector; let service; let httpInterceptor: HttpTestingController; @@ -17,11 +17,11 @@ describe("AutomatedUIServices", () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientModule, HttpClientTestingModule], - providers: [AutomatedUIServices] + providers: [ConfigurationService] }); injector = getTestBed(); - service = injector.get(AutomatedUIServices); + service = injector.get(ConfigurationService); httpInterceptor = injector.get(HttpTestingController); }); @@ -40,7 +40,7 @@ describe("AutomatedUIServices", () => { const req = httpInterceptor.expectOne(`${environment.apiBaseUrl}configs`); expect(req.request.method).toBe("POST"); expect(req.request.headers.getAll).toBe(headers.getAll); - expect(req.request.body).toEqual({ data: "data1" }); + expect(req.request.body).toEqual({data: "data1"}); req.flush({}); }); @@ -55,7 +55,7 @@ describe("AutomatedUIServices", () => { const req = httpInterceptor.expectOne(`${environment.apiBaseUrl}configs/fileName.xml`); expect(req.request.method).toBe("PUT"); expect(req.request.headers.getAll).toBe(headers.getAll); - expect(req.request.body).toEqual({ data: "data1" }); + expect(req.request.body).toEqual({data: "data1"}); req.flush({}); }); diff --git a/ui-src/src/app/configurations/configuration.service.ts b/ui-src/src/app/configurations/configuration.service.ts new file mode 100644 index 0000000..2afa590 --- /dev/null +++ b/ui-src/src/app/configurations/configuration.service.ts @@ -0,0 +1,45 @@ +import {Injectable} from "@angular/core"; +import {HttpClient, HttpHeaders} from "@angular/common/http"; +import {ConfigurationsComponent} from "./configurations.component"; +import {Observable} from "rxjs/Observable"; +import {environment} from "../../environments/environment.prod"; + + +@Injectable() +export class ConfigurationService { + private headers: HttpHeaders; + constructor(private http: HttpClient) { + this.headers = new HttpHeaders({"Content-Type": "application/json"}); + } + + postConfig$(configData, configPath): Observable { + this.headers = this.headers.set("configPathDir", configPath); + return this.http.post(`${environment.apiBaseUrl}configs`, configData, { + headers: this.headers + }); + + + } + + getConfig$(configPath, xmlFileName): Observable { + this.headers = this.headers.set("configPathDir", configPath); + return this.http.get(`${environment.apiBaseUrl}configs/${xmlFileName}`, { + headers: this.headers + }); + } + + putConfig$(configData, configPath, xmlFileName): Observable { + this.headers = this.headers.set("configPathDir", configPath); + return this.http.put( + `${environment.apiBaseUrl}configs/${xmlFileName}`, + configData, + {headers: this.headers} + ); + } + + getSchema$(location: string): Observable { + return this.http + .get(`http://localhost:4200/${location}`, {headers: this.headers}) + .map((data: any) => data); + } +} diff --git a/ui-src/src/app/configurations/configurations.component.ts b/ui-src/src/app/configurations/configurations.component.ts index 29c50a6..822d573 100644 --- a/ui-src/src/app/configurations/configurations.component.ts +++ b/ui-src/src/app/configurations/configurations.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from "@angular/core"; import { HttpClient } from "@angular/common/http"; -import { AutomatedUIServices } from "../automated-ui-services"; +import { ConfigurationService } from "./configuration.service"; import { JsonSchemaFormModule } from "angular2-json-schema-form"; import { ToastsManager } from "ng2-toastr/ng2-toastr"; import "rxjs/add/operator/map"; @@ -19,14 +19,14 @@ export class ConfigurationsComponent implements OnInit { configSchema = { layout: true }; constructor( - private automatedUIServices: AutomatedUIServices, + private configurationService: ConfigurationService, private toastr: ToastsManager, private http: HttpClient ) {} ngOnInit() { - this.automatedUIServices + this.configurationService .getSchema$("assets/schema.json") .subscribe((data: any) => { this.configSchema = data; @@ -34,7 +34,7 @@ export class ConfigurationsComponent implements OnInit { } onSubmit(configData) { - this.automatedUIServices.postConfig$(configData, this.configPath).subscribe( + this.configurationService.postConfig$(configData, this.configPath).subscribe( data => { this.toastr.success("Your data has been saved!", "Success!"); }, @@ -65,7 +65,7 @@ export class ConfigurationsComponent implements OnInit { } onCancel() { - this.automatedUIServices + this.configurationService .getConfig$(this.configPath, this.xmlFileName) .subscribe( data => { @@ -97,7 +97,7 @@ export class ConfigurationsComponent implements OnInit { this.xmlFileName = undefined; } onGetFile() { - this.automatedUIServices + this.configurationService .getConfig$(this.configPath, this.xmlFileName) .subscribe( data => { @@ -132,7 +132,7 @@ export class ConfigurationsComponent implements OnInit { ); } onUpdate(configData) { - this.automatedUIServices + this.configurationService .putConfig$(this.formData, this.configPath, this.xmlFileName) .subscribe( data => { diff --git a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.css b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.css new file mode 100644 index 0000000..b7f71fd --- /dev/null +++ b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.css @@ -0,0 +1,13 @@ +.sortable-wrapper{ + +} + +.place-holder-test-case{ + +} + +.sortable-item{ +} +.sortable-item-active{ + +} \ No newline at end of file diff --git a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html new file mode 100644 index 0000000..a5c58fe --- /dev/null +++ b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html @@ -0,0 +1,14 @@ +
+ + + + + + + + + + + +
Name DescriptionHttp Method
{{testCase.name}}{{testCase.description}}{{testCase.httpMethod}}
+
diff --git a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.spec.ts b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.spec.ts new file mode 100644 index 0000000..b0aca10 --- /dev/null +++ b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TestCasesListComponent } from './test-cases-list.component'; + +describe('TestCasesListComponent', () => { + let component: TestCasesListComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ TestCasesListComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(TestCasesListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts new file mode 100644 index 0000000..41e2255 --- /dev/null +++ b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts @@ -0,0 +1,18 @@ + +import { + Component, + Input, + Output, + EventEmitter +} from '@angular/core'; + +@Component({ + selector: 'test-cases-list', + templateUrl: './test-cases-list.component.html', + styleUrls: ['./test-cases-list.component.css'] +}) +export class TestCasesListComponent { + + @Input() testCases; + +} diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.css b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.css new file mode 100644 index 0000000..e69de29 diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html new file mode 100644 index 0000000..983c559 --- /dev/null +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html @@ -0,0 +1,19 @@ +
+
+

Available

+ +
+
+ + + + + +
+
+

Selected

+ +
+
+ +
{{allTestCases |json}}
\ No newline at end of file diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.spec.ts b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.spec.ts new file mode 100644 index 0000000..7d2fee3 --- /dev/null +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TestCasesSelectionComponent } from './test-cases-selection.component'; + +describe('TestCasesSelectionComponent', () => { + let component: TestCasesSelectionComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ TestCasesSelectionComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(TestCasesSelectionComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts new file mode 100644 index 0000000..3b9bf22 --- /dev/null +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts @@ -0,0 +1,42 @@ +import { Component, OnInit, Input } from '@angular/core'; +import {TestCaseService} from '../../test-cases/test-case.service' +@Component({ + selector: 'test-cases-selection', + templateUrl: './test-cases-selection.component.html', + styleUrls: ['./test-cases-selection.component.css'] +}) +export class TestCasesSelectionComponent implements OnInit { + + @Input() testSuiteDirPath; + availableTestCases = []; + allTestCases = this.availableTestCases; + selectedTestCases = []; + + + constructor( + private testCaseService: TestCaseService + ) {} + + ngOnInit() { + this.testCaseService.getAllTestCases$(this.testSuiteDirPath).subscribe( (data) => { + this.availableTestCases = data; + this.allTestCases = data; + }); + } + + selectOne(){ + + } + + deSelectOne(){ + + } + + selectAll(){ + + } + selectNone(){ + + } + +} diff --git a/ui-src/src/app/test-cases/test-case.service.spec.ts b/ui-src/src/app/test-cases/test-case.service.spec.ts new file mode 100644 index 0000000..50f742d --- /dev/null +++ b/ui-src/src/app/test-cases/test-case.service.spec.ts @@ -0,0 +1,15 @@ +import { TestBed, inject } from '@angular/core/testing'; + +import { TestCaseService } from './test-case.service'; + +describe('TestCaseService', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [TestCaseService] + }); + }); + + it('should be created', inject([TestCaseService], (service: TestCaseService) => { + expect(service).toBeTruthy(); + })); +}); diff --git a/ui-src/src/app/test-cases/test-case.service.ts b/ui-src/src/app/test-cases/test-case.service.ts new file mode 100644 index 0000000..c6861dc --- /dev/null +++ b/ui-src/src/app/test-cases/test-case.service.ts @@ -0,0 +1,21 @@ +import {Injectable} from '@angular/core'; +import {HttpClient, HttpHeaders} from "@angular/common/http"; +import {TestCasesComponent} from "./test-cases.component"; +import {Observable} from "rxjs/Observable"; +import {environment} from "../../environments/environment.prod"; + +@Injectable() +export class TestCaseService { + + private headers: HttpHeaders; + constructor(private http: HttpClient) { + this.headers = new HttpHeaders({"Content-Type": "application/json"}); + } + + getAllTestCases$(testCasesPath): Observable { + this.headers = this.headers.set("testSuitePathDir", testCasesPath); + return this.http.get(`${environment.apiBaseUrl}test-suites` + '/a/a', { + headers: this.headers + }); + } +} diff --git a/ui-src/src/app/test-suites/test-suite.service.spec.ts b/ui-src/src/app/test-suites/test-suite.service.spec.ts new file mode 100644 index 0000000..a5954a6 --- /dev/null +++ b/ui-src/src/app/test-suites/test-suite.service.spec.ts @@ -0,0 +1,15 @@ +import { TestBed, inject } from '@angular/core/testing'; + +import { TestSuiteService } from './test-suite.service'; + +describe('TestSuiteService', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [TestSuiteService] + }); + }); + + it('should be created', inject([TestSuiteService], (service: TestSuiteService) => { + expect(service).toBeTruthy(); + })); +}); diff --git a/ui-src/src/app/test-suites/test-suite.service.ts b/ui-src/src/app/test-suites/test-suite.service.ts new file mode 100644 index 0000000..e9f5356 --- /dev/null +++ b/ui-src/src/app/test-suites/test-suite.service.ts @@ -0,0 +1,45 @@ +import {Injectable} from '@angular/core'; +import {HttpClient, HttpHeaders} from "@angular/common/http"; +import {TestSuitesComponent} from "./test-suites.component"; +import {Observable} from "rxjs/Observable"; +import {environment} from "../../environments/environment.prod"; + +@Injectable() +export class TestSuiteService { + + private headers: HttpHeaders; + constructor(private http: HttpClient) { + this.headers = new HttpHeaders({"Content-Type": "application/json"}); + } + + postTestSuite$(testSuiteData, testSuitePath): Observable { + this.headers = this.headers.set("testSuitePathDir", testSuitePath); + return this.http.post(`${environment.apiBaseUrl}test-suites`, testSuiteData, { + headers: this.headers + }); + } + + getTestSuite$(testSuitePath, testSuiteFileName): Observable { + this.headers = this.headers.set("testSuitePathDir", testSuitePath); + return this.http.get(`${environment.apiBaseUrl}test-suites/${testSuiteFileName}`, { + headers: this.headers + }); + } + + getAllTestSuite$(testSuitePath): Observable { + this.headers = this.headers.set("testSuitePathDir", testSuitePath); + return this.http.get(`${environment.apiBaseUrl}test-suites`, { + headers: this.headers + }); + } + + + putTestSuite$(testSuiteData, testSuitePath, testSuiteFileName): Observable { + this.headers = this.headers.set("testSuitePathDir", testSuitePath); + return this.http.put( + `${environment.apiBaseUrl}test-suites/${testSuiteFileName}`, + testSuiteData, + {headers: this.headers} + ); + } +} diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index 0a3a1b2..f46599b 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -1,14 +1,14 @@
-
+
-
- +
+ +
-
- - - -
- - -

Available

- - - - - - - - - - - - -
Name DescriptionHttp Method
{{testCase.name}}{{testCase.description}}{{testCase.httpMethod}}
-
-
- - - - -
-
- -

Selected

- - - - - - - - - - - -
Name DescriptionHttp Method
{{testCase.name}}{{testCase.description}}{{testCase.httpMethod}}
-
-
+
diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index bc5bdf9..5f49c71 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -1,95 +1,90 @@ import { Component, OnInit } from "@angular/core"; -import { AutomatedUIServices } from "../automated-ui-services"; +import { TestSuiteService } from "./test-suite.service"; +import { TestCaseService } from "../test-cases/test-case.service"; import { ToastsManager } from "ng2-toastr/ng2-toastr"; +const TEST_SUITE_PATH = '/Users/a505230/code/go/src/github.com/xtracdev/automated-perf-test/config'; @Component({ selector: "app-test-suites", templateUrl: "./test-suites.component.html", styleUrls: ["./test-suites.component.css"] }) export class TestSuitesComponent { + + + testSuitePath = TEST_SUITE_PATH + + testSuiteData = []; testCaseData = []; testCaseArray = []; formData = {}; selectedTestCaseData = []; - testSuitePath = undefined; testSuiteFileName = undefined; testSuiteSchema = { layout: true }; constructor( - private automatedUIServices: AutomatedUIServices, + private testSuiteService: TestSuiteService, + private testCaseService: TestCaseService, private toastr: ToastsManager ) {} - ngOnInit() { - this.automatedUIServices - .getSchema$("assets/testSuite_schema.json") - .subscribe((data: any) => { - this.testSuiteSchema = data; - }); - } - - selectedCase(testCase) { - this.selectedTestCaseData.push(testCase); - this.testCaseArray["testCases"] = this.selectedTestCaseData; - } + // selectedCase(testCase) { + // this.selectedTestCaseData.push(testCase); + // this.testCaseArray["testCases"] = this.selectedTestCaseData; + // } onAdd() { - this.automatedUIServices.getAllTestSuite$(this.testSuitePath).subscribe( - data => { - this.formData = data; - this.toastr.success("Your data has been saved!", "Success!"); - }, + // this.testSuiteService.getAllTestSuite$(TEST_SUITE_PATH).subscribe( + // data => { + // this.formData = data; + // this.toastr.success("Your data has been saved!", "Success!"); + // }, - error => { - switch (error.status) { - case 500: { - this.toastr.error("An error has occurred!", "Check the logs!"); - break; - } - case 400: { - this.toastr.error( - "No Test Suite Directory added", - "An error occurred!" - ); - break; - } - default: { - this.toastr.error("An error occurred!"); - } - } - } - ); + // error => { + // switch (error.status) { + // case 500: { + // this.toastr.error("An error has occurred!", "Check the logs!"); + // break; + // } + // case 400: { + // this.toastr.error( + // "No Test Suite Directory added", + // "An error occurred!" + // ); + // break; + // } + // default: { + // this.toastr.error("An error occurred!"); + // } + // } + // } + // ); } getTestCases() { - this.automatedUIServices - .getAllTestCases$(this.testSuitePath) - .subscribe((data: any) => { - this.testCaseData = data; - }); + // this.testCaseService.getAllTestCases$(TEST_SUITE_PATH) + // .subscribe((data: any) => this.testCases = data); } onDelete() {} onCancel() { //clear schema and moving info back into available (get method) - this.automatedUIServices - .getTestSuite$(this.testSuitePath, this.testSuiteFileName) - .subscribe( - data => { - this.testSuiteData = data; - this.toastr.success("Previous data reloaded!"); - }, - error => { - this.testSuiteData = undefined; - } - ); + // this.testSuiteService.getTestSuite$(TEST_SUITE_PATH, this.testSuiteFileName) + // .subscribe( + // data => { + // this.testSuiteData = data; + // this.toastr.success("Previous data reloaded!"); + // }, + // error => { + // this.testSuiteData = undefined; + // } + // ); } onSave(data) { Object.assign(data, this.testCaseArray); - this.automatedUIServices.postTestSuite$(data, this.testSuitePath).subscribe( + this.testSuiteService.postTestSuite$(data, TEST_SUITE_PATH).subscribe( data => { this.toastr.success("Your data has been saved!", "Success!"); }, @@ -120,8 +115,8 @@ export class TestSuitesComponent { } onSelectAll() { - this.automatedUIServices - .getAllTestCases$(this.testSuitePath) + this.testCaseService + .getAllTestCases$(TEST_SUITE_PATH) .subscribe((data: any) => { this.selectedTestCaseData = data; this.testCaseArray["testCases"] = this.selectedTestCaseData; diff --git a/uiServices/src/configServices.go b/uiServices/src/configServices.go index 33409a7..da51b98 100644 --- a/uiServices/src/configServices.go +++ b/uiServices/src/configServices.go @@ -50,6 +50,7 @@ func ConfigCtx(next http.Handler) http.Handler { } func postConfigs(rw http.ResponseWriter, req *http.Request) { + rw.Header().Set("Access-Control-Allow-Origin", "*") configPathDir := req.Header.Get("configPathDir") buf := new(bytes.Buffer) buf.ReadFrom(req.Body) @@ -108,7 +109,7 @@ func FilePathExist(path string) bool { } func getConfigs(rw http.ResponseWriter, req *http.Request) { - + rw.Header().Set("Access-Control-Allow-Origin", "*") configPathDir := getConfigHeader(req) configName := chi.URLParam(req, "configName") @@ -155,6 +156,7 @@ func getConfigs(rw http.ResponseWriter, req *http.Request) { } func putConfigs(rw http.ResponseWriter, req *http.Request) { + rw.Header().Set("Access-Control-Allow-Origin", "*") path := getConfigHeader(req) configName := chi.URLParam(req, "configName") diff --git a/uiServices/src/homepage.go b/uiServices/src/homepage.go index 68f3059..f979a72 100644 --- a/uiServices/src/homepage.go +++ b/uiServices/src/homepage.go @@ -8,6 +8,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" + "github.com/go-chi/cors" "os" ) @@ -21,6 +22,16 @@ func StartUiMode() { func GetRouter() *chi.Mux { r := chi.NewRouter() + cors := cors.New(cors.Options{ + AllowedOrigins: []string{"*"}, + AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, + AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"}, + ExposedHeaders: []string{"Link"}, + AllowCredentials: true, + MaxAge: 300, + }) + + r.Use(cors.Handler) r.Use(middleware.Logger) r.Use(middleware.Recoverer) @@ -61,7 +72,6 @@ func GetIndexPage() *chi.Mux { router.Mount("/configs", routeConfigs()) router.Mount("/test-suites/a/a", routeTestCases()) router.Mount("/test-suites", routeTestSuites()) - router.Get("/*", func(w http.ResponseWriter, r *http.Request) { @@ -127,4 +137,4 @@ func routeTestCases() http.Handler { router.Get("/{testCaseName}", getTestCase) return router -} \ No newline at end of file +} diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index 6f9202c..db03dd9 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -10,18 +10,19 @@ import ( "os" "path/filepath" "strings" + "github.com/Sirupsen/logrus" - "github.com/xtracdev/automated-perf-test/testStrategies" "github.com/go-chi/chi" + "github.com/xtracdev/automated-perf-test/testStrategies" ) type Case struct { - HttpMethod string `json:"httpMethod"` - Name string `json:"name"` - Description string `json:"description"` - PreThinkTime int64 `json:"preThinkTime"` - PostThinkTime int64 `json:"postThinkTime"` - ExecWeight string `json:"execWeight"` + HttpMethod string `json:"httpMethod"` + Name string `json:"name"` + Description string `json:"description"` + PreThinkTime int64 `json:"preThinkTime"` + PostThinkTime int64 `json:"postThinkTime"` + ExecWeight string `json:"execWeight"` } func TestCaseCtx(next http.Handler) http.Handler { @@ -40,7 +41,7 @@ func getTestCaseHeader(req *http.Request) string { } func getAllTestCases(rw http.ResponseWriter, req *http.Request) { - + rw.Header().Set("Access-Control-Allow-Origin", "*") testCasePathDir := getTestCaseHeader(req) if len(testCasePathDir) <= 1 { logrus.Error("No file directory entered") @@ -56,7 +57,7 @@ func getAllTestCases(rw http.ResponseWriter, req *http.Request) { testCases := make([]Case, 0) for _, file := range files { - if filepath.Ext(testCasePathDir +file.Name()) == ".xml" { + if filepath.Ext(testCasePathDir+file.Name()) == ".xml" { testCase := new(testStrategies.TestDefinition) @@ -81,20 +82,19 @@ func getAllTestCases(rw http.ResponseWriter, req *http.Request) { //if a Test Case Name can't be assigned, it isn't a Test Case object if testCase.TestName != "" { testCases = append(testCases, Case{ - Name: testCase.TestName, - Description: testCase.Description, - HttpMethod: testCase.HTTPMethod, + Name: testCase.TestName, + Description: testCase.Description, + HttpMethod: testCase.HTTPMethod, PostThinkTime: testCase.PostThinkTime, - PreThinkTime: testCase.PreThinkTime, - ExecWeight: testCase.ExecWeight, - + PreThinkTime: testCase.PreThinkTime, + ExecWeight: testCase.ExecWeight, }) } } } err = json.NewEncoder(rw).Encode(testCases) - if err != nil{ + if err != nil { logrus.Error("Could not enocde Test Cases") rw.WriteHeader(http.StatusInternalServerError) return @@ -104,7 +104,7 @@ func getAllTestCases(rw http.ResponseWriter, req *http.Request) { } func getTestCase(rw http.ResponseWriter, req *http.Request) { - + rw.Header().Set("Access-Control-Allow-Origin", "*") testCasePathDir := getTestCaseHeader(req) testCaseName := chi.URLParam(req, "testCaseName") @@ -144,4 +144,4 @@ func getTestCase(rw http.ResponseWriter, req *http.Request) { rw.WriteHeader(http.StatusOK) rw.Write(testSuiteJSON) -} \ No newline at end of file +} diff --git a/uiServices/src/testSuiteServices.go b/uiServices/src/testSuiteServices.go index 19aa479..5939cd3 100644 --- a/uiServices/src/testSuiteServices.go +++ b/uiServices/src/testSuiteServices.go @@ -43,6 +43,7 @@ func getTestSuiteHeader(req *http.Request) string { } func postTestSuites(rw http.ResponseWriter, req *http.Request) { + rw.Header().Set("Access-Control-Allow-Origin", "*") testSuitePathDir := getTestSuiteHeader(req) buf := new(bytes.Buffer) buf.ReadFrom(req.Body) @@ -109,6 +110,7 @@ func ValidateJsonWithSchema(testSuite []byte, schemaName, structType string) boo } func putTestSuites(rw http.ResponseWriter, req *http.Request) { + rw.Header().Set("Access-Control-Allow-Origin", "*") path := getTestSuiteHeader(req) testSuiteName := chi.URLParam(req, "testSuiteName") @@ -150,7 +152,7 @@ func putTestSuites(rw http.ResponseWriter, req *http.Request) { } func getTestSuite(rw http.ResponseWriter, req *http.Request) { - + rw.Header().Set("Access-Control-Allow-Origin", "*") testSuitePathDir := getTestSuiteHeader(req) testSuiteName := chi.URLParam(req, "testSuiteName") @@ -193,7 +195,7 @@ func getTestSuite(rw http.ResponseWriter, req *http.Request) { } func getAllTestSuites(rw http.ResponseWriter, req *http.Request) { - + rw.Header().Set("Access-Control-Allow-Origin", "*") testSuitePathDir := getTestSuiteHeader(req) if len(testSuitePathDir) <= 1 { logrus.Error("No file directory entered") From f74a40af6ed2f76f0328911af2487c3ae5b834b9 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Wed, 28 Feb 2018 16:45:03 +0000 Subject: [PATCH 23/82] get all method from ui --- config/TestCase.xml | 63 +++++++++ config/TestCase222.xml | 63 +++++++++ ui-src/src/app/automated-ui-services.ts | 10 +- .../configurations.component.html | 6 +- .../configurations.component.ts | 132 ++++++++++-------- .../app/test-cases/test-cases.component.css | 37 +++++ .../app/test-cases/test-cases.component.html | 39 +++++- .../app/test-cases/test-cases.component.ts | 59 +++++++- 8 files changed, 342 insertions(+), 67 deletions(-) create mode 100644 config/TestCase.xml create mode 100644 config/TestCase222.xml diff --git a/config/TestCase.xml b/config/TestCase.xml new file mode 100644 index 0000000..a7c9d3e --- /dev/null +++ b/config/TestCase.xml @@ -0,0 +1,63 @@ + + + + +TestCase + +host + +9191 + +GET + +desc + +path/to/URI + +false + +payload + + + + + + + +F-Name + +PayloadName + +file-name + + + + + + + +200 + +JSON + + + + +
Header-Value
+ +
+ + + + +Res-Value + + + +1000 + +2000 + +Sparse + +
\ No newline at end of file diff --git a/config/TestCase222.xml b/config/TestCase222.xml new file mode 100644 index 0000000..f9cf8b1 --- /dev/null +++ b/config/TestCase222.xml @@ -0,0 +1,63 @@ + + + + +Test222 + +host2222 + +91912222 + +PUT + +desc222 + +path/to/URI22 + +false + +payload22 + + + + + + + +F-Name2 + +PayloadName + +file-name + + + + + + + +200 + +JSON + + + + +
Header-Value
+ +
+ + + + +Res-Value + + + +14 + +44 + +Sparse + +
\ No newline at end of file diff --git a/ui-src/src/app/automated-ui-services.ts b/ui-src/src/app/automated-ui-services.ts index 8cadf9e..576a33c 100644 --- a/ui-src/src/app/automated-ui-services.ts +++ b/ui-src/src/app/automated-ui-services.ts @@ -24,7 +24,7 @@ export class AutomatedUIServices { } getConfig$(configPath, xmlFileName): Observable { - this.headers = this.headers.set("configPathDir", configPath); + this.headers = this.headers.set("configPathDir", configPath); return this.http.get(`${environment.apiBaseUrl}configs/${xmlFileName}`, { headers: this.headers }); @@ -42,4 +42,12 @@ export class AutomatedUIServices { .get(`${environment.apiBaseUrl}${location}`, { headers: this.headers }) .map((data: any) => data); } + + getAllCases$(testCasePath): Observable { + this.headers = this.headers.set("testCasePathDir", testCasePath); + return this.http.get(`${environment.apiBaseUrl}test-cases`, { + headers: this.headers + }); + } + } diff --git a/ui-src/src/app/configurations/configurations.component.html b/ui-src/src/app/configurations/configurations.component.html index 31521e0..9d47c5d 100644 --- a/ui-src/src/app/configurations/configurations.component.html +++ b/ui-src/src/app/configurations/configurations.component.html @@ -7,14 +7,16 @@
- +
- + diff --git a/ui-src/src/app/configurations/configurations.component.ts b/ui-src/src/app/configurations/configurations.component.ts index cc8ad23..2f3bfb1 100644 --- a/ui-src/src/app/configurations/configurations.component.ts +++ b/ui-src/src/app/configurations/configurations.component.ts @@ -23,7 +23,7 @@ export class ConfigurationsComponent implements OnInit { private toastr: ToastsManager, private http: HttpClient - ) {} + ) { } ngOnInit() { this.automatedUIServices @@ -68,87 +68,95 @@ export class ConfigurationsComponent implements OnInit { this.automatedUIServices .getConfig$(this.configPath, this.xmlFileName) .subscribe( - data => { - this.formData = data; - this.toastr.success("Previous data reloaded!"); - }, - error => { - this.configPath = undefined; - this.xmlFileName = undefined; - this.formData = undefined; - } + data => { + this.formData = data; + this.toastr.success("Previous data reloaded!"); + }, + error => { + this.configPath = undefined; + this.xmlFileName = undefined; + this.formData = undefined; + } ); } + fileSelector(event) { - this.fileName = event.srcElement.files[0].name; - this.xmlFileName = this.fileName; + this.fileName  =  event.srcElement.files[0].name; + this.xmlFileName  =  this.fileName; + this.xmlFileName  =  this.xmlFileName.substring( + 0, + this.xmlFileName.length  -  4); + this.onGetFile(); + (document.getElementById("file")).value  = ""; } + + onGetFile() { this.automatedUIServices .getConfig$(this.configPath, this.xmlFileName) .subscribe( - data => { - this.formData = data; - this.toastr.success("Success!"); - }, - error => { - switch (error.status) { - case 404: { - this.toastr.error("File not found!", "An error occured!"); - break; - } - case 400: { - this.toastr.error( - "Check your field inputs", - "An error occurred!" - ); - break; - } - case 500: { - this.toastr.error("An error has occurred!", "Check the logs!"); - break; - } - default: { - this.toastr.error( - "Your data was not retrieved!", - "An error occurred!" - ); - } + data => { + this.formData = data; + this.toastr.success("Success!"); + }, + error => { + switch (error.status) { + case 404: { + this.toastr.error("File not found!", "An error occured!"); + break; + } + case 400: { + this.toastr.error( + "Check your field inputs", + "An error occurred!" + ); + break; + } + case 500: { + this.toastr.error("An error has occurred!", "Check the logs!"); + break; + } + default: { + this.toastr.error( + "Your data was not retrieved!", + "An error occurred!" + ); } } + } ); } onUpdate(configData) { this.automatedUIServices .putConfig$(this.formData, this.configPath, this.xmlFileName) .subscribe( - data => { - this.toastr.success("Success!"); - }, - error => { - switch (error.status) { - case 404: { - this.toastr.error("File not found", "An error occured!"); - break; - } - case 400: { - this.toastr.error( - "File must be specified!", - "An error occurred!" - ); - break; - } - case 500: { - this.toastr.error("Internal server error!"); - break; - } - default: { - this.toastr.error("File was not updated!", "An error occurred!"); - } + data => { + this.toastr.success("Success!"); + }, + error => { + switch (error.status) { + case 404: { + this.toastr.error("File not found", "An error occured!"); + break; + } + case 400: { + this.toastr.error( + "File must be specified!", + "An error occurred!" + ); + break; + } + case 500: { + this.toastr.error("Internal server error!"); + break; + } + default: { + this.toastr.error("File was not updated!", "An error occurred!"); } } + } ); } } diff --git a/ui-src/src/app/test-cases/test-cases.component.css b/ui-src/src/app/test-cases/test-cases.component.css index 8b13789..36e3598 100644 --- a/ui-src/src/app/test-cases/test-cases.component.css +++ b/ui-src/src/app/test-cases/test-cases.component.css @@ -1 +1,38 @@ +.row { + margin-top: 25px; + margin-bottom: 25px; + } + .button-row { margin-top: 25px;} + .column { + + padding: 0px; + } + + table { + + font-family: arial, sans-serif; + border-collapse: collapse; + width: 100%; + margin-bottom: 25px; + +} + +td, th { + border: 1px solid #dddddd; + text-align: left; + padding: 8px; +} + +tr:nth-child(even) { + background-color: #dddddd; +} + +.btn{ + margin-bottom: 25px; +} + +submit-widget{ + display : none; +} + diff --git a/ui-src/src/app/test-cases/test-cases.component.html b/ui-src/src/app/test-cases/test-cases.component.html index ec92454..9900cf3 100644 --- a/ui-src/src/app/test-cases/test-cases.component.html +++ b/ui-src/src/app/test-cases/test-cases.component.html @@ -1 +1,38 @@ -

test-cases works

\ No newline at end of file +
+
+ + +
+ + +
+ +
+ + + + + + + + + + + + + +
Name DescriptionHttp Method
{{testCase.name}}{{testCase.description}}{{testCase.httpMethod}}
+
+
+ + + + +
+ + +
+
+
+
\ No newline at end of file diff --git a/ui-src/src/app/test-cases/test-cases.component.ts b/ui-src/src/app/test-cases/test-cases.component.ts index 977b195..55fb28d 100644 --- a/ui-src/src/app/test-cases/test-cases.component.ts +++ b/ui-src/src/app/test-cases/test-cases.component.ts @@ -1,8 +1,65 @@ import { Component, OnInit } from "@angular/core"; +import { AutomatedUIServices } from "../automated-ui-services"; +import { ToastsManager } from "ng2-toastr/ng2-toastr"; +import { JsonSchemaFormModule } from "angular2-json-schema-form"; +import { HttpClient } from "@angular/common/http"; +import "rxjs/add/operator/map"; @Component({ selector: "app-test-cases", templateUrl: "./test-cases.component.html", styleUrls: ["./test-cases.component.css"] }) -export class TestCasesComponent {} +export class TestCasesComponent implements OnInit { + testCaseData = {}; + testCasePath = undefined; + testCaseSchema = { layout: true }; + + constructor( + private automatedUIServices: AutomatedUIServices, + private toastr: ToastsManager, + private http: HttpClient + ) { } + + ngOnInit() { + this.automatedUIServices + .getSchema$("assets/testCase_schema.json") + .subscribe((data: any) => { + this.testCaseSchema = data; + }); + } + + + onAdd() { + this.automatedUIServices.getAllCases$(this.testCasePath).subscribe( + (data: any) => { + this.testCaseData = data; + + this.toastr.success("Your data has been saved!", "Success!"); + }, + + error => { + switch (error.status) { + case 500: { + this.toastr.error("An error has occurred!", "Check the logs!"); + break; + } + case 400: { + this.toastr.error( + "No Test Suite Directory added", + "An error occurred!" + ); + break; + } + default: { + this.toastr.error("An error occurred!"); + } + } + } + ); + } + + onDelete() { } + onSave(testCaseData) { } + onCancel() { } +} From 20a30809f63dc00885f0dde6d7edd2d92062069c Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Wed, 28 Feb 2018 17:05:29 +0000 Subject: [PATCH 24/82] full schema --- ui-src/src/assets/testCase_schema.json | 89 ++++++++++++-------------- 1 file changed, 42 insertions(+), 47 deletions(-) diff --git a/ui-src/src/assets/testCase_schema.json b/ui-src/src/assets/testCase_schema.json index 401a5f0..2b01083 100644 --- a/ui-src/src/assets/testCase_schema.json +++ b/ui-src/src/assets/testCase_schema.json @@ -14,57 +14,48 @@ "postThinkTime", "execWeight", "Headers", - "ResponseValues", - "MultipartPayload" + "ResponseValues" ], "properties": { - "overridePort": { - "type": "string" - }, "testname": { "type": "string" }, "description": { "type": "string" }, - "overrideHost": { + "BaseURI": { "type": "string" }, - "HttpMethod": { - "type": "string", - "enum": ["POST","GET","PUT","DELETE"] - }, - "BaseURI": { + "overrideHost": { "type": "string" }, "multipart": { "type": "boolean" }, - "payload": { + "overridePort": { "type": "string" }, - "responseStatusCode": { - "type": "number" - }, - "responseContentType": { + "payload": { "type": "string" }, - "preThinkTime": { - "type": "number" - }, - "postThinkTime": { - "type": "number" - }, - "execWeight": { + "HttpMethod": { "type": "string", - "enum": ["Sparse","Infrequent"] + "enum": [ + "POST", + "GET", + "PUT", + "DELETE" + ] }, "Headers": { "type": "array", "items": { "type": "object", "additionalProperties": false, - "required": ["Key", "Value"], + "required": [ + "Key", + "Value" + ], "properties": { "Key": { "type": "string" @@ -75,39 +66,43 @@ } } }, + "preThinkTime": { + "type": "number" + }, + "postThinkTime": { + "type": "number" + }, + "execWeight": { + "type": "string", + "enum": [ + "Sparse", + "Infrequent" + ] + }, + "responseStatusCode": { + "type": "number" + }, + "responseContentType": { + "type": "string" + }, "ResponseValues": { "type": "array", "items": { "type": "object", "additionalProperties": false, - "required": ["Value", "ExtractionKey"], + "required": [ + "Value", + "ExtractionKey" + ], "properties": { - "Value": { + "ExtractionKey": { "type": "string" }, - "ExtractionKey": { + "Value": { "type": "string" } } - }, - "MultipartPayload": { - "type": "array", - "items": { - "type": "object", - "required": ["FieldName", "FieldValue","FileName", "FileContent"], - "properties": { - "fieldName": { - "type": "string" - }, - "FieldValue": { - "type": "string" - }, - "FileName": { - "type": "string" - } - } - } } } } -} +} \ No newline at end of file From bd723d43451bc4a4353e51dc0231086525674bce Mon Sep 17 00:00:00 2001 From: a586754 Date: Wed, 28 Feb 2018 17:17:56 +0000 Subject: [PATCH 25/82] Adding get Functioality --- config/config.xml | 4 +- .../test-cases-list.component.html | 2 +- .../test-cases-list.component.ts | 19 +++- .../test-cases-selection.component.html | 12 ++- .../test-cases-selection.component.ts | 29 +++--- .../src/app/test-suites/test-suite.service.ts | 6 +- .../test-suites/test-suites.component.html | 20 +++-- .../app/test-suites/test-suites.component.ts | 88 +++++++++++-------- 8 files changed, 113 insertions(+), 67 deletions(-) diff --git a/config/config.xml b/config/config.xml index ce3d74e..d0a2a86 100644 --- a/config/config.xml +++ b/config/config.xml @@ -2,7 +2,7 @@ config localhost 8080 - 1000 + 1066666 15 15 ./definitions/testCases @@ -12,7 +12,7 @@ 50 Default-1 /alt/debug/vars - 5000 + 5000 30 15 15 diff --git a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html index a5c58fe..9610751 100644 --- a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html +++ b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html @@ -5,7 +5,7 @@ Description Http Method - + {{testCase.name}} {{testCase.description}} {{testCase.httpMethod}} diff --git a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts index 41e2255..a994bdf 100644 --- a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts +++ b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts @@ -11,8 +11,25 @@ import { templateUrl: './test-cases-list.component.html', styleUrls: ['./test-cases-list.component.css'] }) -export class TestCasesListComponent { + +export class TestCasesListComponent { + testCaseArray = []; + selectedTestCaseData = []; @Input() testCases; + @Output() t = new EventEmitter(); + + + selectedCase(testCase) { + this.selectedTestCaseData.push(testCase); + this.testCaseArray = this.selectedTestCaseData; + console.log(this.testCaseArray) + this.t.emit(this.testCaseArray); + + } + changeValue() { + console.log("clicked") + this.t.emit("emit this value"); + } } diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html index 983c559..77b2f0f 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html @@ -1,19 +1,17 @@

Available

- +
- - + +

Selected

- +
-
- -
{{allTestCases |json}}
\ No newline at end of file +
\ No newline at end of file diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts index 3b9bf22..a45a1c3 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts @@ -1,5 +1,6 @@ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import {TestCaseService} from '../../test-cases/test-case.service' + @Component({ selector: 'test-cases-selection', templateUrl: './test-cases-selection.component.html', @@ -8,20 +9,19 @@ import {TestCaseService} from '../../test-cases/test-case.service' export class TestCasesSelectionComponent implements OnInit { @Input() testSuiteDirPath; - availableTestCases = []; - allTestCases = this.availableTestCases; - selectedTestCases = []; - - + @Input() availableTestCases; + @Input() t; + @Output() t1 = new EventEmitter(); +selectedTestCases = [] constructor( private testCaseService: TestCaseService ) {} ngOnInit() { - this.testCaseService.getAllTestCases$(this.testSuiteDirPath).subscribe( (data) => { - this.availableTestCases = data; - this.allTestCases = data; - }); + // this.testCaseService.getAllTestCases$(this.testSuiteDirPath).subscribe( (data) => { + // this.availableTestCases = data; + + // }); } selectOne(){ @@ -39,4 +39,13 @@ export class TestCasesSelectionComponent implements OnInit { } + onT(e) { + console.log("@@@") + this.selectedTestCases = e; + console.log(this.selectedTestCases) + console.log(this.availableTestCases) + console.log(e) + + } + } diff --git a/ui-src/src/app/test-suites/test-suite.service.ts b/ui-src/src/app/test-suites/test-suite.service.ts index e9f5356..55b5870 100644 --- a/ui-src/src/app/test-suites/test-suite.service.ts +++ b/ui-src/src/app/test-suites/test-suite.service.ts @@ -32,7 +32,11 @@ export class TestSuiteService { headers: this.headers }); } - + getSchema$(location: string): Observable { + return this.http + .get(`http://localhost:4200/${location}`, {headers: this.headers}) + .map((data: any) => data); + } putTestSuite$(testSuiteData, testSuitePath, testSuiteFileName): Observable { this.headers = this.headers.set("testSuitePathDir", testSuitePath); diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index f46599b..9b6c53c 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -1,14 +1,15 @@
- +
+
- -
+ +
+ +
+
+ + + +
- +
diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index 5f49c71..86a58e0 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -1,8 +1,8 @@ -import { Component, OnInit } from "@angular/core"; +import { Component, OnInit, Input } from "@angular/core"; import { TestSuiteService } from "./test-suite.service"; import { TestCaseService } from "../test-cases/test-case.service"; import { ToastsManager } from "ng2-toastr/ng2-toastr"; -const TEST_SUITE_PATH = '/Users/a505230/code/go/src/github.com/xtracdev/automated-perf-test/config'; +const TEST_SUITE_PATH = 'C:/Users/A586754/go/src/github.com/xtracdev/automated-perf-test/config'; @Component({ selector: "app-test-suites", templateUrl: "./test-suites.component.html", @@ -12,63 +12,73 @@ export class TestSuitesComponent { testSuitePath = TEST_SUITE_PATH - - - testSuiteData = []; - testCaseData = []; + testValue = []; + testSuiteData = {}; + testCases = []; testCaseArray = []; - formData = {}; + formData = []; selectedTestCaseData = []; testSuiteFileName = undefined; testSuiteSchema = { layout: true }; - + @Input() t1; + constructor( private testSuiteService: TestSuiteService, private testCaseService: TestCaseService, private toastr: ToastsManager ) {} + - // selectedCase(testCase) { - // this.selectedTestCaseData.push(testCase); - // this.testCaseArray["testCases"] = this.selectedTestCaseData; - // } + ngOnInit() { + this.testSuiteService + .getSchema$("assets/testSuite_schema.json") + .subscribe((data: any) => { + this.testSuiteSchema = data; + }); + } + selectedCase(testCase) { + this.selectedTestCaseData.push(testCase); + this.testCaseArray["testCases"] = this.selectedTestCaseData; + } onAdd() { - // this.testSuiteService.getAllTestSuite$(TEST_SUITE_PATH).subscribe( - // data => { - // this.formData = data; - // this.toastr.success("Your data has been saved!", "Success!"); - // }, + this.testSuiteService.getAllTestSuite$(TEST_SUITE_PATH).subscribe( + data => { + this.formData = data; + this.toastr.success("Your data has been saved!", "Success!"); + }, - // error => { - // switch (error.status) { - // case 500: { - // this.toastr.error("An error has occurred!", "Check the logs!"); - // break; - // } - // case 400: { - // this.toastr.error( - // "No Test Suite Directory added", - // "An error occurred!" - // ); - // break; - // } - // default: { - // this.toastr.error("An error occurred!"); - // } - // } - // } - // ); + error => { + switch (error.status) { + case 500: { + this.toastr.error("An error has occurred!", "Check the logs!"); + break; + } + case 400: { + this.toastr.error( + "No Test Suite Directory added", + "An error occurred!" + ); + break; + } + default: { + this.toastr.error("An error occurred!"); + } + } + } + ); } getTestCases() { - // this.testCaseService.getAllTestCases$(TEST_SUITE_PATH) - // .subscribe((data: any) => this.testCases = data); + this.testCaseService.getAllTestCases$(TEST_SUITE_PATH) + .subscribe((data: any) => this.testCases = data); } onDelete() {} - onCancel() { + onCancel(e) { + console.log("****",e); + //clear schema and moving info back into available (get method) // this.testSuiteService.getTestSuite$(TEST_SUITE_PATH, this.testSuiteFileName) // .subscribe( From d9df6385e36a044690da71a7de3263cdba96c407 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Wed, 28 Feb 2018 22:29:27 +0000 Subject: [PATCH 26/82] fixed typo error --- main.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index f165c89..65bea53 100644 --- a/main.go +++ b/main.go @@ -5,14 +5,15 @@ import ( "encoding/xml" "flag" "fmt" - log "github.com/Sirupsen/logrus" - "github.com/xtracdev/automated-perf-test/perfTestUtils" - "github.com/xtracdev/automated-perf-test/testStrategies" - "github.com/xtracdev/automated-perf-test/uiServices/src" "io/ioutil" "net/http" "os" "time" + + log "github.com/Sirupsen/logrus" + "github.com/xtracdev/automated-perf-test/perfTestUtils" + "github.com/xtracdev/automated-perf-test/testStrategies" + "github.com/xtracdev/automated-perf-test/uiServices/src" ) //----- Globals ------------------------------------------------------------------ @@ -147,7 +148,7 @@ func initConfig(args []string, fs perfTestUtils.FileSystem, exit func(code int)) // Start server for the User Interface Mode if uiMode { - services.StartUIMode() + services.StartUiMode() } setLogLevel(boolVerbose, boolDebug) From 6dc14f1cace0ae9d9dead1ca73b2f8de2c49373c Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Wed, 28 Feb 2018 23:01:41 +0000 Subject: [PATCH 27/82] post method on UI --- ui-src/src/app/automated-ui-services.ts | 9 ++++++ .../app/test-cases/test-cases.component.ts | 32 ++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/ui-src/src/app/automated-ui-services.ts b/ui-src/src/app/automated-ui-services.ts index 576a33c..30eb701 100644 --- a/ui-src/src/app/automated-ui-services.ts +++ b/ui-src/src/app/automated-ui-services.ts @@ -50,4 +50,13 @@ export class AutomatedUIServices { }); } + postTestCases$(testCaseData, testCasePath): Observable { + this.headers = this.headers.set("testCasePathDir", testCasePath); + return this.http.post(`${environment.apiBaseUrl}test-cases`, testCaseData, { + headers: this.headers + }); + + + } + } diff --git a/ui-src/src/app/test-cases/test-cases.component.ts b/ui-src/src/app/test-cases/test-cases.component.ts index 55fb28d..9f4099c 100644 --- a/ui-src/src/app/test-cases/test-cases.component.ts +++ b/ui-src/src/app/test-cases/test-cases.component.ts @@ -60,6 +60,36 @@ export class TestCasesComponent implements OnInit { } onDelete() { } - onSave(testCaseData) { } + + onSave(testCaseData) { + this.automatedUIServices.postTestCases$(testCaseData, this.testCasePath).subscribe( + data => { + this.toastr.success("Your data has been saved!", "Success!"); + }, + + error => { + switch (error.status) { + case 500: { + this.toastr.error("An error has occurred!", "Check the logs!"); + break; + } + case 409: { + this.toastr.error("File already exists!", "An error occurred!"); + break; + } + case 400: { + this.toastr.error( + "Some of the fields do not conform to the schema!", + "An error occurred!" + ); + break; + } + default: { + this.toastr.error("Your data did not save!", "An error occurred!"); + } + } + } + ); + } onCancel() { } } From 6c3e73b9931623a3969c0666d44cd28c886405a5 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Wed, 28 Feb 2018 23:18:54 +0000 Subject: [PATCH 28/82] all get all golang --- uiServices/src/homepage.go | 2 + uiServices/src/testCaseServices.go | 75 +++++++++++++++++++++++-- uiServices/src/testCaseServices_test.go | 31 +++++++--- 3 files changed, 96 insertions(+), 12 deletions(-) diff --git a/uiServices/src/homepage.go b/uiServices/src/homepage.go index 9e6d486..89d1a4e 100644 --- a/uiServices/src/homepage.go +++ b/uiServices/src/homepage.go @@ -125,6 +125,8 @@ func routeTestCases() http.Handler { router.Use(TestCaseCtx) router.Post("/", postTestCase) router.Put("/{testCaseName}", putTestCase) + router.Get("/", getAllTestCases) + return router } diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index e818e88..a5aa884 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -1,14 +1,20 @@ package services import ( + "bytes" "encoding/json" + "encoding/xml" "fmt" + "io/ioutil" + "log" "net/http" + "os" + "path/filepath" "strings" + "github.com/Sirupsen/logrus" - "github.com/xtracdev/automated-perf-test/testStrategies" - "bytes" "github.com/go-chi/chi" + "github.com/xtracdev/automated-perf-test/testStrategies" ) const testCaseSchema string = "testCase_schema.json" @@ -29,6 +35,65 @@ func getTestCaseHeader(req *http.Request) string { return testCasePathDir } +func getAllTestCases(rw http.ResponseWriter, req *http.Request) { + + testCasePathDir := getTestCaseHeader(req) + if len(testCasePathDir) <= 1 { + logrus.Error("No file directory entered") + rw.WriteHeader(http.StatusBadRequest) + return + } + + files, err := ioutil.ReadDir(testCasePathDir) + if err != nil { + log.Fatal(err) + } + + testCases := make([]Case, 0) + + for _, file := range files { + if filepath.Ext(testCasePathDir+file.Name()) == ".xml" { + + testCase := new(testStrategies.TestDefinition) + + filename := file.Name() + + file, err := os.Open(fmt.Sprintf("%s%s", testCasePathDir, filename)) + if err != nil { + continue + } + + byteValue, err := ioutil.ReadAll(file) + if err != nil { + continue + } + + err = xml.Unmarshal(byteValue, testCase) + if err != nil { + continue + } + + //if a Test Case Name can't be assigned, it isn't a Test Case object + if testCase.TestName != "" { + testCases = append(testCases, Case{ + Name: testCase.TestName, + Description: testCase.Description, + HttpMethod: testCase.HTTPMethod, + }) + } + } + } + + err = json.NewEncoder(rw).Encode(testCases) + if err != nil { + logrus.Error("Could not enocde Test Cases") + rw.WriteHeader(http.StatusInternalServerError) + return + } + + rw.WriteHeader(http.StatusOK) +} + func postTestCase(rw http.ResponseWriter, req *http.Request) { testCasePathDir := getTestCaseHeader(req) buf := new(bytes.Buffer) @@ -60,7 +125,7 @@ func postTestCase(rw http.ResponseWriter, req *http.Request) { } - if !testCaseWriterXml(testCase, testCasePathDir + testCase.TestName+".xml") { + if !testCaseWriterXml(testCase, testCasePathDir+testCase.TestName+".xml") { rw.WriteHeader(http.StatusInternalServerError) return } @@ -101,7 +166,7 @@ func putTestCase(rw http.ResponseWriter, req *http.Request) { return } - if len(testCase.TestName) < 1{ + if len(testCase.TestName) < 1 { logrus.Error("No TestName Entered") rw.WriteHeader(http.StatusBadRequest) return @@ -113,4 +178,4 @@ func putTestCase(rw http.ResponseWriter, req *http.Request) { } rw.WriteHeader(http.StatusNoContent) -} \ No newline at end of file +} diff --git a/uiServices/src/testCaseServices_test.go b/uiServices/src/testCaseServices_test.go index d749ef7..1432b97 100644 --- a/uiServices/src/testCaseServices_test.go +++ b/uiServices/src/testCaseServices_test.go @@ -1,13 +1,14 @@ package services import ( + "net/http" + "net/http/httptest" + "os" + "strings" "testing" + "github.com/go-chi/chi" - "strings" - "os" - "net/http/httptest" "github.com/stretchr/testify/assert" - "net/http" ) const validTestCase = ` @@ -89,7 +90,6 @@ const TestCaseMissingRequired = ` } ` - func TestValidTestCasePost(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) @@ -210,7 +210,6 @@ func TestTestCasePutMissingRequired(t *testing.T) { assert.Equal(t, http.StatusBadRequest, w.Code, "Should not have successfully updated") } - func TestInvalidUrlTestCasePut(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) @@ -314,4 +313,22 @@ func TestNoNameTestCasePut(t *testing.T) { } assert.Equal(t, http.StatusBadRequest, w.Code, "Successfully updated. Should not have worked due to no filepath") -} \ No newline at end of file +} + +func TestGetAllCasesNoHeader(t *testing.T) { + r := chi.NewRouter() + r.Mount("/", GetIndexPage()) + + DircetoryPath := "" + request, err := http.NewRequest(http.MethodGet, "/test-cases", nil) + + request.Header.Set("testCasePathDir", DircetoryPath) + request.Header.Get("testCasePathDir") + + w := httptest.NewRecorder() + r.ServeHTTP(w, request) + + if assert.NoError(t, err) { + assert.Equal(t, http.StatusBadRequest, w.Code, "Did not get all test cases") + } +} From 722b44b06b8c7ca103f72c368ae781f9b45c46f4 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Wed, 28 Feb 2018 23:30:37 +0000 Subject: [PATCH 29/82] get all working --- uiServices/src/testCaseServices.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index a5aa884..659f6a6 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -20,6 +20,12 @@ import ( const testCaseSchema string = "testCase_schema.json" const structTypeName string = "TestCase " +type Case struct { + HttpMethod string `json:"httpMethod"` + Name string `json:"name"` + Description string `json:"description"` +} + func TestCaseCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { next.ServeHTTP(w, r) From 19e3712563465ecaef267adbfdb5fb543c891cc8 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Thu, 1 Mar 2018 10:56:45 +0000 Subject: [PATCH 30/82] basic post method working --- ui-src/src/app/test-cases/test-cases.component.html | 4 ++-- ui-src/src/app/test-cases/test-cases.component.ts | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ui-src/src/app/test-cases/test-cases.component.html b/ui-src/src/app/test-cases/test-cases.component.html index 9900cf3..df76449 100644 --- a/ui-src/src/app/test-cases/test-cases.component.html +++ b/ui-src/src/app/test-cases/test-cases.component.html @@ -25,13 +25,13 @@
-
- +
diff --git a/ui-src/src/app/test-cases/test-cases.component.ts b/ui-src/src/app/test-cases/test-cases.component.ts index 9f4099c..8bbabdd 100644 --- a/ui-src/src/app/test-cases/test-cases.component.ts +++ b/ui-src/src/app/test-cases/test-cases.component.ts @@ -91,5 +91,9 @@ export class TestCasesComponent implements OnInit { } ); } - onCancel() { } + onCancel() { + + this.testCaseData = undefined; + + } } From f8f37d0aa755fe8d5a168873babe8af30fd021dc Mon Sep 17 00:00:00 2001 From: a586754 Date: Thu, 1 Mar 2018 15:18:24 +0000 Subject: [PATCH 31/82] select and deselect of testcase on click --- config/Hello.xml | 9 ---- config/rrrrrr.xml | 8 --- .../test-cases-list.component.html | 2 +- .../test-cases-list.component.ts | 33 ++++-------- .../test-cases-selection.component.html | 4 +- .../test-cases-selection.component.ts | 51 +++++++------------ .../test-suites/test-suites.component.html | 2 +- .../app/test-suites/test-suites.component.ts | 37 +++++--------- 8 files changed, 43 insertions(+), 103 deletions(-) delete mode 100644 config/Hello.xml delete mode 100644 config/rrrrrr.xml diff --git a/config/Hello.xml b/config/Hello.xml deleted file mode 100644 index 0bdece8..0000000 --- a/config/Hello.xml +++ /dev/null @@ -1,9 +0,0 @@ - - Hello - World - SuiteBased - - TestCaseService - TestCaseService - - \ No newline at end of file diff --git a/config/rrrrrr.xml b/config/rrrrrr.xml deleted file mode 100644 index da18b79..0000000 --- a/config/rrrrrr.xml +++ /dev/null @@ -1,8 +0,0 @@ - - rrrrrr - rrrrr - SuiteBased - - TestCaseService - - \ No newline at end of file diff --git a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html index 9610751..9e87cc5 100644 --- a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html +++ b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html @@ -5,7 +5,7 @@ Description Http Method - + {{testCase.name}} {{testCase.description}} {{testCase.httpMethod}} diff --git a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts index a994bdf..867f581 100644 --- a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts +++ b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts @@ -1,35 +1,20 @@ - -import { - Component, - Input, - Output, - EventEmitter -} from '@angular/core'; +import { Component, Input, Output, EventEmitter } from "@angular/core"; @Component({ - selector: 'test-cases-list', - templateUrl: './test-cases-list.component.html', - styleUrls: ['./test-cases-list.component.css'] + selector: "test-cases-list", + templateUrl: "./test-cases-list.component.html", + styleUrls: ["./test-cases-list.component.css"] }) - - export class TestCasesListComponent { testCaseArray = []; selectedTestCaseData = []; @Input() testCases; - @Output() t = new EventEmitter(); + @Output() addToSelected = new EventEmitter(); + @Output() reverse = new EventEmitter(); - - selectedCase(testCase) { + selectedCase(testCase, i) { this.selectedTestCaseData.push(testCase); - this.testCaseArray = this.selectedTestCaseData; - console.log(this.testCaseArray) - this.t.emit(this.testCaseArray); - + this.addToSelected.emit(this.selectedTestCaseData); + this.reverse.emit(i); } - changeValue() { - console.log("clicked") - this.t.emit("emit this value"); - } - } diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html index 77b2f0f..0025474 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html @@ -1,7 +1,7 @@

Available

- +
@@ -12,6 +12,6 @@

Available

Selected

- +
\ No newline at end of file diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts index a45a1c3..f1ca4a8 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts @@ -1,51 +1,36 @@ -import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; -import {TestCaseService} from '../../test-cases/test-case.service' +import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core"; +import { TestCaseService } from "../../test-cases/test-case.service"; @Component({ - selector: 'test-cases-selection', - templateUrl: './test-cases-selection.component.html', - styleUrls: ['./test-cases-selection.component.css'] + selector: "test-cases-selection", + templateUrl: "./test-cases-selection.component.html", + styleUrls: ["./test-cases-selection.component.css"] }) export class TestCasesSelectionComponent implements OnInit { - @Input() testSuiteDirPath; - @Input() availableTestCases; - @Input() t; - @Output() t1 = new EventEmitter(); -selectedTestCases = [] - constructor( - private testCaseService: TestCaseService - ) {} + @Input() availableTestCases; + @Input() t; + @Output() addToSelected = new EventEmitter(); + @Output() reverse = new EventEmitter(); + selectedTestCases = []; + constructor(private testCaseService: TestCaseService) {} ngOnInit() { // this.testCaseService.getAllTestCases$(this.testSuiteDirPath).subscribe( (data) => { // this.availableTestCases = data; - // }); } - selectOne(){ - - } + selectOne() {} - deSelectOne(){ + deSelectOne() {} + selectAll() {} + selectNone() {} + onReverse(i) { + this.selectedTestCases.splice(i, 1); } - - selectAll(){ - - } - selectNone(){ - - } - - onT(e) { - console.log("@@@") + onAddToSelected(e) { this.selectedTestCases = e; - console.log(this.selectedTestCases) - console.log(this.availableTestCases) - console.log(e) - } - } diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index 9b6c53c..0e9f397 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -30,7 +30,7 @@
- +
diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index 86a58e0..2f2d7a2 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -2,32 +2,27 @@ import { Component, OnInit, Input } from "@angular/core"; import { TestSuiteService } from "./test-suite.service"; import { TestCaseService } from "../test-cases/test-case.service"; import { ToastsManager } from "ng2-toastr/ng2-toastr"; -const TEST_SUITE_PATH = 'C:/Users/A586754/go/src/github.com/xtracdev/automated-perf-test/config'; +const TEST_SUITE_PATH = + "C:/Users/A586754/go/src/github.com/xtracdev/automated-perf-test/config"; @Component({ selector: "app-test-suites", templateUrl: "./test-suites.component.html", styleUrls: ["./test-suites.component.css"] }) export class TestSuitesComponent { - - - testSuitePath = TEST_SUITE_PATH - testValue = []; - testSuiteData = {}; + testSuitePath = TEST_SUITE_PATH; testCases = []; testCaseArray = []; formData = []; selectedTestCaseData = []; testSuiteFileName = undefined; testSuiteSchema = { layout: true }; - @Input() t1; - + constructor( private testSuiteService: TestSuiteService, private testCaseService: TestCaseService, private toastr: ToastsManager ) {} - ngOnInit() { this.testSuiteService @@ -36,10 +31,6 @@ export class TestSuitesComponent { this.testSuiteSchema = data; }); } - selectedCase(testCase) { - this.selectedTestCaseData.push(testCase); - this.testCaseArray["testCases"] = this.selectedTestCaseData; - } onAdd() { this.testSuiteService.getAllTestSuite$(TEST_SUITE_PATH).subscribe( @@ -70,15 +61,12 @@ export class TestSuitesComponent { } getTestCases() { - this.testCaseService.getAllTestCases$(TEST_SUITE_PATH) - .subscribe((data: any) => this.testCases = data); + this.testCaseService + .getAllTestCases$(TEST_SUITE_PATH) + .subscribe((data: any) => (this.testCases = data)); } - onDelete() {} - - onCancel(e) { - console.log("****",e); - + onCancel() { //clear schema and moving info back into available (get method) // this.testSuiteService.getTestSuite$(TEST_SUITE_PATH, this.testSuiteFileName) // .subscribe( @@ -93,6 +81,9 @@ export class TestSuitesComponent { } onSave(data) { + this.testCaseArray["testCases"] = this.selectedTestCaseData; + console.log(this.testCaseArray); + Object.assign(data, this.testCaseArray); this.testSuiteService.postTestSuite$(data, TEST_SUITE_PATH).subscribe( data => { @@ -105,6 +96,7 @@ export class TestSuitesComponent { break; } case 400: { + console.log(data); this.toastr.error( "Some of the fields do not conform to the schema!", "An error occurred!" @@ -119,11 +111,6 @@ export class TestSuitesComponent { ); } - reverseCase(testCase, index) { - this.selectedTestCaseData.splice(index, 1); - this.testCaseArray["testCases"] = this.selectedTestCaseData; - } - onSelectAll() { this.testCaseService .getAllTestCases$(TEST_SUITE_PATH) From 4fe0e12de09cb77d1f67a09c6e389a0d03c0c9a1 Mon Sep 17 00:00:00 2001 From: a586754 Date: Fri, 2 Mar 2018 12:08:11 +0000 Subject: [PATCH 32/82] Refactor --- config/Billy.xml | 6 + config/TestSuiteService444.xml | 9 + config/ddd.xml | 6 + config/hhh.xml | 6 + .../test-cases-selection.component.html | 2 +- .../test-cases-selection.component.ts | 9 +- .../test-suites/test-suites.component.html | 4 +- .../app/test-suites/test-suites.component.ts | 31 ++- uiServices/src/testSuiteServices.go | 250 ------------------ 9 files changed, 55 insertions(+), 268 deletions(-) create mode 100644 config/Billy.xml create mode 100644 config/TestSuiteService444.xml create mode 100644 config/ddd.xml create mode 100644 config/hhh.xml delete mode 100644 uiServices/src/testSuiteServices.go diff --git a/config/Billy.xml b/config/Billy.xml new file mode 100644 index 0000000..91b01ce --- /dev/null +++ b/config/Billy.xml @@ -0,0 +1,6 @@ + + Billy + Billy + SuiteBased + + \ No newline at end of file diff --git a/config/TestSuiteService444.xml b/config/TestSuiteService444.xml new file mode 100644 index 0000000..a9a2eaa --- /dev/null +++ b/config/TestSuiteService444.xml @@ -0,0 +1,9 @@ + + TestSuiteService444 + Services for XYZ + SuiteBased + + file1 + file2 + + \ No newline at end of file diff --git a/config/ddd.xml b/config/ddd.xml new file mode 100644 index 0000000..68c7f28 --- /dev/null +++ b/config/ddd.xml @@ -0,0 +1,6 @@ + + ddd + ddd + ServiceBased + + \ No newline at end of file diff --git a/config/hhh.xml b/config/hhh.xml new file mode 100644 index 0000000..5301e60 --- /dev/null +++ b/config/hhh.xml @@ -0,0 +1,6 @@ + + hhh + hhh + SuiteBased + + \ No newline at end of file diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html index 0025474..bca0eff 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html @@ -12,6 +12,6 @@

Available

Selected

- +
\ No newline at end of file diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts index f1ca4a8..6841079 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts @@ -9,10 +9,7 @@ import { TestCaseService } from "../../test-cases/test-case.service"; export class TestCasesSelectionComponent implements OnInit { @Input() testSuiteDirPath; @Input() availableTestCases; - @Input() t; - @Output() addToSelected = new EventEmitter(); - @Output() reverse = new EventEmitter(); - selectedTestCases = []; + selectedTestCaseData= []; constructor(private testCaseService: TestCaseService) {} ngOnInit() { @@ -28,9 +25,9 @@ export class TestCasesSelectionComponent implements OnInit { selectAll() {} selectNone() {} onReverse(i) { - this.selectedTestCases.splice(i, 1); + this.selectedTestCaseData.splice(i, 1); } onAddToSelected(e) { - this.selectedTestCases = e; + this.selectedTestCaseData = e; } } diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index 0e9f397..901bd54 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -16,7 +16,7 @@ Name Description - + {{testSuite.name}} {{testSuite.description}} @@ -30,7 +30,7 @@
- +
diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index 2f2d7a2..aabb58e 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -11,10 +11,11 @@ const TEST_SUITE_PATH = }) export class TestSuitesComponent { testSuitePath = TEST_SUITE_PATH; - testCases = []; + testCaseArray = []; - formData = []; - selectedTestCaseData = []; + testSuites = []; + testSuiteData = {}; + @Input() testCases; testSuiteFileName = undefined; testSuiteSchema = { layout: true }; @@ -35,7 +36,8 @@ export class TestSuitesComponent { onAdd() { this.testSuiteService.getAllTestSuite$(TEST_SUITE_PATH).subscribe( data => { - this.formData = data; + this.testSuites = data; + console.log(this.testSuites) this.toastr.success("Your data has been saved!", "Success!"); }, @@ -81,7 +83,8 @@ export class TestSuitesComponent { } onSave(data) { - this.testCaseArray["testCases"] = this.selectedTestCaseData; + /// console.log(this.selectedTestCaseData) + // this.testCaseArray["testCases"] = this.selectedTestCaseData; console.log(this.testCaseArray); Object.assign(data, this.testCaseArray); @@ -115,13 +118,23 @@ export class TestSuitesComponent { this.testCaseService .getAllTestCases$(TEST_SUITE_PATH) .subscribe((data: any) => { - this.selectedTestCaseData = data; - this.testCaseArray["testCases"] = this.selectedTestCaseData; + // this.selectedTestCaseData = data; + //this.testCaseArray["testCases"] = this.selectedTestCaseData; }); } - onSelectOne() {} + onSelectSuite(testSuite,i) { + this.testSuiteData = testSuite + console.log(this.testCases) + // this.selectedTestCaseData = testSuite.testCases; + + + } + onAddToSelected(e){ + console.log("*****",e) + // this.selectedTestCaseData = e; + } onReverseOne() {} onReverseAll() { - this.selectedTestCaseData = undefined; + // this.selectedTestCaseData = undefined; } } diff --git a/uiServices/src/testSuiteServices.go b/uiServices/src/testSuiteServices.go deleted file mode 100644 index 5939cd3..0000000 --- a/uiServices/src/testSuiteServices.go +++ /dev/null @@ -1,250 +0,0 @@ -package services - -import ( - "bytes" - "encoding/json" - "encoding/xml" - "fmt" - "io/ioutil" - "log" - "net/http" - "os" - "path/filepath" - "strings" - - "github.com/Sirupsen/logrus" - "github.com/go-chi/chi" - "github.com/xeipuuv/gojsonschema" - "github.com/xtracdev/automated-perf-test/testStrategies" -) - -var schemaFile string = "testSuite_schema.json" -var structType string = "TestSuite" - -type Suite struct { - File string `json:"file"` - Name string `json:"name"` - Description string `json:"description"` -} - -func TestSuiteCtx(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - next.ServeHTTP(w, r) - }) - -} -func getTestSuiteHeader(req *http.Request) string { - testSuitePathDir := req.Header.Get("testSuitePathDir") - - if !strings.HasSuffix(testSuitePathDir, "/") { - testSuitePathDir = testSuitePathDir + "/" - } - return testSuitePathDir -} - -func postTestSuites(rw http.ResponseWriter, req *http.Request) { - rw.Header().Set("Access-Control-Allow-Origin", "*") - testSuitePathDir := getTestSuiteHeader(req) - buf := new(bytes.Buffer) - buf.ReadFrom(req.Body) - - testSuite := testStrategies.TestSuite{} - err := json.Unmarshal(buf.Bytes(), &testSuite) - if err != nil { - logrus.Error("Failed to unmarshall json body", err) - rw.WriteHeader(http.StatusBadRequest) - return - } - - if !ValidateFileNameAndHeader(rw, req, testSuitePathDir, testSuite.Name) { - return - } - - // if !ValidateJsonWithSchema(buf.Bytes(), schemaFile, structType) { - // rw.WriteHeader(http.StatusBadRequest) - // return - // } - - if !FilePathExist(testSuitePathDir) { - logrus.Error("Directory path does not exist", err) - rw.WriteHeader(http.StatusBadRequest) - return - - } - - if FilePathExist(fmt.Sprintf("%s%s.xml", testSuitePathDir, testSuite.Name)) { - logrus.Error("File already exists") - rw.WriteHeader(http.StatusBadRequest) - return - - } - - if !testSuiteWriterXml(testSuite, testSuitePathDir+testSuite.Name+".xml") { - rw.WriteHeader(http.StatusInternalServerError) - return - } - - rw.WriteHeader(http.StatusCreated) -} - -func ValidateJsonWithSchema(testSuite []byte, schemaName, structType string) bool { - goPath := os.Getenv("GOPATH") - schemaLoader := gojsonschema.NewReferenceLoader("file:///" + goPath + "/src/github.com/xtracdev/automated-perf-test/ui-src/src/assets/" + schemaName) - documentLoader := gojsonschema.NewBytesLoader(testSuite) - logrus.Info(schemaLoader) - result, error := gojsonschema.Validate(schemaLoader, documentLoader) - - if error != nil { - return false - } - if !result.Valid() { - logrus.Errorf("%sdocument is not valid. see errors :", structType) - for _, desc := range result.Errors() { - logrus.Error("- ", desc) - return false - } - } - - logrus.Infof("%s document is valid", structType) - return true -} - -func putTestSuites(rw http.ResponseWriter, req *http.Request) { - rw.Header().Set("Access-Control-Allow-Origin", "*") - path := getTestSuiteHeader(req) - testSuiteName := chi.URLParam(req, "testSuiteName") - - if !ValidateFileNameAndHeader(rw, req, path, testSuiteName) { - return - } - - testSuitePathDir := fmt.Sprintf("%s%s.xml", path, testSuiteName) - buf := new(bytes.Buffer) - buf.ReadFrom(req.Body) - - if !FilePathExist(testSuitePathDir) { - logrus.Error("File path does not exist") - rw.WriteHeader(http.StatusNotFound) - return - - } - - if !ValidateJsonWithSchema(buf.Bytes(), schemaFile, structType) { - rw.WriteHeader(http.StatusBadRequest) - return - } - - testSuite := testStrategies.TestSuite{} - err := json.Unmarshal(buf.Bytes(), &testSuite) - - if err != nil { - logrus.Error("Cannot Unmarshall Json") - rw.WriteHeader(http.StatusBadRequest) - return - } - - if !testSuiteWriterXml(testSuite, testSuitePathDir) { - rw.WriteHeader(http.StatusInternalServerError) - return - } - - rw.WriteHeader(http.StatusNoContent) -} - -func getTestSuite(rw http.ResponseWriter, req *http.Request) { - rw.Header().Set("Access-Control-Allow-Origin", "*") - testSuitePathDir := getTestSuiteHeader(req) - testSuiteName := chi.URLParam(req, "testSuiteName") - - ValidateFileNameAndHeader(rw, req, testSuitePathDir, testSuiteName) - - file, err := os.Open(fmt.Sprintf("%s%s.xml", testSuitePathDir, testSuiteName)) - if err != nil { - logrus.Error("Test Suite Name Not Found: " + testSuitePathDir + testSuiteName) - rw.WriteHeader(http.StatusNotFound) - return - } - defer file.Close() - - var testSuite testStrategies.TestSuite - - byteValue, err := ioutil.ReadAll(file) - if err != nil { - rw.WriteHeader(http.StatusInternalServerError) - logrus.Error("Cannot Read File") - return - } - - err = xml.Unmarshal(byteValue, &testSuite) - if err != nil { - rw.WriteHeader(http.StatusInternalServerError) - logrus.Error("Cannot Unmarshall from XML") - return - } - - testSuiteJSON, err := json.MarshalIndent(testSuite, "", "") - if err != nil { - rw.WriteHeader(http.StatusInternalServerError) - logrus.Error("Cannot marshall to JSON") - return - } - - rw.WriteHeader(http.StatusOK) - rw.Write(testSuiteJSON) - -} - -func getAllTestSuites(rw http.ResponseWriter, req *http.Request) { - rw.Header().Set("Access-Control-Allow-Origin", "*") - testSuitePathDir := getTestSuiteHeader(req) - if len(testSuitePathDir) <= 1 { - logrus.Error("No file directory entered") - rw.WriteHeader(http.StatusBadRequest) - return - } - - files, err := ioutil.ReadDir(testSuitePathDir) - if err != nil { - log.Fatal(err) - } - - testSuites := make([]Suite, 0) - - for _, file := range files { - if filepath.Ext(testSuitePathDir+file.Name()) == ".xml" { - - testSuite := new(testStrategies.TestSuite) - - filename := file.Name() - - file, err := os.Open(fmt.Sprintf("%s%s", testSuitePathDir, filename)) - if err != nil { - logrus.Error("Cannot open file: ", filename) - } - - byteValue, err := ioutil.ReadAll(file) - if err != nil { - logrus.Error("Cannot Read File: ", filename) - } - - err = xml.Unmarshal(byteValue, testSuite) - if err != nil { - logrus.Error("Cannot Unmarshall: ", filename) - - } - - //if a Test Suite Name can't be assigned, it isn't a Test Suite object - if testSuite.Name != "" { - testSuites = append(testSuites, Suite{ - Name: testSuite.Name, - Description: testSuite.Description, - File: filename, - }) - } - } - } - - json.NewEncoder(rw).Encode(testSuites) - - rw.WriteHeader(http.StatusOK) -} From 1faec0e3635e09f16c398988f20e69aba80304e8 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Sun, 4 Mar 2018 19:19:12 +0000 Subject: [PATCH 33/82] updated layout on config schema --- ui-src/src/assets/schema.json | 117 +++++++++++++++++++++++++++------- 1 file changed, 95 insertions(+), 22 deletions(-) diff --git a/ui-src/src/assets/schema.json b/ui-src/src/assets/schema.json index 50ec856..affd48e 100644 --- a/ui-src/src/assets/schema.json +++ b/ui-src/src/assets/schema.json @@ -19,16 +19,28 @@ "reportOutputDir" ], "properties": { - "apiName": { "type": "string" }, - "targetHost": { "type": "string" }, + "apiName": { + "type": "string" + }, + "targetHost": { + "type": "string" + }, "targetPort": { "type": "string", "minimum": 1, "maximum": 65535 }, - "memoryEndpoint": { "type": "string" }, - "numIterations": { "type": "integer", "minimum": 1 }, - "concurrentUsers": { "type": "integer", "minimum": 1 }, + "memoryEndpoint": { + "type": "string" + }, + "numIterations": { + "type": "integer", + "minimum": 1 + }, + "concurrentUsers": { + "type": "integer", + "minimum": 1 + }, "allowablePeakMemoryVariance": { "type": "number", "minimum": 0, @@ -41,24 +53,54 @@ }, "testSuite": { "type": "string", - "enum": ["Default-1", "Default-2", "Default-3"] - }, - "requestDelay": { "type": "integer", "minimum": 1 }, - "TPSFreq": { "type": "integer", "minimum": 1 }, - "rampUsers": { "type": "integer", "minimum": 1 }, - "rampDelay": { "type": "integer", "minimum": 0 }, - "testCaseDir": { "type": "string" }, - "testSuiteDir": { "type": "string" }, - "baseStatsOutputDir": { "type": "string" }, - "reportOutputDir": { "type": "string" } + "enum": [ + "Default-1", + "Default-2", + "Default-3" + ] + }, + "requestDelay": { + "type": "integer", + "minimum": 1 + }, + "TPSFreq": { + "type": "integer", + "minimum": 1 + }, + "rampUsers": { + "type": "integer", + "minimum": 1 + }, + "rampDelay": { + "type": "integer", + "minimum": 0 + }, + "testCaseDir": { + "type": "string" + }, + "testSuiteDir": { + "type": "string" + }, + "baseStatsOutputDir": { + "type": "string" + }, + "reportOutputDir": { + "type": "string" + } }, - "layout" : [ + "layout": [ { "type": "flex", "flex-flow": "row wrap", "items": [ "apiName", + { + "md": 4 + }, "numIterations", + { + "md": 4 + }, { "key": "requestDelay", "title": "Request Delay (ms)" @@ -70,7 +112,13 @@ "flex-flow": "row wrap", "items": [ "targetHost", + { + "md": 4 + }, "concurrentUsers", + { + "md": 4 + }, { "key": "TPSFreq", "title": "TPS Frequency (s)" @@ -82,10 +130,16 @@ "flex-flow": "row wrap", "items": [ "targetPort", + { + "md": 4 + }, { "key": "allowablePeakMemoryVariance", "title": "Memory Variance (%)" }, + { + "md": 4 + }, "rampUsers" ] }, @@ -94,21 +148,40 @@ "flex-flow": "row wrap", "items": [ "memoryEndpoint", + { + "md": 4 + }, { "key": "allowableServiceResponseTimeVariance", "title": "Service Variance (%)" }, + { + "md": 4 + }, { "key": "rampDelay", "title": "Ramp Delay (s)" } ] }, - { "key": "testSuite" }, - { "key": "testCaseDir", "title": "Test Case Directory" }, - { "key": "testSuiteDir", "title": "Test Suites Directory" }, - { "key": "baseStatsOutputDir", "title": "Base Stats Output Directory" }, - { "key": "reportOutputDir", "title": "Report Output Directory" } - + { + "key": "testSuite" + }, + { + "key": "testCaseDir", + "title": "Test Case Directory" + }, + { + "key": "testSuiteDir", + "title": "Test Suites Directory" + }, + { + "key": "baseStatsOutputDir", + "title": "Base Stats Output Directory" + }, + { + "key": "reportOutputDir", + "title": "Report Output Directory" + } ] } \ No newline at end of file From 63c014f3b6e7a8f2ed1c29590c149ec61e0f272c Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Sun, 4 Mar 2018 19:22:08 +0000 Subject: [PATCH 34/82] added package for layout --- package.json | 5 + ui-src/npm-debug.log.2280341074 | 0 yarn.lock | 844 ++++++++++++++++++++++++++++++++ 3 files changed, 849 insertions(+) create mode 100644 package.json create mode 100644 ui-src/npm-debug.log.2280341074 create mode 100644 yarn.lock diff --git a/package.json b/package.json new file mode 100644 index 0000000..9b49b50 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "react-jsonschema-form-layout-grid": "^2.1.0" + } +} diff --git a/ui-src/npm-debug.log.2280341074 b/ui-src/npm-debug.log.2280341074 new file mode 100644 index 0000000..e69de29 diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..da9527e --- /dev/null +++ b/yarn.lock @@ -0,0 +1,844 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +ajv@^5.2.3: + version "5.5.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" + dependencies: + co "^4.6.0" + fast-deep-equal "^1.0.0" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.3.0" + +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + dependencies: + sprintf-js "~1.0.2" + +asap@~2.0.3: + version "2.0.6" + resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" + +asn1@0.1.11: + version "0.1.11" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.1.11.tgz#559be18376d08a4ec4dbe80877d27818639b2df7" + +asn1@~0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + +assert-plus@^0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.1.5.tgz#ee74009413002d84cec7219c6ac811812e723160" + +assert-plus@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" + +async@~0.9.0: + version "0.9.2" + resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + +aws-sign2@~0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.5.0.tgz#c57103f7a17fc037f02d7c2e64b602ea223f7d63" + +aws-sign2@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" + +aws4@^1.2.1: + version "1.6.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" + +babel-runtime@^6.11.6: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.11.0" + +bcrypt-pbkdf@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" + dependencies: + tweetnacl "^0.14.3" + +bl@~0.9.0: + version "0.9.5" + resolved "https://registry.yarnpkg.com/bl/-/bl-0.9.5.tgz#c06b797af085ea00bc527afc8efcf11de2232054" + dependencies: + readable-stream "~1.0.26" + +boom@0.4.x: + version "0.4.2" + resolved "https://registry.yarnpkg.com/boom/-/boom-0.4.2.tgz#7a636e9ded4efcefb19cef4947a3c67dfaee911b" + dependencies: + hoek "0.9.x" + +boom@2.x.x: + version "2.10.1" + resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" + dependencies: + hoek "2.x.x" + +caseless@~0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" + +caseless@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.6.0.tgz#8167c1ab8397fb5bb95f96d28e5a81c50f247ac4" + +chain-function@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/chain-function/-/chain-function-1.0.0.tgz#0d4ab37e7e18ead0bdc47b920764118ce58733dc" + +chalk@^1.1.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +classnames@^2.2.5: + version "2.2.5" + resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.5.tgz#fb3801d453467649ef3603c7d61a02bd129bde6d" + +co@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" + +codecov.io@^0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/codecov.io/-/codecov.io-0.1.6.tgz#59dfd02da1ff31c2fb2b952ad8ad16fd3781b728" + dependencies: + request "2.42.0" + urlgrey "0.4.0" + +combined-stream@^1.0.5, combined-stream@~1.0.5: + version "1.0.6" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" + dependencies: + delayed-stream "~1.0.0" + +combined-stream@~0.0.4: + version "0.0.7" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-0.0.7.tgz#0137e657baa5a7541c57ac37ac5fc07d73b4dc1f" + dependencies: + delayed-stream "0.0.5" + +commander@^2.9.0: + version "2.14.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa" + +core-js@^1.0.0: + version "1.2.7" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" + +core-js@^2.4.0: + version "2.5.3" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.3.tgz#8acc38345824f16d8365b7c9b4259168e8ed603e" + +core-util-is@1.0.2, core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +coveralls@^2.11.16: + version "2.13.3" + resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-2.13.3.tgz#9ad7c2ae527417f361e8b626483f48ee92dd2bc7" + dependencies: + js-yaml "3.6.1" + lcov-parse "0.0.10" + log-driver "1.2.5" + minimist "1.2.0" + request "2.79.0" + +cryptiles@0.2.x: + version "0.2.2" + resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-0.2.2.tgz#ed91ff1f17ad13d3748288594f8a48a0d26f325c" + dependencies: + boom "0.4.x" + +cryptiles@2.x.x: + version "2.0.5" + resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" + dependencies: + boom "2.x.x" + +ctype@0.5.3: + version "0.5.3" + resolved "https://registry.yarnpkg.com/ctype/-/ctype-0.5.3.tgz#82c18c2461f74114ef16c135224ad0b9144ca12f" + +dashdash@^1.12.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + dependencies: + assert-plus "^1.0.0" + +deep-equal@~0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-0.1.2.tgz#b246c2b80a570a47c11be1d9bd1070ec878b87ce" + +defined@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/defined/-/defined-0.0.0.tgz#f35eea7d705e933baf13b2f03b3f83d921403b3e" + +delayed-stream@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-0.0.5.tgz#d4b1f43a93e8296dfe02694f4680bc37a313c73f" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + +dom-helpers@^3.2.0, dom-helpers@^3.2.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/dom-helpers/-/dom-helpers-3.3.1.tgz#fc1a4e15ffdf60ddde03a480a9c0fece821dd4a6" + +duplexer@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" + +ecc-jsbn@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" + dependencies: + jsbn "~0.1.0" + +encoding@^0.1.11: + version "0.1.12" + resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb" + dependencies: + iconv-lite "~0.4.13" + +escape-string-regexp@^1.0.2: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +esprima@^2.6.0: + version "2.7.3" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" + +extend@~3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" + +extsprintf@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + +extsprintf@^1.2.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" + +fast-deep-equal@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614" + +fast-json-stable-stringify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" + +fbjs@^0.8.16: + version "0.8.16" + resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db" + dependencies: + core-js "^1.0.0" + isomorphic-fetch "^2.1.1" + loose-envify "^1.0.0" + object-assign "^4.1.0" + promise "^7.1.1" + setimmediate "^1.0.5" + ua-parser-js "^0.7.9" + +forever-agent@~0.5.0: + version "0.5.2" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.5.2.tgz#6d0e09c4921f94a27f63d3b49c5feff1ea4c5130" + +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + +form-data@~0.1.0: + version "0.1.4" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-0.1.4.tgz#91abd788aba9702b1aabfa8bc01031a2ac9e3b12" + dependencies: + async "~0.9.0" + combined-stream "~0.0.4" + mime "~1.2.11" + +form-data@~2.1.1: + version "2.1.4" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.12" + +generate-function@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74" + +generate-object-property@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" + dependencies: + is-property "^1.0.0" + +getpass@^0.1.1: + version "0.1.7" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" + dependencies: + assert-plus "^1.0.0" + +har-validator@~2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d" + dependencies: + chalk "^1.1.1" + commander "^2.9.0" + is-my-json-valid "^2.12.4" + pinkie-promise "^2.0.0" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + dependencies: + ansi-regex "^2.0.0" + +hawk@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-1.1.1.tgz#87cd491f9b46e4e2aeaca335416766885d2d1ed9" + dependencies: + boom "0.4.x" + cryptiles "0.2.x" + hoek "0.9.x" + sntp "0.2.x" + +hawk@~3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" + dependencies: + boom "2.x.x" + cryptiles "2.x.x" + hoek "2.x.x" + sntp "1.x.x" + +hoek@0.9.x: + version "0.9.1" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-0.9.1.tgz#3d322462badf07716ea7eb85baf88079cddce505" + +hoek@2.x.x: + version "2.16.3" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" + +http-signature@~0.10.0: + version "0.10.1" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-0.10.1.tgz#4fbdac132559aa8323121e540779c0a012b27e66" + dependencies: + asn1 "0.1.11" + assert-plus "^0.1.5" + ctype "0.5.3" + +http-signature@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" + dependencies: + assert-plus "^0.2.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +iconv-lite@~0.4.13: + version "0.4.19" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" + +inherits@~2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +invariant@^2.1.0, invariant@^2.2.1: + version "2.2.3" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.3.tgz#1a827dfde7dcbd7c323f0ca826be8fa7c5e9d688" + dependencies: + loose-envify "^1.0.0" + +is-my-ip-valid@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz#7b351b8e8edd4d3995d4d066680e664d94696824" + +is-my-json-valid@^2.12.4: + version "2.17.2" + resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.17.2.tgz#6b2103a288e94ef3de5cf15d29dd85fc4b78d65c" + dependencies: + generate-function "^2.0.0" + generate-object-property "^1.1.0" + is-my-ip-valid "^1.0.0" + jsonpointer "^4.0.0" + xtend "^4.0.0" + +is-property@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" + +is-stream@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + +is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + +isomorphic-fetch@^2.1.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9" + dependencies: + node-fetch "^1.0.1" + whatwg-fetch ">=0.10.0" + +isstream@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + +js-tokens@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" + +js-yaml@3.6.1: + version "3.6.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.6.1.tgz#6e5fe67d8b205ce4d22fad05b7781e8dadcc4b30" + dependencies: + argparse "^1.0.7" + esprima "^2.6.0" + +jsbn@~0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" + +json-schema-traverse@^0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" + +json-schema@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + +json-stringify-safe@~5.0.0, json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + +jsonify@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" + +jsonpointer@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" + +jsprim@^1.2.2: + version "1.4.1" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" + dependencies: + assert-plus "1.0.0" + extsprintf "1.3.0" + json-schema "0.2.3" + verror "1.10.0" + +keycode@^2.1.2: + version "2.1.9" + resolved "https://registry.yarnpkg.com/keycode/-/keycode-2.1.9.tgz#964a23c54e4889405b4861a5c9f0480d45141dfa" + +lcov-parse@0.0.10: + version "0.0.10" + resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.10.tgz#1b0b8ff9ac9c7889250582b70b71315d9da6d9a3" + +lodash.topath@^4.5.2: + version "4.5.2" + resolved "https://registry.yarnpkg.com/lodash.topath/-/lodash.topath-4.5.2.tgz#3616351f3bba61994a0931989660bd03254fd009" + +log-driver@1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.5.tgz#7ae4ec257302fd790d557cb10c97100d857b0056" + +loose-envify@^1.0.0, loose-envify@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848" + dependencies: + js-tokens "^3.0.0" + +mime-db@~1.33.0: + version "1.33.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.33.0.tgz#a3492050a5cb9b63450541e39d9788d2272783db" + +mime-types@^2.1.12, mime-types@~2.1.7: + version "2.1.18" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.18.tgz#6f323f60a83d11146f831ff11fd66e2fe5503bb8" + dependencies: + mime-db "~1.33.0" + +mime-types@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-1.0.2.tgz#995ae1392ab8affcbfcb2641dd054e943c0d5dce" + +mime@~1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.2.11.tgz#58203eed86e3a5ef17aed2b7d9ebd47f0a60dd10" + +minimist@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + +node-fetch@^1.0.1: + version "1.7.3" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef" + dependencies: + encoding "^0.1.11" + is-stream "^1.0.1" + +node-uuid@~1.4.0: + version "1.4.8" + resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.8.tgz#b040eb0923968afabf8d32fb1f17f1167fdab907" + +oauth-sign@~0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.4.0.tgz#f22956f31ea7151a821e5f2fb32c113cad8b9f69" + +oauth-sign@~0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" + +object-assign@^4.1.0, object-assign@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + +promise@^7.1.1: + version "7.3.1" + resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf" + dependencies: + asap "~2.0.3" + +prop-types-extra@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/prop-types-extra/-/prop-types-extra-1.0.1.tgz#a57bd4810e82d27a3ff4317ecc1b4ad005f79a82" + dependencies: + warning "^3.0.0" + +prop-types@^15.5.10, prop-types@^15.5.8: + version "15.6.1" + resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.1.tgz#36644453564255ddda391191fb3a125cbdf654ca" + dependencies: + fbjs "^0.8.16" + loose-envify "^1.3.1" + object-assign "^4.1.1" + +punycode@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + +qs@~1.2.0: + version "1.2.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-1.2.2.tgz#19b57ff24dc2a99ce1f8bdf6afcda59f8ef61f88" + +qs@~6.3.0: + version "6.3.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.2.tgz#e75bd5f6e268122a2a0e0bda630b2550c166502c" + +"react-bootstrap@>= 0.30.7": + version "0.32.1" + resolved "https://registry.yarnpkg.com/react-bootstrap/-/react-bootstrap-0.32.1.tgz#60624c1b48a39d773ef6cce6421a4f33ecc166bb" + dependencies: + babel-runtime "^6.11.6" + classnames "^2.2.5" + dom-helpers "^3.2.0" + invariant "^2.2.1" + keycode "^2.1.2" + prop-types "^15.5.10" + prop-types-extra "^1.0.1" + react-overlays "^0.8.0" + react-prop-types "^0.4.0" + react-transition-group "^2.0.0" + uncontrollable "^4.1.0" + warning "^3.0.0" + +react-jsonschema-form-layout-grid@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/react-jsonschema-form-layout-grid/-/react-jsonschema-form-layout-grid-2.1.0.tgz#1caf8d579aea2c22edcae9e8d89f46353187421b" + dependencies: + codecov.io "^0.1.6" + coveralls "^2.11.16" + react-bootstrap ">= 0.30.7" + react-jsonschema-form ">= 0.43.0" + +"react-jsonschema-form@>= 0.43.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/react-jsonschema-form/-/react-jsonschema-form-1.0.1.tgz#1b83ad5a71458100367c29bef68b5c38d65fbeab" + dependencies: + ajv "^5.2.3" + lodash.topath "^4.5.2" + prop-types "^15.5.8" + setimmediate "^1.0.5" + +react-overlays@^0.8.0: + version "0.8.3" + resolved "https://registry.yarnpkg.com/react-overlays/-/react-overlays-0.8.3.tgz#fad65eea5b24301cca192a169f5dddb0b20d3ac5" + dependencies: + classnames "^2.2.5" + dom-helpers "^3.2.1" + prop-types "^15.5.10" + prop-types-extra "^1.0.1" + react-transition-group "^2.2.0" + warning "^3.0.0" + +react-prop-types@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/react-prop-types/-/react-prop-types-0.4.0.tgz#f99b0bfb4006929c9af2051e7c1414a5c75b93d0" + dependencies: + warning "^3.0.0" + +react-transition-group@^2.0.0, react-transition-group@^2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-2.2.1.tgz#e9fb677b79e6455fd391b03823afe84849df4a10" + dependencies: + chain-function "^1.0.0" + classnames "^2.2.5" + dom-helpers "^3.2.0" + loose-envify "^1.3.1" + prop-types "^15.5.8" + warning "^3.0.0" + +readable-stream@~1.0.26: + version "1.0.34" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +regenerator-runtime@^0.11.0: + version "0.11.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" + +request@2.42.0: + version "2.42.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.42.0.tgz#572bd0148938564040ac7ab148b96423a063304a" + dependencies: + bl "~0.9.0" + caseless "~0.6.0" + forever-agent "~0.5.0" + json-stringify-safe "~5.0.0" + mime-types "~1.0.1" + node-uuid "~1.4.0" + qs "~1.2.0" + tunnel-agent "~0.4.0" + optionalDependencies: + aws-sign2 "~0.5.0" + form-data "~0.1.0" + hawk "1.1.1" + http-signature "~0.10.0" + oauth-sign "~0.4.0" + stringstream "~0.0.4" + tough-cookie ">=0.12.0" + +request@2.79.0: + version "2.79.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.79.0.tgz#4dfe5bf6be8b8cdc37fcf93e04b65577722710de" + dependencies: + aws-sign2 "~0.6.0" + aws4 "^1.2.1" + caseless "~0.11.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~2.1.1" + har-validator "~2.0.6" + hawk "~3.1.3" + http-signature "~1.1.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + oauth-sign "~0.8.1" + qs "~6.3.0" + stringstream "~0.0.4" + tough-cookie "~2.3.0" + tunnel-agent "~0.4.1" + uuid "^3.0.0" + +resumer@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759" + dependencies: + through "~2.3.4" + +setimmediate@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" + +sntp@0.2.x: + version "0.2.4" + resolved "https://registry.yarnpkg.com/sntp/-/sntp-0.2.4.tgz#fb885f18b0f3aad189f824862536bceeec750900" + dependencies: + hoek "0.9.x" + +sntp@1.x.x: + version "1.0.9" + resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" + dependencies: + hoek "2.x.x" + +split@~0.2.10: + version "0.2.10" + resolved "https://registry.yarnpkg.com/split/-/split-0.2.10.tgz#67097c601d697ce1368f418f06cd201cf0521a57" + dependencies: + through "2" + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + +sshpk@^1.7.0: + version "1.13.1" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + dashdash "^1.12.0" + getpass "^0.1.1" + optionalDependencies: + bcrypt-pbkdf "^1.0.0" + ecc-jsbn "~0.1.1" + jsbn "~0.1.0" + tweetnacl "~0.14.0" + +stream-combiner@~0.0.2: + version "0.0.4" + resolved "https://registry.yarnpkg.com/stream-combiner/-/stream-combiner-0.0.4.tgz#4d5e433c185261dde623ca3f44c586bcf5c4ad14" + dependencies: + duplexer "~0.1.1" + +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + +stringstream@~0.0.4: + version "0.0.5" + resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" + +strip-ansi@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + dependencies: + ansi-regex "^2.0.0" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + +tape@2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/tape/-/tape-2.3.0.tgz#0dfeec709227fbcc9170abe7f046962b271431db" + dependencies: + deep-equal "~0.1.0" + defined "~0.0.0" + inherits "~2.0.1" + jsonify "~0.0.0" + resumer "~0.0.0" + split "~0.2.10" + stream-combiner "~0.0.2" + through "~2.3.4" + +through@2, through@~2.3.4: + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + +tough-cookie@>=0.12.0, tough-cookie@~2.3.0: + version "2.3.4" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.4.tgz#ec60cee38ac675063ffc97a5c18970578ee83655" + dependencies: + punycode "^1.4.1" + +tunnel-agent@~0.4.0, tunnel-agent@~0.4.1: + version "0.4.3" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.5" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + +ua-parser-js@^0.7.9: + version "0.7.17" + resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac" + +uncontrollable@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/uncontrollable/-/uncontrollable-4.1.0.tgz#e0358291252e1865222d90939b19f2f49f81c1a9" + dependencies: + invariant "^2.1.0" + +urlgrey@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/urlgrey/-/urlgrey-0.4.0.tgz#f065357040fb35c3b311d4e5dc36484d96dbea06" + dependencies: + tape "2.3.0" + +uuid@^3.0.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14" + +verror@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" + dependencies: + assert-plus "^1.0.0" + core-util-is "1.0.2" + extsprintf "^1.2.0" + +warning@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/warning/-/warning-3.0.0.tgz#32e5377cb572de4ab04753bdf8821c01ed605b7c" + dependencies: + loose-envify "^1.0.0" + +whatwg-fetch@>=0.10.0: + version "2.0.3" + resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84" + +xtend@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" From a73a7839002ae693d950e85e27f67bff1fcb357b Mon Sep 17 00:00:00 2001 From: a586754 Date: Mon, 5 Mar 2018 09:03:19 +0000 Subject: [PATCH 35/82] Put functionality- Not fully complete --- config/TestSuiteService22.xml | 2 +- .../configurationComponent.e2e-spec.ts | 238 ---------------- .../test-cases-selection.component.html | 2 +- .../test-cases-selection.component.ts | 8 +- .../test-suites/test-suites.component.html | 4 +- .../app/test-suites/test-suites.component.ts | 63 +++-- uiServices/src/testSuiteServices.go | 254 ++++++++++++++++++ 7 files changed, 312 insertions(+), 259 deletions(-) create mode 100644 uiServices/src/testSuiteServices.go diff --git a/config/TestSuiteService22.xml b/config/TestSuiteService22.xml index d5d3360..249936b 100644 --- a/config/TestSuiteService22.xml +++ b/config/TestSuiteService22.xml @@ -1,5 +1,5 @@ - TestSuiteService22 + TestSuiteService21 Services 22 SuiteBased diff --git a/ui-src/e2e/components/configurationComponent.e2e-spec.ts b/ui-src/e2e/components/configurationComponent.e2e-spec.ts index 6c60226..07178de 100644 --- a/ui-src/e2e/components/configurationComponent.e2e-spec.ts +++ b/ui-src/e2e/components/configurationComponent.e2e-spec.ts @@ -1,242 +1,4 @@ -import { - browser, - element, - by, - By, - $, - $$, - ExpectedConditions, - protractor, - WebDriver, - Key -} from "protractor"; -import { read } from "fs"; -import { Input } from "@angular/core/src/metadata/directives"; -import { ToastModule } from "ng2-toastr/ng2-toastr"; -const since = require("jasmine2-custom-message"); - -import ConfigurationPageObject = require("../pages/configuration-PO"); -const configPO: ConfigurationPageObject = new ConfigurationPageObject(); - -describe("configuration component", () => { - beforeEach(() => { - browser.get("http://localhost:9191"); - browser.executeScript("window.onbeforeunload = function(e){};"); - browser.driver - .manage() - .window() - .maximize(); - }); - - it("should create xml file", () => { - configPO.setConfigData(); - configPO.submitBtn.click(); - expect(configPO.toastrMessage.getText()).toContain( - "Your data has been saved!" - ); - }); - - - it("should check that all text box names are correct", () => { - configPO.setConfigData(); - expect(configPO.labels.get(0).getText()).toContain("Api Name"); - expect(configPO.labels.get(1).getText()).toContain("Num Iterations"); - expect(configPO.labels.get(2).getText()).toContain("Request Delay (ms)"); - expect(configPO.labels.get(3).getText()).toContain("Target Host"); - expect(configPO.labels.get(4).getText()).toContain("Concurrent Users"); - expect(configPO.labels.get(5).getText()).toContain("TPS Frequency (s"); - expect(configPO.labels.get(6).getText()).toContain("Target Port"); - expect(configPO.labels.get(7).getText()).toContain("Memory Variance (%)"); - expect(configPO.labels.get(8).getText()).toContain("Ramp Users"); - expect(configPO.labels.get(9).getText()).toContain("Memory Endpoint"); - expect(configPO.labels.get(10).getText()).toContain("Service Variance (%)"); - expect(configPO.labels.get(11).getText()).toContain("Ramp Delay (s)"); - expect(configPO.labels.get(12).getText()).toContain("Test Suite"); - expect(configPO.labels.get(13).getText()).toContain("Test Case Directory"); - expect(configPO.labels.get(14).getText()).toContain( - "Test Suites Directory" - ); - }); - - it("should check values of existing file are as expected", () => { - configPO.configFilePath.sendKeys(configPO.absolutePath); - configPO.xmlFileName.sendKeys("config"); - configPO.cancelBtn.click(); - expect(configPO.applicationName.getAttribute("value")).toEqual("config"); - expect(configPO.targetHost.getAttribute("value")).toEqual("localhost"); - expect(configPO.targetPort.getAttribute("value")).toEqual("8080"); - expect(configPO.testCaseDir.getAttribute("value")).toEqual( - "./definitions/testCases" - ); - expect(configPO.baseStatsDir.getAttribute("value")).toEqual("./envStats"); - expect(configPO.memoryEndpoint.getAttribute("value")).toEqual( - "/alt/debug/vars" - ); - expect(configPO.reportsDir.getAttribute("value")).toEqual("./report"); - expect(configPO.numIterations.getAttribute("value")).toEqual("1000"); - expect(configPO.memoryVariance.getAttribute("value")).toEqual("15"); - expect(configPO.serviceVariance.getAttribute("value")).toEqual("15"); - expect(configPO.concurrentUsers.getAttribute("value")).toEqual("50"); - expect(configPO.requestDelay.getAttribute("value")).toEqual("5000"); - expect(configPO.tpsFreq.getAttribute("value")).toEqual("30"); - expect(configPO.rampDelay.getAttribute("value")).toEqual("15"); - expect(configPO.rampUsers.getAttribute("value")).toEqual("15"); - }); - - - it("should throw error when file path does not exist", () => { - configPO.setConfigData(); - configPO.configFilePath.sendKeys("/path/to/bad/location"); - configPO.submitBtn.click(); - expect(configPO.toastrMessage.getText()).toContain( - "Some of the fields do not conform to the schema" - ); - }); - - it("should check requiredFields warning appears when requiredFields input is blank", () => { - configPO.checkRequiredFields(); - since("(apiName) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(0).getText()) - .toContain("This field is required."); - since("(targetHost) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(1).getText()) - .toContain("This field is required."); - since("(targetPort) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(2).getText()) - .toContain("This field is required."); - since("(numIterations) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(3).getText()) - .toContain("This field is required."); - since("(concurrentUsers) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(4).getText()) - .toContain("This field is required."); - since("(memoryVariance) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(5).getText()) - .toContain("This field is required."); - since("(serviceVariance) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(6).getText()) - .toContain("This field is required."); - since("(requestDelay) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(7).getText()) - .toContain("This field is required."); - since("(tpsFreq) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(8).getText()) - .toContain("This field is required."); - since("(rampUsers) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(9).getText()) - .toContain("This field is required."); - since("(rampDelay) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(10).getText()) - .toContain("This field is required."); - since("(testCaseDir) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(11).getText()) - .toContain("This field is required."); - since("(testSuiteDir) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(12).getText()) - .toContain("This field is required."); - since("(baseStatsDir) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(13).getText()) - .toContain("This field is required."); - since("(reportsDir) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(14).getText()) - .toContain("This field is required."); - }); - - it("should show that string cannot be entered into a integer field", () => { - configPO.checkForStrings(); - expect(configPO.numIterations.getAttribute("value")).toEqual(""); - expect(configPO.memoryVariance.getAttribute("value")).toEqual(""); - expect(configPO.serviceVariance.getAttribute("value")).toEqual(""); - expect(configPO.concurrentUsers.getAttribute("value")).toEqual(""); - expect(configPO.requestDelay.getAttribute("value")).toEqual(""); - expect(configPO.tpsFreq.getAttribute("value")).toEqual(""); - expect(configPO.tpsFreq.getAttribute("value")).toEqual(""); - expect(configPO.rampDelay.getAttribute("value")).toEqual(""); - expect(configPO.rampUsers.getAttribute("value")).toEqual(""); - }); - it("should check that e is not accepted in interger field", () => { - configPO.checkEisNotAccepted(); - since("(numIterations) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(0).getText()) - .toContain("This field is required."); - since("(concurrentUsers) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(1).getText()) - .toContain("This field is required."); - since("(memoryVariance) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(2).getText()) - .toContain("This field is required."); - since("(serviceVariance) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(3).getText()) - .toContain("This field is required."); - since("(requestDelay) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(4).getText()) - .toContain("This field is required."); - since("(tpsFreq) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(5).getText()) - .toContain("This field is required."); - since("(rampUsers) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(6).getText()) - .toContain("This field is required."); - since("(rampDelay) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(7).getText()) - .toContain("This field is required."); - }); - - it("should check that warning appears if negative number is enter to integer field", () => { - configPO.checkNegativeValues(); - since("(numIterations) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(0).getText()) - .toContain("Must be 1 or more"); - since("(requestDelay) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(1).getText()) - .toContain("Must be 1 or more"); - since("(concurrentUsers) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(2).getText()) - .toContain("Must be 1 or more"); - since("(tpsFreq) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(3).getText()) - .toContain("Must be 1 or more"); - since("(memoryVariance) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(4).getText()) - .toContain("Must be 0 or more"); - since("(rampUsers) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(5).getText()) - .toContain("Must be 1 or more"); - since("(serviceVariance) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(6).getText()) - .toContain("Must be 0 or more"); - since("(rampDelay) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(7).getText()) - .toContain("Must be 0 or more"); - }); - - it("should check that warning appears if value exceeds maximum", () => { - configPO.memoryVariance.sendKeys(101); - configPO.serviceVariance.sendKeys(101); - since("(memoryVariance) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(0).getText()) - .toEqual("Must be 100 or less"); - since("(serviceVariance) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(1).getText()) - .toEqual("Must be 100 or less"); - }); - - it("should update existing file", () => { - configPO.configFilePath.sendKeys(configPO.absolutePath); - configPO.xmlFileName.sendKeys("config"); - configPO.cancelBtn.click(); - configPO.numIterations.sendKeys(5); - configPO.btnUpdate.click(); - configPO.numIterations.sendKeys(Key.BACK_SPACE); - configPO.cancelBtn.click(); - - expect(configPO.numIterations.getAttribute("value")).toEqual("10005"); - }); - it("should show update button is disabled when Xml File Name is blank", () => { - expect(configPO.btnUpdate.isPresent()).toBe(false); - }); -}); import { browser, element, diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html index bca0eff..f1b07d0 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html @@ -12,6 +12,6 @@

Available

Selected

- +
\ No newline at end of file diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts index 6841079..9aa114e 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts @@ -9,7 +9,9 @@ import { TestCaseService } from "../../test-cases/test-case.service"; export class TestCasesSelectionComponent implements OnInit { @Input() testSuiteDirPath; @Input() availableTestCases; - selectedTestCaseData= []; + @Input() selectedTestCaseData; + @Output() addToSelected = new EventEmitter(); + @Output() reverse = new EventEmitter(); constructor(private testCaseService: TestCaseService) {} ngOnInit() { @@ -26,8 +28,10 @@ export class TestCasesSelectionComponent implements OnInit { selectNone() {} onReverse(i) { this.selectedTestCaseData.splice(i, 1); + this.addToSelected.emit(this.selectedTestCaseData); } - onAddToSelected(e) { + onAddToSelected(e,i) { this.selectedTestCaseData = e; + this.addToSelected.emit(e); } } diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index 901bd54..6a08cc6 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -30,9 +30,9 @@
- +
- +
diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index aabb58e..d395a01 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit, Input } from "@angular/core"; import { TestSuiteService } from "./test-suite.service"; import { TestCaseService } from "../test-cases/test-case.service"; import { ToastsManager } from "ng2-toastr/ng2-toastr"; +import {TestCasesSelectionComponent} from "../shared/test-cases-selection/test-cases-selection.component" const TEST_SUITE_PATH = "C:/Users/A586754/go/src/github.com/xtracdev/automated-perf-test/config"; @Component({ @@ -11,14 +12,13 @@ const TEST_SUITE_PATH = }) export class TestSuitesComponent { testSuitePath = TEST_SUITE_PATH; - testCaseArray = []; testSuites = []; + selectedTestCaseData = []; testSuiteData = {}; - @Input() testCases; + testCases = []; testSuiteFileName = undefined; testSuiteSchema = { layout: true }; - constructor( private testSuiteService: TestSuiteService, private testCaseService: TestCaseService, @@ -66,6 +66,7 @@ export class TestSuitesComponent { this.testCaseService .getAllTestCases$(TEST_SUITE_PATH) .subscribe((data: any) => (this.testCases = data)); + } onCancel() { @@ -81,12 +82,43 @@ export class TestSuitesComponent { // } // ); } + onUpdate(data) { + this.testCaseArray["testCases"] = this.selectedTestCaseData; + Object.assign(data, this.testCaseArray); + this.testSuiteService + .putTestSuite$(this.testSuiteData, this.testSuitePath, this.testSuiteFileName) + .subscribe( + data => { + this.toastr.success("Success!"); + }, + error => { + switch (error.status) { + case 404: { + this.toastr.error("File not found", "An error occured!"); + break; + } + case 400: { + this.toastr.error( + "File must be specified!", + "An error occurred!" + ); + break; + } + case 500: { + this.toastr.error("Internal server error!"); + break; + } + default: { + this.toastr.error("File was not updated!", "An error occurred!"); + } + } + } + ); + } + onSave(data) { - /// console.log(this.selectedTestCaseData) - // this.testCaseArray["testCases"] = this.selectedTestCaseData; - console.log(this.testCaseArray); - + this.testCaseArray["testCases"] = this.selectedTestCaseData; Object.assign(data, this.testCaseArray); this.testSuiteService.postTestSuite$(data, TEST_SUITE_PATH).subscribe( data => { @@ -122,16 +154,17 @@ export class TestSuitesComponent { //this.testCaseArray["testCases"] = this.selectedTestCaseData; }); } - onSelectSuite(testSuite,i) { - this.testSuiteData = testSuite - console.log(this.testCases) - // this.selectedTestCaseData = testSuite.testCases; + onSelectSuite(testSuite, i) + { + this.testSuiteData = testSuite; + this.selectedTestCaseData = testSuite.testCases; + this.testSuiteFileName = testSuite.name - } - onAddToSelected(e){ - console.log("*****",e) - // this.selectedTestCaseData = e; + } + updateSelected(e){ + this.selectedTestCaseData = e; + console.log(e); } onReverseOne() {} onReverseAll() { diff --git a/uiServices/src/testSuiteServices.go b/uiServices/src/testSuiteServices.go new file mode 100644 index 0000000..f3ad702 --- /dev/null +++ b/uiServices/src/testSuiteServices.go @@ -0,0 +1,254 @@ +package services + +import ( + "bytes" + "encoding/json" + "encoding/xml" + "fmt" + "io/ioutil" + "log" + "net/http" + "os" + "path/filepath" + "strings" + + "github.com/Sirupsen/logrus" + "github.com/go-chi/chi" + "github.com/xeipuuv/gojsonschema" + "github.com/xtracdev/automated-perf-test/testStrategies" +) + +var schemaFile string = "testSuite_schema.json" +var structType string = "TestSuite" + +type Suite struct { + File string `json:"file"` + Name string `json:"name"` + Description string `json:"description"` + TestStrategy string `json:"testStrategy"` + TestCases []testStrategies.TestCase `json:"testCases"` +} + +func TestSuiteCtx(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + next.ServeHTTP(w, r) + }) + +} +func getTestSuiteHeader(req *http.Request) string { + testSuitePathDir := req.Header.Get("testSuitePathDir") + + if !strings.HasSuffix(testSuitePathDir, "/") { + testSuitePathDir = testSuitePathDir + "/" + } + return testSuitePathDir +} + +func postTestSuites(rw http.ResponseWriter, req *http.Request) { + rw.Header().Set("Access-Control-Allow-Origin", "*") + testSuitePathDir := getTestSuiteHeader(req) + buf := new(bytes.Buffer) + buf.ReadFrom(req.Body) + + testSuite := testStrategies.TestSuite{} + err := json.Unmarshal(buf.Bytes(), &testSuite) + if err != nil { + logrus.Error("Failed to unmarshall json body", err) + rw.WriteHeader(http.StatusBadRequest) + return + } + + if !ValidateFileNameAndHeader(rw, req, testSuitePathDir, testSuite.Name) { + return + } + + // if !ValidateJsonWithSchema(buf.Bytes(), schemaFile, structType) { + // rw.WriteHeader(http.StatusBadRequest) + // return + // } + + if !FilePathExist(testSuitePathDir) { + logrus.Error("Directory path does not exist", err) + rw.WriteHeader(http.StatusBadRequest) + return + + } + + if FilePathExist(fmt.Sprintf("%s%s.xml", testSuitePathDir, testSuite.Name)) { + logrus.Error("File already exists") + rw.WriteHeader(http.StatusBadRequest) + return + + } + + if !testSuiteWriterXml(testSuite, testSuitePathDir+testSuite.Name+".xml") { + rw.WriteHeader(http.StatusInternalServerError) + return + } + + rw.WriteHeader(http.StatusCreated) +} + +func ValidateJsonWithSchema(testSuite []byte, schemaName, structType string) bool { + goPath := os.Getenv("GOPATH") + schemaLoader := gojsonschema.NewReferenceLoader("file:///" + goPath + "/src/github.com/xtracdev/automated-perf-test/ui-src/src/assets/" + schemaName) + documentLoader := gojsonschema.NewBytesLoader(testSuite) + logrus.Info(schemaLoader) + result, error := gojsonschema.Validate(schemaLoader, documentLoader) + + if error != nil { + return false + } + if !result.Valid() { + logrus.Errorf("%sdocument is not valid. see errors :", structType) + for _, desc := range result.Errors() { + logrus.Error("- ", desc) + return false + } + } + + logrus.Infof("%s document is valid", structType) + return true +} + +func putTestSuites(rw http.ResponseWriter, req *http.Request) { + rw.Header().Set("Access-Control-Allow-Origin", "*") + path := getTestSuiteHeader(req) + testSuiteName := chi.URLParam(req, "testSuiteName") + + if !ValidateFileNameAndHeader(rw, req, path, testSuiteName) { + return + } + + testSuitePathDir := fmt.Sprintf("%s%s.xml", path, testSuiteName) + buf := new(bytes.Buffer) + buf.ReadFrom(req.Body) + + if !FilePathExist(testSuitePathDir) { + logrus.Error("File path does not exist") + rw.WriteHeader(http.StatusNotFound) + return + + } + + if !ValidateJsonWithSchema(buf.Bytes(), schemaFile, structType) { + rw.WriteHeader(http.StatusBadRequest) + return + } + + testSuite := testStrategies.TestSuite{} + err := json.Unmarshal(buf.Bytes(), &testSuite) + + if err != nil { + logrus.Error("Cannot Unmarshall Json") + rw.WriteHeader(http.StatusBadRequest) + return + } + + if !testSuiteWriterXml(testSuite, testSuitePathDir) { + rw.WriteHeader(http.StatusInternalServerError) + return + } + + rw.WriteHeader(http.StatusNoContent) +} + +func getTestSuite(rw http.ResponseWriter, req *http.Request) { + rw.Header().Set("Access-Control-Allow-Origin", "*") + testSuitePathDir := getTestSuiteHeader(req) + testSuiteName := chi.URLParam(req, "testSuiteName") + + ValidateFileNameAndHeader(rw, req, testSuitePathDir, testSuiteName) + + file, err := os.Open(fmt.Sprintf("%s%s.xml", testSuitePathDir, testSuiteName)) + if err != nil { + logrus.Error("Test Suite Name Not Found: " + testSuitePathDir + testSuiteName) + rw.WriteHeader(http.StatusNotFound) + return + } + defer file.Close() + + var testSuite testStrategies.TestSuite + + byteValue, err := ioutil.ReadAll(file) + if err != nil { + rw.WriteHeader(http.StatusInternalServerError) + logrus.Error("Cannot Read File") + return + } + + err = xml.Unmarshal(byteValue, &testSuite) + if err != nil { + rw.WriteHeader(http.StatusInternalServerError) + logrus.Error("Cannot Unmarshall from XML") + return + } + + testSuiteJSON, err := json.MarshalIndent(testSuite, "", "") + if err != nil { + rw.WriteHeader(http.StatusInternalServerError) + logrus.Error("Cannot marshall to JSON") + return + } + + rw.WriteHeader(http.StatusOK) + rw.Write(testSuiteJSON) + +} + +func getAllTestSuites(rw http.ResponseWriter, req *http.Request) { + rw.Header().Set("Access-Control-Allow-Origin", "*") + testSuitePathDir := getTestSuiteHeader(req) + if len(testSuitePathDir) <= 1 { + logrus.Error("No file directory entered") + rw.WriteHeader(http.StatusBadRequest) + return + } + + files, err := ioutil.ReadDir(testSuitePathDir) + if err != nil { + log.Fatal(err) + } + + testSuites := make([]Suite, 0) + + for _, file := range files { + if filepath.Ext(testSuitePathDir+file.Name()) == ".xml" { + + testSuite := new(testStrategies.TestSuite) + + filename := file.Name() + + file, err := os.Open(fmt.Sprintf("%s%s", testSuitePathDir, filename)) + if err != nil { + logrus.Error("Cannot open file: ", filename) + } + + byteValue, err := ioutil.ReadAll(file) + if err != nil { + logrus.Error("Cannot Read File: ", filename) + } + + err = xml.Unmarshal(byteValue, testSuite) + if err != nil { + logrus.Error("Cannot Unmarshall: ", filename) + + } + + //if a Test Suite Name can't be assigned, it isn't a Test Suite object + if testSuite.Name != "" { + testSuites = append(testSuites, Suite{ + Name: testSuite.Name, + Description: testSuite.Description, + File: filename, + TestStrategy: testSuite.TestStrategy, + TestCases: testSuite.TestCases, + }) + } + } + } + + json.NewEncoder(rw).Encode(testSuites) + + rw.WriteHeader(http.StatusOK) +} From 1630bdaaba0535f07f2e862434781bc01c626193 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Mon, 5 Mar 2018 09:59:15 +0000 Subject: [PATCH 36/82] get one method on ui side --- ui-src/src/app/automated-ui-services.ts | 8 +++++++- ui-src/src/app/test-cases/test-cases.component.html | 2 +- ui-src/src/app/test-cases/test-cases.component.ts | 10 ++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ui-src/src/app/automated-ui-services.ts b/ui-src/src/app/automated-ui-services.ts index 30eb701..081882e 100644 --- a/ui-src/src/app/automated-ui-services.ts +++ b/ui-src/src/app/automated-ui-services.ts @@ -55,8 +55,14 @@ export class AutomatedUIServices { return this.http.post(`${environment.apiBaseUrl}test-cases`, testCaseData, { headers: this.headers }); + } - + getOneTestCase$(testCasePath, testCaseFileName): Observable { + this.headers = this.headers.set("testCasePathDir", testCasePath); + return this.http.get(`${environment.apiBaseUrl}test-cases/${testCaseFileName}`, { + headers: this.headers + }); } + } diff --git a/ui-src/src/app/test-cases/test-cases.component.html b/ui-src/src/app/test-cases/test-cases.component.html index df76449..a3e95c7 100644 --- a/ui-src/src/app/test-cases/test-cases.component.html +++ b/ui-src/src/app/test-cases/test-cases.component.html @@ -16,7 +16,7 @@ Description Http Method - + {{testCase.name}} {{testCase.description}} {{testCase.httpMethod}} diff --git a/ui-src/src/app/test-cases/test-cases.component.ts b/ui-src/src/app/test-cases/test-cases.component.ts index 8bbabdd..87141ef 100644 --- a/ui-src/src/app/test-cases/test-cases.component.ts +++ b/ui-src/src/app/test-cases/test-cases.component.ts @@ -14,6 +14,7 @@ export class TestCasesComponent implements OnInit { testCaseData = {}; testCasePath = undefined; testCaseSchema = { layout: true }; + testCaseFileName = undefined; constructor( private automatedUIServices: AutomatedUIServices, @@ -30,6 +31,8 @@ export class TestCasesComponent implements OnInit { } + + onAdd() { this.automatedUIServices.getAllCases$(this.testCasePath).subscribe( (data: any) => { @@ -59,6 +62,13 @@ export class TestCasesComponent implements OnInit { ); } + + onSelectCase(testCase, i) { + this.testCaseData = testCase; + this.testCaseFileName = testCase.name + + } + onDelete() { } onSave(testCaseData) { From 55cc123f1a1f524695c237bba961da7e9080a1fd Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Mon, 5 Mar 2018 11:38:40 +0000 Subject: [PATCH 37/82] get one working from ui, just need to edit from go lang side --- ui-src/src/app/test-cases/test-cases.component.html | 4 ++-- ui-src/src/app/test-cases/test-cases.component.ts | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ui-src/src/app/test-cases/test-cases.component.html b/ui-src/src/app/test-cases/test-cases.component.html index a3e95c7..4bc6e4b 100644 --- a/ui-src/src/app/test-cases/test-cases.component.html +++ b/ui-src/src/app/test-cases/test-cases.component.html @@ -1,7 +1,7 @@
- +
@@ -16,7 +16,7 @@ Description Http Method - + {{testCase.name}} {{testCase.description}} {{testCase.httpMethod}} diff --git a/ui-src/src/app/test-cases/test-cases.component.ts b/ui-src/src/app/test-cases/test-cases.component.ts index 87141ef..8084a67 100644 --- a/ui-src/src/app/test-cases/test-cases.component.ts +++ b/ui-src/src/app/test-cases/test-cases.component.ts @@ -15,7 +15,7 @@ export class TestCasesComponent implements OnInit { testCasePath = undefined; testCaseSchema = { layout: true }; testCaseFileName = undefined; - + testCases = []; constructor( private automatedUIServices: AutomatedUIServices, private toastr: ToastsManager, @@ -36,8 +36,7 @@ export class TestCasesComponent implements OnInit { onAdd() { this.automatedUIServices.getAllCases$(this.testCasePath).subscribe( (data: any) => { - this.testCaseData = data; - + this.testCases = data; this.toastr.success("Your data has been saved!", "Success!"); }, From 4defedcf002d94531ce3a2b2daedd57952134517 Mon Sep 17 00:00:00 2001 From: "Farcas, Camelia" Date: Mon, 5 Mar 2018 15:48:26 +0000 Subject: [PATCH 38/82] XAPTC-63 delete all test cases --- main.go | 11 +++---- uiServices/src/configServices.go | 10 +++---- uiServices/src/homepage.go | 3 +- uiServices/src/testCaseServices.go | 33 +++++++++++++++++--- uiServices/src/testCaseServices_test.go | 40 ++++++++++++++++++++----- 5 files changed, 74 insertions(+), 23 deletions(-) diff --git a/main.go b/main.go index 9ee0a3a..b94a697 100644 --- a/main.go +++ b/main.go @@ -5,14 +5,15 @@ import ( "encoding/xml" "flag" "fmt" - log "github.com/Sirupsen/logrus" - "github.com/xtracdev/automated-perf-test/perfTestUtils" - "github.com/xtracdev/automated-perf-test/testStrategies" - "github.com/xtracdev/automated-perf-test/uiServices/src" "io/ioutil" "net/http" "os" "time" + + log "github.com/Sirupsen/logrus" + "github.com/xtracdev/automated-perf-test/perfTestUtils" + "github.com/xtracdev/automated-perf-test/testStrategies" + "github.com/xtracdev/automated-perf-test/uiServices/src" ) //----- Globals ------------------------------------------------------------------ @@ -147,7 +148,7 @@ func initConfig(args []string, fs perfTestUtils.FileSystem, exit func(code int)) // Start server for the User Interface Mode if uiMode { - services.StartUiMode() + services.StartUIMode() } setLogLevel(boolVerbose, boolDebug) diff --git a/uiServices/src/configServices.go b/uiServices/src/configServices.go index e44e558..7fc1fca 100644 --- a/uiServices/src/configServices.go +++ b/uiServices/src/configServices.go @@ -1,4 +1,3 @@ - package services import ( @@ -35,7 +34,10 @@ func ValidateFileNameAndHeader(rw http.ResponseWriter, req *http.Request, header rw.WriteHeader(http.StatusBadRequest) return false } + return true && IsHeaderValid(header, rw) +} +func IsHeaderValid(header string, rw http.ResponseWriter) bool { if len(header) <= 1 { logrus.Error("No Header Path Found") rw.WriteHeader(http.StatusBadRequest) @@ -43,7 +45,6 @@ func ValidateFileNameAndHeader(rw http.ResponseWriter, req *http.Request, header } return true } - func ConfigCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { next.ServeHTTP(w, r) @@ -195,19 +196,18 @@ func putConfigs(rw http.ResponseWriter, req *http.Request) { rw.WriteHeader(http.StatusNoContent) } - func putConfigFileName(rw http.ResponseWriter, req *http.Request) { path := getConfigHeader(req) configFileName := chi.URLParam(req, "configFileName") newConfigFileName := chi.URLParam(req, "newConfigFileName") - if len(newConfigFileName) < 1{ + if len(newConfigFileName) < 1 { logrus.Error("File path does not exist") rw.WriteHeader(http.StatusBadRequest) return } - os.Rename(fmt.Sprintf("%s%s.xml", path, configFileName),fmt.Sprintf("%s%s.xml", path, newConfigFileName)) + os.Rename(fmt.Sprintf("%s%s.xml", path, configFileName), fmt.Sprintf("%s%s.xml", path, newConfigFileName)) rw.WriteHeader(http.StatusNoContent) } diff --git a/uiServices/src/homepage.go b/uiServices/src/homepage.go index e37d403..9e41890 100644 --- a/uiServices/src/homepage.go +++ b/uiServices/src/homepage.go @@ -126,6 +126,7 @@ func routeTestCases() http.Handler { router.Use(TestCaseCtx) router.Get("/", getAllTestCases) router.Get("/{testCaseName}", getTestCase) + router.Delete("/all", deleteAllTestCases) return router -} \ No newline at end of file +} diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index 6e247b1..06b746b 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -10,9 +10,10 @@ import ( "os" "path/filepath" "strings" + "github.com/Sirupsen/logrus" - "github.com/xtracdev/automated-perf-test/testStrategies" "github.com/go-chi/chi" + "github.com/xtracdev/automated-perf-test/testStrategies" ) type Case struct { @@ -54,7 +55,7 @@ func getAllTestCases(rw http.ResponseWriter, req *http.Request) { testCases := make([]Case, 0) for _, file := range files { - if filepath.Ext(testCasePathDir +file.Name()) == ".xml" { + if filepath.Ext(testCasePathDir+file.Name()) == ".xml" { testCase := new(testStrategies.TestDefinition) @@ -87,7 +88,7 @@ func getAllTestCases(rw http.ResponseWriter, req *http.Request) { } err = json.NewEncoder(rw).Encode(testCases) - if err != nil{ + if err != nil { logrus.Error("Could not enocde Test Cases") rw.WriteHeader(http.StatusInternalServerError) return @@ -137,4 +138,28 @@ func getTestCase(rw http.ResponseWriter, req *http.Request) { rw.WriteHeader(http.StatusOK) rw.Write(testSuiteJSON) -} \ No newline at end of file +} + +func deleteAllTestCases(rw http.ResponseWriter, req *http.Request) { + testCasePathDir := getTestCaseHeader(req) + + if !IsHeaderValid(testCasePathDir, rw) { + return + } + + files, err := ioutil.ReadDir(testCasePathDir) + if err != nil { + log.Fatal(err) + } + + for _, file := range files { + err := os.RemoveAll(filepath.Join(testCasePathDir, file.Name())) + if err != nil { + logrus.Errorf("Error deleting the files from filesystem: %s", err) + rw.WriteHeader(http.StatusInternalServerError) + return + } + + rw.WriteHeader(http.StatusNoContent) + } +} diff --git a/uiServices/src/testCaseServices_test.go b/uiServices/src/testCaseServices_test.go index bdc450d..df0b5b6 100644 --- a/uiServices/src/testCaseServices_test.go +++ b/uiServices/src/testCaseServices_test.go @@ -1,15 +1,18 @@ package services import ( - "github.com/go-chi/chi" + "fmt" + "io/ioutil" "net/http" "net/http/httptest" "os" "testing" + + "github.com/Sirupsen/logrus" + "github.com/go-chi/chi" "github.com/stretchr/testify/assert" ) - func TestSuccessfulGetAllCases(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) @@ -23,7 +26,7 @@ func TestSuccessfulGetAllCases(t *testing.T) { w := httptest.NewRecorder() r.ServeHTTP(w, request) - if assert.NoError(t,err) { + if assert.NoError(t, err) { assert.Equal(t, http.StatusOK, w.Code, "Did not get all test cases") } } @@ -41,12 +44,11 @@ func TestGetAllCasesNoHeader(t *testing.T) { w := httptest.NewRecorder() r.ServeHTTP(w, request) - if assert.NoError(t,err) { + if assert.NoError(t, err) { assert.Equal(t, http.StatusBadRequest, w.Code, "Did not get all test cases") } } - //func TestSuccessfulGetTestCase(t *testing.T) { // r := chi.NewRouter() // r.Mount("/", GetIndexPage()) @@ -84,7 +86,7 @@ func TestGetTestCaseNoHeader(t *testing.T) { t.Error(err) } - assert.Equal(t,http.StatusBadRequest, w.Code, "Should not return data") + assert.Equal(t, http.StatusBadRequest, w.Code, "Should not return data") } func TestGetTestCaseFileNotFound(t *testing.T) { @@ -104,5 +106,27 @@ func TestGetTestCaseFileNotFound(t *testing.T) { t.Error(err) } - assert.Equal(t,http.StatusNotFound, w.Code, "Should not return data") -} \ No newline at end of file + assert.Equal(t, http.StatusNotFound, w.Code, "Should not return data") +} + +func testDeleteAllCases(t *testing.T) { + r := chi.NewRouter() + r.Mount("/", GetIndexPage()) + + DirectoryPath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" + err := ioutil.WriteFile(fmt.Sprintf("%s%s.xml", DirectoryPath, "test"), nil, 0666) + if err != nil { + logrus.Errorf("Error trying to create a file", err) + } + + request, err := http.NewRequest(http.MethodDelete, "/test-cases/all", nil) + if err != nil { + logrus.Errorf("Error trying to delete files", err) + } + + request.Header.Set("testCasePathDir", DirectoryPath) + w := httptest.NewRecorder() + r.ServeHTTP(w, request) + assert.Equal(t, http.StatusNoContent, w.Code, "all files deleted : 204") + +} From 6cefca501856d9c76f424d20344cf2befc151d67 Mon Sep 17 00:00:00 2001 From: "Smyth, Conor" Date: Mon, 5 Mar 2018 16:02:23 +0000 Subject: [PATCH 39/82] Merge branch 'master' of https://github.com/xtracdev/automated-perf-test into feature/XAPTC-63 # Conflicts: # uiServices/src/homepage.go # uiServices/src/testCaseServices.go # uiServices/src/testCaseServices_test.go --- uiServices/test/GodogConfig.xml | 19 ++++++++++++++++++ uiServices/test/GodogTestCase.xml | 29 +++++++++++++++++++++++++++ uiServices/test/GodogTestCase2.xml | 29 +++++++++++++++++++++++++++ uiServices/test/GodogTestSuite.xml | 8 ++++++++ uiServices/test/ServiceTestConfig.xml | 19 ++++++++++++++++++ uiServices/test/TestCaseService.xml | 29 +++++++++++++++++++++++++++ uiServices/test/TestSuiteService.xml | 9 +++++++++ uiServices/test/x.xml | 19 ++++++++++++++++++ 8 files changed, 161 insertions(+) create mode 100644 uiServices/test/GodogConfig.xml create mode 100644 uiServices/test/GodogTestCase.xml create mode 100644 uiServices/test/GodogTestCase2.xml create mode 100644 uiServices/test/GodogTestSuite.xml create mode 100644 uiServices/test/ServiceTestConfig.xml create mode 100644 uiServices/test/TestCaseService.xml create mode 100644 uiServices/test/TestSuiteService.xml create mode 100644 uiServices/test/x.xml diff --git a/uiServices/test/GodogConfig.xml b/uiServices/test/GodogConfig.xml new file mode 100644 index 0000000..0cdd26b --- /dev/null +++ b/uiServices/test/GodogConfig.xml @@ -0,0 +1,19 @@ + + GodogAPI + localhost + 1001 + 4000 + 50 + 50 + ./definitions/testCases + ./definitions/testSuites + ./envStats + ./report + 50 + Default-3 + /alt/debug/vars + 1000 + 10 + 10 + 10 + \ No newline at end of file diff --git a/uiServices/test/GodogTestCase.xml b/uiServices/test/GodogTestCase.xml new file mode 100644 index 0000000..c70ab2d --- /dev/null +++ b/uiServices/test/GodogTestCase.xml @@ -0,0 +1,29 @@ + + GodogTestCase + host + 1001 + POST + desc + path/to/URI + false + payload + + + F-Name + PayloadName + file-name + + + + 200 + JSON + +
Header-Value
+
+ + Res-Value + + 1000 + 2000 + Sparse +
\ No newline at end of file diff --git a/uiServices/test/GodogTestCase2.xml b/uiServices/test/GodogTestCase2.xml new file mode 100644 index 0000000..b7a8604 --- /dev/null +++ b/uiServices/test/GodogTestCase2.xml @@ -0,0 +1,29 @@ + + GodogTestCase2 + host + 9191 + PUT + desc2 + path/to/URI + false + payload + + + F-Name + PayloadName + file-name + + + + 200 + JSON + +
Header-Value
+
+ + Res-Value + + 1000 + 2000 + Sparse +
\ No newline at end of file diff --git a/uiServices/test/GodogTestSuite.xml b/uiServices/test/GodogTestSuite.xml new file mode 100644 index 0000000..816379d --- /dev/null +++ b/uiServices/test/GodogTestSuite.xml @@ -0,0 +1,8 @@ + + GodogTestSuite2 + ServiceDesc + SuiteBased + + file1 + + \ No newline at end of file diff --git a/uiServices/test/ServiceTestConfig.xml b/uiServices/test/ServiceTestConfig.xml new file mode 100644 index 0000000..b8211ad --- /dev/null +++ b/uiServices/test/ServiceTestConfig.xml @@ -0,0 +1,19 @@ + + ServiceTestConfig + localhost + 9191 + 1000 + 30 + 30 + ./definitions/testCases + ./definitions/testSuites + ./envStats + ./report + 50 + Default-1 + /alt/debug/vars + 5000 + 30 + 5 + 15 + \ No newline at end of file diff --git a/uiServices/test/TestCaseService.xml b/uiServices/test/TestCaseService.xml new file mode 100644 index 0000000..2b6ce3a --- /dev/null +++ b/uiServices/test/TestCaseService.xml @@ -0,0 +1,29 @@ + + TestCaseService + host + 9191 + GET + desc + path/to/URI + false + payload + + + F-Name + PayloadName + file-name + + + + 200 + JSON + +
Header-Value
+
+ + Res-Value + + 1000 + 2000 + Sparse +
\ No newline at end of file diff --git a/uiServices/test/TestSuiteService.xml b/uiServices/test/TestSuiteService.xml new file mode 100644 index 0000000..f6e6e90 --- /dev/null +++ b/uiServices/test/TestSuiteService.xml @@ -0,0 +1,9 @@ + + TestSuiteService + Services for XYZ + SuiteBased + + file1 + file2 + + \ No newline at end of file diff --git a/uiServices/test/x.xml b/uiServices/test/x.xml new file mode 100644 index 0000000..d2c91c6 --- /dev/null +++ b/uiServices/test/x.xml @@ -0,0 +1,19 @@ + + x + localhost + 9191 + 1000 + 30 + 30 + ./definitions/testCases + ./definitions/testSuites + ./envStats + ./report + 50 + Default-1 + /alt/debug/vars + 5000 + 30 + 5 + 15 + \ No newline at end of file From eeaa7e9138415e12dcf184e4b3669ebbe9b29c66 Mon Sep 17 00:00:00 2001 From: "Farcas, Camelia" Date: Mon, 5 Mar 2018 16:09:31 +0000 Subject: [PATCH 40/82] XAPTC-63 delete all test cases (one file added) --- uiServices/src/testCaseServices_test.go | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/uiServices/src/testCaseServices_test.go b/uiServices/src/testCaseServices_test.go index df0b5b6..c97f553 100644 --- a/uiServices/src/testCaseServices_test.go +++ b/uiServices/src/testCaseServices_test.go @@ -49,26 +49,6 @@ func TestGetAllCasesNoHeader(t *testing.T) { } } -//func TestSuccessfulGetTestCase(t *testing.T) { -// r := chi.NewRouter() -// r.Mount("/", GetIndexPage()) -// -// filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" -// request, err := http.NewRequest(http.MethodGet, "/test-cases/Case1", nil) -// -// request.Header.Set("testCasePathDir", filePath) -// request.Header.Get("testCasePathDir") -// -// w := httptest.NewRecorder() -// r.ServeHTTP(w, request) -// -// if err != nil { -// t.Error(err) -// } -// -// assert.Equal(t,http.StatusOK, w.Code, "Error. Did not successfully GET") -//} - func TestGetTestCaseNoHeader(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) From 5a1b7db8cde65e33e1f735d80b69afffa6ec9fda Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Tue, 6 Mar 2018 10:39:28 +0000 Subject: [PATCH 41/82] put method working --- config/TestCase.xml | 85 +++++-------------- ui-src/src/app/automated-ui-services.ts | 10 ++- .../configurations.component.html | 1 - .../app/test-cases/test-cases.component.html | 7 +- .../app/test-cases/test-cases.component.ts | 57 +++++++++++-- uiServices/src/testCaseServices.go | 67 ++++++++++----- 6 files changed, 128 insertions(+), 99 deletions(-) diff --git a/config/TestCase.xml b/config/TestCase.xml index a7c9d3e..681d247 100644 --- a/config/TestCase.xml +++ b/config/TestCase.xml @@ -1,63 +1,22 @@ - - - - -TestCase - -host - -9191 - -GET - -desc - -path/to/URI - -false - -payload - - - - - - - -F-Name - -PayloadName - -file-name - - - - - - - -200 - -JSON - - - - -
Header-Value
- -
- - - - -Res-Value - - - -1000 - -2000 - -Sparse - -
\ No newline at end of file + + tester + host + 9191 + POST + desc + 1232 + false + payload + + 200 + life + +
1
+
+ + 1 + + 1 + 1 + Sparse +
\ No newline at end of file diff --git a/ui-src/src/app/automated-ui-services.ts b/ui-src/src/app/automated-ui-services.ts index 081882e..803026c 100644 --- a/ui-src/src/app/automated-ui-services.ts +++ b/ui-src/src/app/automated-ui-services.ts @@ -57,12 +57,20 @@ export class AutomatedUIServices { }); } - getOneTestCase$(testCasePath, testCaseFileName): Observable { + getOneTestCase$(testCaseData, testCasePath, testCaseFileName): Observable { this.headers = this.headers.set("testCasePathDir", testCasePath); return this.http.get(`${environment.apiBaseUrl}test-cases/${testCaseFileName}`, { headers: this.headers }); } + putTestCase$(testCaseData, testCasePath, testCaseFileName): Observable { + this.headers = this.headers.set("testCasePathDir", testCasePath); + return this.http.put( + `${environment.apiBaseUrl}test-cases/${testCaseFileName}`, + testCaseData, + { headers: this.headers } + ); + } } diff --git a/ui-src/src/app/configurations/configurations.component.html b/ui-src/src/app/configurations/configurations.component.html index 9d47c5d..9adbfbd 100644 --- a/ui-src/src/app/configurations/configurations.component.html +++ b/ui-src/src/app/configurations/configurations.component.html @@ -13,7 +13,6 @@
-
diff --git a/ui-src/src/app/test-cases/test-cases.component.html b/ui-src/src/app/test-cases/test-cases.component.html index 4bc6e4b..41fb3b6 100644 --- a/ui-src/src/app/test-cases/test-cases.component.html +++ b/ui-src/src/app/test-cases/test-cases.component.html @@ -17,9 +17,9 @@ Http Method - {{testCase.name}} + {{testCase.testname}} {{testCase.description}} - {{testCase.httpMethod}} + {{testCase.HttpMethod}}
@@ -30,8 +30,9 @@
- + +
diff --git a/ui-src/src/app/test-cases/test-cases.component.ts b/ui-src/src/app/test-cases/test-cases.component.ts index 8084a67..eb24448 100644 --- a/ui-src/src/app/test-cases/test-cases.component.ts +++ b/ui-src/src/app/test-cases/test-cases.component.ts @@ -16,6 +16,8 @@ export class TestCasesComponent implements OnInit { testCaseSchema = { layout: true }; testCaseFileName = undefined; testCases = []; + + constructor( private automatedUIServices: AutomatedUIServices, private toastr: ToastsManager, @@ -30,16 +32,12 @@ export class TestCasesComponent implements OnInit { }); } - - - onAdd() { this.automatedUIServices.getAllCases$(this.testCasePath).subscribe( (data: any) => { this.testCases = data; this.toastr.success("Your data has been saved!", "Success!"); }, - error => { switch (error.status) { case 500: { @@ -61,11 +59,9 @@ export class TestCasesComponent implements OnInit { ); } - onSelectCase(testCase, i) { this.testCaseData = testCase; this.testCaseFileName = testCase.name - } onDelete() { } @@ -100,9 +96,54 @@ export class TestCasesComponent implements OnInit { } ); } - onCancel() { - this.testCaseData = undefined; + onUpdate(testCaseData) { + console.log(testCaseData.testname, "in update"); + this.automatedUIServices + .putTestCase$(testCaseData, this.testCasePath, testCaseData.testname) + .subscribe( + data => { + this.toastr.success("Success!"); + }, + error => { + switch (error.status) { + case 404: { + console.log(this.testCasePath, "404"); + this.toastr.error("File not found", "An error occured!"); + break; + } + case 400: { + this.toastr.error( + "File must be specified!", + "An error occurred!" + ); + break; + } + case 500: { + this.toastr.error("Internal server error!"); + break; + } + default: { + this.toastr.error("File was not updated!", "An error occurred!"); + } + } + } + ); + } + + onCancel(testCaseData) { + console.log(testCaseData.testname, "in cancel"); + this.automatedUIServices + .getOneTestCase$(testCaseData, this.testCasePath, testCaseData.testname) + .subscribe( + data => { + this.testCaseData = data; + this.toastr.success("Previous data reloaded!"); + }, + error => { + this.testCaseData = undefined; + } + ); } } diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index d7a0173..0948d65 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -1,32 +1,42 @@ package services import ( + "bytes" "encoding/json" + "encoding/xml" "fmt" + "io/ioutil" "net/http" + "os" + "path/filepath" "strings" + "github.com/Sirupsen/logrus" - "github.com/xtracdev/automated-perf-test/testStrategies" - "bytes" "github.com/go-chi/chi" - "encoding/xml" - "io/ioutil" - "os" - "path/filepath" + "github.com/xtracdev/automated-perf-test/testStrategies" ) const testCaseSchema string = "testCase_schema.json" const structTypeName string = "TestCase " type Case struct { - HttpMethod string `json:"httpMethod"` - Name string `json:"name"` - Description string `json:"description"` + HttpMethod string `json:"HttpMethod"` + Name string `json:"testname"` + Description string `json:"description"` + OverrideHost string `json:"overrideHost"` + OverridePort string `json:"overridePort"` + BaseURI string `json:"BaseURI"` + Multipart bool `json:"multipart"` + ResponseStatusCode int `json:"responseStatusCode"` + ResponseContentType string `json:"responseContentType"` + PreThinkTime int64 `json:"preThinkTime"` + PostThinkTime int64 `json:"postThinkTime"` + ExecWeight string `json:"execWeight"` + Payload string `json:"payload"` + Headers []testStrategies.Header `json:"Headers"` + ResponseValues []testStrategies.ResponseValue `json:"ResponseValues"` } - - - func TestCaseCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { next.ServeHTTP(w, r) @@ -73,7 +83,7 @@ func postTestCase(rw http.ResponseWriter, req *http.Request) { } - if !testCaseWriterXml(testCase, testCasePathDir + testCase.TestName+".xml") { + if !testCaseWriterXml(testCase, testCasePathDir+testCase.TestName+".xml") { rw.WriteHeader(http.StatusInternalServerError) return } @@ -114,7 +124,7 @@ func putTestCase(rw http.ResponseWriter, req *http.Request) { return } - if len(testCase.TestName) < 1{ + if len(testCase.TestName) < 1 { logrus.Error("No TestName Entered") rw.WriteHeader(http.StatusBadRequest) return @@ -145,7 +155,7 @@ func getAllTestCases(rw http.ResponseWriter, req *http.Request) { testCases := make([]Case, 0) for _, file := range files { - if filepath.Ext(testCasePathDir +file.Name()) == ".xml" { + if filepath.Ext(testCasePathDir+file.Name()) == ".xml" { testCase := new(testStrategies.TestDefinition) @@ -153,35 +163,47 @@ func getAllTestCases(rw http.ResponseWriter, req *http.Request) { file, err := os.Open(fmt.Sprintf("%s%s", testCasePathDir, filename)) if err != nil { - logrus.Error("Cannot Open File: "+ filename) + logrus.Error("Cannot Open File: " + filename) continue } byteValue, err := ioutil.ReadAll(file) if err != nil { - logrus.Error("Cannot Read File: "+ filename) + logrus.Error("Cannot Read File: " + filename) continue } err = xml.Unmarshal(byteValue, testCase) if err != nil { - logrus.Error("Cannot Unmarshall File: "+ filename) + logrus.Error("Cannot Unmarshall File: " + filename) continue } //if a Test Case Name can't be assigned, it isn't a Test Case object if testCase.TestName != "" { testCases = append(testCases, Case{ - Name: testCase.TestName, - Description: testCase.Description, - HttpMethod: testCase.HTTPMethod, + Name: testCase.TestName, + Description: testCase.Description, + HttpMethod: testCase.HTTPMethod, + BaseURI: testCase.BaseURI, + OverrideHost: testCase.OverrideHost, + OverridePort: testCase.OverridePort, + Multipart: testCase.Multipart, + ResponseStatusCode: testCase.ResponseStatusCode, + ResponseContentType: testCase.ResponseContentType, + PreThinkTime: testCase.PreThinkTime, + PostThinkTime: testCase.PostThinkTime, + ExecWeight: testCase.ExecWeight, + Headers: testCase.Headers, + ResponseValues: testCase.ResponseValues, + Payload: testCase.Payload, }) } } } err = json.NewEncoder(rw).Encode(testCases) - if err != nil{ + if err != nil { logrus.Error("Could not enocde Test Cases") rw.WriteHeader(http.StatusInternalServerError) return @@ -240,4 +262,3 @@ func getTestCase(rw http.ResponseWriter, req *http.Request) { rw.Write(testSuiteJSON) } - From dcf88269291d5b03f588572f126d0f57cbd09d76 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Tue, 6 Mar 2018 13:50:03 +0000 Subject: [PATCH 42/82] cancel button working, schema form not working correctly --- config/TestCase.xml | 2 +- config/ange.xml | 22 +++++++++++ ui-src/src/app/automated-ui-services.ts | 2 +- .../app/test-cases/test-cases.component.html | 5 +-- .../app/test-cases/test-cases.component.ts | 19 ++++++---- ui-src/src/assets/testCase_schema.json | 38 ++++++++++++++++++- ui-src/src/styles.css | 1 + uiServices/src/testCaseServices.go | 2 +- 8 files changed, 75 insertions(+), 16 deletions(-) create mode 100644 config/ange.xml diff --git a/config/TestCase.xml b/config/TestCase.xml index 681d247..2df5ad0 100644 --- a/config/TestCase.xml +++ b/config/TestCase.xml @@ -1,5 +1,5 @@ - tester + TestCase host 9191 POST diff --git a/config/ange.xml b/config/ange.xml new file mode 100644 index 0000000..59d71b3 --- /dev/null +++ b/config/ange.xml @@ -0,0 +1,22 @@ + + ange + 12 + 32 + GET + 1223423sdasd + 12 + false + 1 + + 1 + 12 + +
tyr
+
+ + rty + + 1 + 1 + Sparse +
\ No newline at end of file diff --git a/ui-src/src/app/automated-ui-services.ts b/ui-src/src/app/automated-ui-services.ts index 803026c..c79824b 100644 --- a/ui-src/src/app/automated-ui-services.ts +++ b/ui-src/src/app/automated-ui-services.ts @@ -57,7 +57,7 @@ export class AutomatedUIServices { }); } - getOneTestCase$(testCaseData, testCasePath, testCaseFileName): Observable { + getOneTestCase$(testCasePath, testCaseFileName): Observable { this.headers = this.headers.set("testCasePathDir", testCasePath); return this.http.get(`${environment.apiBaseUrl}test-cases/${testCaseFileName}`, { headers: this.headers diff --git a/ui-src/src/app/test-cases/test-cases.component.html b/ui-src/src/app/test-cases/test-cases.component.html index 41fb3b6..ad8bc72 100644 --- a/ui-src/src/app/test-cases/test-cases.component.html +++ b/ui-src/src/app/test-cases/test-cases.component.html @@ -25,12 +25,11 @@
- +
- +
diff --git a/ui-src/src/app/test-cases/test-cases.component.ts b/ui-src/src/app/test-cases/test-cases.component.ts index eb24448..c77de3d 100644 --- a/ui-src/src/app/test-cases/test-cases.component.ts +++ b/ui-src/src/app/test-cases/test-cases.component.ts @@ -61,7 +61,8 @@ export class TestCasesComponent implements OnInit { onSelectCase(testCase, i) { this.testCaseData = testCase; - this.testCaseFileName = testCase.name + this.testCaseFileName = testCase.testname + console.log(this.testCaseFileName, "------"); } onDelete() { } @@ -99,6 +100,7 @@ export class TestCasesComponent implements OnInit { onUpdate(testCaseData) { + console.log(testCaseData.testname, "in update"); this.automatedUIServices .putTestCase$(testCaseData, this.testCasePath, testCaseData.testname) @@ -132,18 +134,19 @@ export class TestCasesComponent implements OnInit { ); } - onCancel(testCaseData) { - console.log(testCaseData.testname, "in cancel"); + + + + onCancel() { + this.automatedUIServices - .getOneTestCase$(testCaseData, this.testCasePath, testCaseData.testname) + .getOneTestCase$(this.testCasePath, this.testCaseFileName) .subscribe( data => { this.testCaseData = data; this.toastr.success("Previous data reloaded!"); }, - error => { - this.testCaseData = undefined; - } - ); + + ); } } diff --git a/ui-src/src/assets/testCase_schema.json b/ui-src/src/assets/testCase_schema.json index 2b01083..2075d58 100644 --- a/ui-src/src/assets/testCase_schema.json +++ b/ui-src/src/assets/testCase_schema.json @@ -38,7 +38,7 @@ "payload": { "type": "string" }, - "HttpMethod": { + "httpMethod": { "type": "string", "enum": [ "POST", @@ -104,5 +104,39 @@ } } } - } + }, + "form": [ + "testname", + "description", + "BaseURI", + "overrideHost", + "overridePort", + { + "key": "Headers", + "type": "array" + }, + "httpMethod", + { + "key": "multipart", + "condition": { + "functionBody": "return model.HttpMethod !== 'GET'" + }, + "require": true, + "readonly": false + }, + { + "key": "payload", + "condition": { + "functionBody": "return model.HttpMethod !== 'GET'" + }, + "require": true, + "readonly": false + }, + "preThinkTime", + "postThinkTime", + "execWeight", + "responseStatusCode", + "responseContentType", + "ResponseValues" + ] } \ No newline at end of file diff --git a/ui-src/src/styles.css b/ui-src/src/styles.css index dba64b8..e1ce427 100644 --- a/ui-src/src/styles.css +++ b/ui-src/src/styles.css @@ -3,6 +3,7 @@ @import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500,700'); @import url('https://fonts.googleapis.com/icon?family=Material+Icons'); @import "~@angular/material/prebuilt-themes/indigo-pink.css"; +@import "./app/test-cases/test-cases.component.css"; diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index 0948d65..b989571 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -20,7 +20,7 @@ const testCaseSchema string = "testCase_schema.json" const structTypeName string = "TestCase " type Case struct { - HttpMethod string `json:"HttpMethod"` + HttpMethod string `json:"httpMethod"` Name string `json:"testname"` Description string `json:"description"` OverrideHost string `json:"overrideHost"` From 4567cce530ca5f7c3da7cfbb859dcf9aef7e4c0a Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Tue, 6 Mar 2018 13:53:02 +0000 Subject: [PATCH 43/82] refactor --- config/TestCase.xml | 22 ---------------------- config/TestCase222.xml | 2 +- 2 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 config/TestCase.xml diff --git a/config/TestCase.xml b/config/TestCase.xml deleted file mode 100644 index 2df5ad0..0000000 --- a/config/TestCase.xml +++ /dev/null @@ -1,22 +0,0 @@ - - TestCase - host - 9191 - POST - desc - 1232 - false - payload - - 200 - life - -
1
-
- - 1 - - 1 - 1 - Sparse -
\ No newline at end of file diff --git a/config/TestCase222.xml b/config/TestCase222.xml index f9cf8b1..bff1d4f 100644 --- a/config/TestCase222.xml +++ b/config/TestCase222.xml @@ -2,7 +2,7 @@ -Test222 +TestCase222 host2222 From 3280fba9e89cadae43bf00bda0155d94588cc948 Mon Sep 17 00:00:00 2001 From: a586754 Date: Tue, 6 Mar 2018 14:55:25 +0000 Subject: [PATCH 44/82] Updated Put functionality --- config/ddd.xml | 6 -- config/hhh.xml | 6 -- testStrategies/commonToAllTestStrategies.go | 11 +-- .../test-cases-list.component.html | 12 +-- .../test-cases-list.component.ts | 3 +- .../test-cases-selection.component.html | 14 ++-- .../test-cases-selection.component.ts | 21 +---- .../test-suites/test-suites.component.html | 8 +- .../app/test-suites/test-suites.component.ts | 78 +++++++++---------- 9 files changed, 68 insertions(+), 91 deletions(-) delete mode 100644 config/ddd.xml delete mode 100644 config/hhh.xml diff --git a/config/ddd.xml b/config/ddd.xml deleted file mode 100644 index 68c7f28..0000000 --- a/config/ddd.xml +++ /dev/null @@ -1,6 +0,0 @@ - - ddd - ddd - ServiceBased - - \ No newline at end of file diff --git a/config/hhh.xml b/config/hhh.xml deleted file mode 100644 index 5301e60..0000000 --- a/config/hhh.xml +++ /dev/null @@ -1,6 +0,0 @@ - - hhh - hhh - SuiteBased - - \ No newline at end of file diff --git a/testStrategies/commonToAllTestStrategies.go b/testStrategies/commonToAllTestStrategies.go index 567d949..84bcea5 100644 --- a/testStrategies/commonToAllTestStrategies.go +++ b/testStrategies/commonToAllTestStrategies.go @@ -73,8 +73,8 @@ type TestDefinition struct { // unmarshal is complete. (See TestDefinition above). type TestSuite struct { XMLName xml.Name `xml:"testSuite"` - Name string `xml:"name"` - Description string `xml:"description"` + Name string `xml:"name" json:"name"` + Description string `xml:"description" json:"description"` TestStrategy string `xml:"testStrategy"` TestCases []TestCase `xml:"testCases>testCase"` TestDefinitions []*TestDefinition @@ -86,9 +86,10 @@ type TestSuite struct { type TestCase struct { XMLName xml.Name `xml:"testCase"` Name string `xml:",chardata"` - PreThinkTime int64 `xml:"preThinkTime,attr"` - PostThinkTime int64 `xml:"postThinkTime,attr"` - ExecWeight string `xml:"execWeight,attr"` + Description string `xml:"description,attr" json:"description"` + PreThinkTime int64 `xml:"preThinkTime,attr" json:"preThinkTime"` + PostThinkTime int64 `xml:"postThinkTime,attr" json:"postThinkTime"` + ExecWeight string `xml:"execWeight,attr" json:"execWeight"` } type multipartFormField struct { diff --git a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html index 9e87cc5..5e32bad 100644 --- a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html +++ b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html @@ -1,14 +1,16 @@
- - + + + - - - + + + +
Name DescriptionHttp MethodPre ThinkPost ThinkExec Weight
{{testCase.name}}{{testCase.description}}{{testCase.httpMethod}}{{testCase.description}}{{testCase.preThinkTime}}{{testCase.postThinkTime}}{{testCase.execWeight}}
diff --git a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts index 867f581..8c0fa71 100644 --- a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts +++ b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts @@ -6,14 +6,13 @@ import { Component, Input, Output, EventEmitter } from "@angular/core"; styleUrls: ["./test-cases-list.component.css"] }) export class TestCasesListComponent { - testCaseArray = []; selectedTestCaseData = []; @Input() testCases; @Output() addToSelected = new EventEmitter(); @Output() reverse = new EventEmitter(); selectedCase(testCase, i) { - this.selectedTestCaseData.push(testCase); + this.selectedTestCaseData = testCase; this.addToSelected.emit(this.selectedTestCaseData); this.reverse.emit(i); } diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html index f1b07d0..e52c9f3 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html @@ -1,17 +1,19 @@
-

Available

- +

Available

+
- + - - + +

Selected

- +
\ No newline at end of file diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts index 9aa114e..fad203a 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts @@ -9,29 +9,16 @@ import { TestCaseService } from "../../test-cases/test-case.service"; export class TestCasesSelectionComponent implements OnInit { @Input() testSuiteDirPath; @Input() availableTestCases; - @Input() selectedTestCaseData; + @Input() selectedTestCaseData = []; @Output() addToSelected = new EventEmitter(); @Output() reverse = new EventEmitter(); constructor(private testCaseService: TestCaseService) {} - ngOnInit() { - // this.testCaseService.getAllTestCases$(this.testSuiteDirPath).subscribe( (data) => { - // this.availableTestCases = data; - // }); - } - - selectOne() {} - - deSelectOne() {} - - selectAll() {} - selectNone() {} + ngOnInit() {} onReverse(i) { - this.selectedTestCaseData.splice(i, 1); - this.addToSelected.emit(this.selectedTestCaseData); + this.reverse.emit(i); } - onAddToSelected(e,i) { - this.selectedTestCaseData = e; + onAddToSelected(e, i) { this.addToSelected.emit(e); } } diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index 6a08cc6..96b3bad 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -10,7 +10,7 @@
- + @@ -29,12 +29,12 @@ -
- +
+
- \ No newline at end of file + diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index d395a01..b54e014 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -1,8 +1,8 @@ -import { Component, OnInit, Input } from "@angular/core"; +import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core"; import { TestSuiteService } from "./test-suite.service"; import { TestCaseService } from "../test-cases/test-case.service"; import { ToastsManager } from "ng2-toastr/ng2-toastr"; -import {TestCasesSelectionComponent} from "../shared/test-cases-selection/test-cases-selection.component" +import { TestCasesSelectionComponent } from "../shared/test-cases-selection/test-cases-selection.component"; const TEST_SUITE_PATH = "C:/Users/A586754/go/src/github.com/xtracdev/automated-perf-test/config"; @Component({ @@ -18,6 +18,7 @@ export class TestSuitesComponent { testSuiteData = {}; testCases = []; testSuiteFileName = undefined; + testSuiteFileNameTruncated = undefined; testSuiteSchema = { layout: true }; constructor( private testSuiteService: TestSuiteService, @@ -37,8 +38,8 @@ export class TestSuitesComponent { this.testSuiteService.getAllTestSuite$(TEST_SUITE_PATH).subscribe( data => { this.testSuites = data; - console.log(this.testSuites) - this.toastr.success("Your data has been saved!", "Success!"); + console.log(this.testSuites); + this.toastr.success("Success!"); }, error => { @@ -66,27 +67,39 @@ export class TestSuitesComponent { this.testCaseService .getAllTestCases$(TEST_SUITE_PATH) .subscribe((data: any) => (this.testCases = data)); - } onCancel() { - //clear schema and moving info back into available (get method) - // this.testSuiteService.getTestSuite$(TEST_SUITE_PATH, this.testSuiteFileName) - // .subscribe( - // data => { - // this.testSuiteData = data; - // this.toastr.success("Previous data reloaded!"); - // }, - // error => { - // this.testSuiteData = undefined; - // } - // ); + this.truncateFileName(); + this.testSuiteService + .getTestSuite$(this.testSuitePath, this.testSuiteFileNameTruncated) + .subscribe( + data => { + this.testSuiteData = data; + this.toastr.success("Previous data reloaded!"); + }, + error => { + this.toastr.success("Your data has been cleared", "Success!"); + this.testSuiteData = undefined; + } + ); + } + + truncateFileName() { + if (this.testSuiteFileName) { + this.testSuiteFileNameTruncated = this.testSuiteFileName.substring( + 0, + this.testSuiteFileName.length - 4 + ); + } } + onUpdate(data) { + this.truncateFileName(); this.testCaseArray["testCases"] = this.selectedTestCaseData; Object.assign(data, this.testCaseArray); this.testSuiteService - .putTestSuite$(this.testSuiteData, this.testSuitePath, this.testSuiteFileName) + .putTestSuite$(data, this.testSuitePath, this.testSuiteFileNameTruncated) .subscribe( data => { this.toastr.success("Success!"); @@ -115,10 +128,9 @@ export class TestSuitesComponent { } ); } - onSave(data) { - this.testCaseArray["testCases"] = this.selectedTestCaseData; + this.testCaseArray["testCases"] = this.selectedTestCaseData; Object.assign(data, this.testCaseArray); this.testSuiteService.postTestSuite$(data, TEST_SUITE_PATH).subscribe( data => { @@ -131,7 +143,6 @@ export class TestSuitesComponent { break; } case 400: { - console.log(data); this.toastr.error( "Some of the fields do not conform to the schema!", "An error occurred!" @@ -146,28 +157,15 @@ export class TestSuitesComponent { ); } - onSelectAll() { - this.testCaseService - .getAllTestCases$(TEST_SUITE_PATH) - .subscribe((data: any) => { - // this.selectedTestCaseData = data; - //this.testCaseArray["testCases"] = this.selectedTestCaseData; - }); - } - onSelectSuite(testSuite, i) - { + onSelectSuite(testSuite, i) { this.testSuiteData = testSuite; this.selectedTestCaseData = testSuite.testCases; - this.testSuiteFileName = testSuite.name - - - } - updateSelected(e){ - this.selectedTestCaseData = e; - console.log(e); + this.testSuiteFileName = testSuite.file; + } + updateSelected(e) { + this.selectedTestCaseData.push(e); } - onReverseOne() {} - onReverseAll() { - // this.selectedTestCaseData = undefined; + onReverse(i) { + this.selectedTestCaseData.splice(i, 1); } } From 89ad72bb11e6494eb91200e78b5c4d41b07adea9 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Tue, 6 Mar 2018 15:41:28 +0000 Subject: [PATCH 45/82] edit typos, form in schema still not working with arrays --- config/ange.xml | 2 +- ui-src/src/app/test-cases/test-cases.component.html | 2 +- ui-src/src/app/test-cases/test-cases.component.ts | 12 +++++------- ui-src/src/assets/testCase_schema.json | 11 ++++------- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/config/ange.xml b/config/ange.xml index 59d71b3..94c4eb7 100644 --- a/config/ange.xml +++ b/config/ange.xml @@ -9,7 +9,7 @@ 1 1 - 12 + 1234
tyr
diff --git a/ui-src/src/app/test-cases/test-cases.component.html b/ui-src/src/app/test-cases/test-cases.component.html index ad8bc72..41cac66 100644 --- a/ui-src/src/app/test-cases/test-cases.component.html +++ b/ui-src/src/app/test-cases/test-cases.component.html @@ -19,7 +19,7 @@
- +
Name
{{testCase.testname}} {{testCase.description}}{{testCase.HttpMethod}}{{testCase.httpMethod}}
diff --git a/ui-src/src/app/test-cases/test-cases.component.ts b/ui-src/src/app/test-cases/test-cases.component.ts index c77de3d..fff740a 100644 --- a/ui-src/src/app/test-cases/test-cases.component.ts +++ b/ui-src/src/app/test-cases/test-cases.component.ts @@ -62,7 +62,6 @@ export class TestCasesComponent implements OnInit { onSelectCase(testCase, i) { this.testCaseData = testCase; this.testCaseFileName = testCase.testname - console.log(this.testCaseFileName, "------"); } onDelete() { } @@ -100,8 +99,6 @@ export class TestCasesComponent implements OnInit { onUpdate(testCaseData) { - - console.log(testCaseData.testname, "in update"); this.automatedUIServices .putTestCase$(testCaseData, this.testCasePath, testCaseData.testname) .subscribe( @@ -135,18 +132,19 @@ export class TestCasesComponent implements OnInit { } - - onCancel() { - this.automatedUIServices .getOneTestCase$(this.testCasePath, this.testCaseFileName) .subscribe( data => { this.testCaseData = data; this.toastr.success("Previous data reloaded!"); + }, + error => { + this.testCaseData = undefined; + } - ); + ); } } diff --git a/ui-src/src/assets/testCase_schema.json b/ui-src/src/assets/testCase_schema.json index 2075d58..38a8397 100644 --- a/ui-src/src/assets/testCase_schema.json +++ b/ui-src/src/assets/testCase_schema.json @@ -4,7 +4,7 @@ "testname", "overridePort", "overrideHost", - "HttpMethod", + "httpMethod", "BaseURI", "multipart", "payload", @@ -111,15 +111,12 @@ "BaseURI", "overrideHost", "overridePort", - { - "key": "Headers", - "type": "array" - }, + "Headers", "httpMethod", { "key": "multipart", "condition": { - "functionBody": "return model.HttpMethod !== 'GET'" + "functionBody": "return model.httpMethod !== 'GET'" }, "require": true, "readonly": false @@ -127,7 +124,7 @@ { "key": "payload", "condition": { - "functionBody": "return model.HttpMethod !== 'GET'" + "functionBody": "return model.httpMethod !== 'GET'" }, "require": true, "readonly": false From 2b63d1351b348876e56466b1e8c5b6168a8f907e Mon Sep 17 00:00:00 2001 From: a586754 Date: Wed, 7 Mar 2018 10:09:15 +0000 Subject: [PATCH 46/82] Updates on feedback --- config/TestSuiteService.xml | 8 +-- config/TestSuiteService22.xml | 7 +- config/TestSuiteService444.xml | 4 +- .../test-cases-list.component.css | 16 ++--- .../test-cases-list.component.html | 7 +- .../test-cases-selection.component.html | 13 +--- .../test-cases-selection.component.ts | 8 +-- .../src/app/test-cases/test-case.service.ts | 4 +- .../src/app/test-suites/test-suite.service.ts | 5 -- .../app/test-suites/test-suites.component.css | 53 +++++++------- .../test-suites/test-suites.component.html | 6 +- .../app/test-suites/test-suites.component.ts | 70 +++++++++++-------- uiServices/src/configServices.go | 1 - uiServices/src/homepage.go | 2 +- uiServices/src/testSuiteServices.go | 8 +-- 15 files changed, 100 insertions(+), 112 deletions(-) diff --git a/config/TestSuiteService.xml b/config/TestSuiteService.xml index 0f02978..0a6d738 100644 --- a/config/TestSuiteService.xml +++ b/config/TestSuiteService.xml @@ -1,9 +1,9 @@ - TestSuiteService + TestSuiteService1444 Services for XYZ SuiteBased - file1 - file2 + file1 + file2 - \ No newline at end of file + \ No newline at end of file diff --git a/config/TestSuiteService22.xml b/config/TestSuiteService22.xml index 249936b..e5d0576 100644 --- a/config/TestSuiteService22.xml +++ b/config/TestSuiteService22.xml @@ -1,9 +1,10 @@ - TestSuiteService21 + TestSuiteServiceTest Services 22 SuiteBased - file222 - file2222 + file222 + file2222 + TestCaseService \ No newline at end of file diff --git a/config/TestSuiteService444.xml b/config/TestSuiteService444.xml index a9a2eaa..4930069 100644 --- a/config/TestSuiteService444.xml +++ b/config/TestSuiteService444.xml @@ -3,7 +3,7 @@ Services for XYZ SuiteBased - file1 - file2 + file1 + file2 \ No newline at end of file diff --git a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.css b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.css index b7f71fd..6ee5204 100644 --- a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.css +++ b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.css @@ -1,13 +1,5 @@ -.sortable-wrapper{ - -} - -.place-holder-test-case{ - -} - -.sortable-item{ -} -.sortable-item-active{ - +td, th { + border: 1px solid #dddddd; + padding: 8px; + width: 100%; } \ No newline at end of file diff --git a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html index 5e32bad..f24e860 100644 --- a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html +++ b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.html @@ -2,9 +2,9 @@ - - - + + + @@ -14,3 +14,4 @@
DescriptionPre ThinkPost ThinkExec WeightPre-ThinkPost-ThinkExec-Weight
{{testCase.description}}
+ \ No newline at end of file diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html index e52c9f3..828552a 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html @@ -1,18 +1,9 @@
-
+

Available

-
- - - - - -
-
+

Selected

diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts index fad203a..032cc52 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts @@ -15,10 +15,10 @@ export class TestCasesSelectionComponent implements OnInit { constructor(private testCaseService: TestCaseService) {} ngOnInit() {} - onReverse(i) { - this.reverse.emit(i); + onReverse(selectedIndex) { + this.reverse.emit(selectedIndex); } - onAddToSelected(e, i) { - this.addToSelected.emit(e); + onAddToSelected(testCase, selectedIndex) { + this.addToSelected.emit(testCase); } } diff --git a/ui-src/src/app/test-cases/test-case.service.ts b/ui-src/src/app/test-cases/test-case.service.ts index c6861dc..5fdd6db 100644 --- a/ui-src/src/app/test-cases/test-case.service.ts +++ b/ui-src/src/app/test-cases/test-case.service.ts @@ -12,9 +12,9 @@ export class TestCaseService { this.headers = new HttpHeaders({"Content-Type": "application/json"}); } - getAllTestCases$(testCasesPath): Observable { + getAllCases$(testCasesPath): Observable { this.headers = this.headers.set("testSuitePathDir", testCasesPath); - return this.http.get(`${environment.apiBaseUrl}test-suites` + '/a/a', { + return this.http.get(`${environment.apiBaseUrl}test-suites` + '/getAllCases/', { headers: this.headers }); } diff --git a/ui-src/src/app/test-suites/test-suite.service.ts b/ui-src/src/app/test-suites/test-suite.service.ts index 55b5870..32475f8 100644 --- a/ui-src/src/app/test-suites/test-suite.service.ts +++ b/ui-src/src/app/test-suites/test-suite.service.ts @@ -32,11 +32,6 @@ export class TestSuiteService { headers: this.headers }); } - getSchema$(location: string): Observable { - return this.http - .get(`http://localhost:4200/${location}`, {headers: this.headers}) - .map((data: any) => data); - } putTestSuite$(testSuiteData, testSuitePath, testSuiteFileName): Observable { this.headers = this.headers.set("testSuitePathDir", testSuitePath); diff --git a/ui-src/src/app/test-suites/test-suites.component.css b/ui-src/src/app/test-suites/test-suites.component.css index a242327..d0c6fff 100644 --- a/ui-src/src/app/test-suites/test-suites.component.css +++ b/ui-src/src/app/test-suites/test-suites.component.css @@ -1,41 +1,40 @@ .row { - margin-top: 25px; - margin-bottom: 25px; - } - .button-row { margin-top: 25px;} - .column { - - padding: 0px; - } - - table { - - font-family: arial, sans-serif; - border-collapse: collapse; - width: 100%; - margin-bottom: 25px; + margin-top: 25px; + margin-bottom: 25px; + padding: 10px; +} +.button-row { + margin-top: 25px; +} +.column { + padding: 0px; +} +table { + font-family: arial, sans-serif; + border-collapse: collapse; + width: 90%; + margin-bottom: 25px; + padding-right: 5px; } -td, th { - border: 1px solid #dddddd; - text-align: left; - padding: 8px; +td, +th { + border: 1px solid #dddddd; + text-align: left; + padding: 8px; } tr:nth-child(even) { - background-color: #dddddd; + background-color: #dddddd; } -.btn{ +.btn { margin-bottom: 25px; } -fieldset{ +fieldset { display: none; } -/* label[class|= "control-label"] -{display: none} */ - -submit-widget{ - display : none; +submit-widget { + display: none; } diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index 96b3bad..fc0a207 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -10,7 +10,6 @@
- @@ -32,8 +31,9 @@
- - + + +
diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index b54e014..5916245 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core"; import { TestSuiteService } from "./test-suite.service"; import { TestCaseService } from "../test-cases/test-case.service"; +import { ConfigurationService } from "../configurations/configuration.service"; import { ToastsManager } from "ng2-toastr/ng2-toastr"; import { TestCasesSelectionComponent } from "../shared/test-cases-selection/test-cases-selection.component"; const TEST_SUITE_PATH = @@ -23,11 +24,12 @@ export class TestSuitesComponent { constructor( private testSuiteService: TestSuiteService, private testCaseService: TestCaseService, + private configurationService: ConfigurationService, private toastr: ToastsManager ) {} ngOnInit() { - this.testSuiteService + this.configurationService .getSchema$("assets/testSuite_schema.json") .subscribe((data: any) => { this.testSuiteSchema = data; @@ -38,8 +40,7 @@ export class TestSuitesComponent { this.testSuiteService.getAllTestSuite$(TEST_SUITE_PATH).subscribe( data => { this.testSuites = data; - console.log(this.testSuites); - this.toastr.success("Success!"); + //this.toastr.success("Success!"); }, error => { @@ -65,26 +66,31 @@ export class TestSuitesComponent { getTestCases() { this.testCaseService - .getAllTestCases$(TEST_SUITE_PATH) + .getAllCases$(TEST_SUITE_PATH) .subscribe((data: any) => (this.testCases = data)); } onCancel() { - this.truncateFileName(); - this.testSuiteService - .getTestSuite$(this.testSuitePath, this.testSuiteFileNameTruncated) - .subscribe( - data => { - this.testSuiteData = data; - this.toastr.success("Previous data reloaded!"); - }, - error => { - this.toastr.success("Your data has been cleared", "Success!"); - this.testSuiteData = undefined; - } - ); + // this.truncateFileName(); + // this.testSuiteService + // .getTestSuite$(this.testSuitePath, this.testSuiteFileNameTruncated) + // .subscribe( + // data => { + // this.testSuiteData = data; + // this.toastr.success("Previous data reloaded!"); + // }, + // error => { + // this.toastr.success("Your data has been cleared", "Success!"); + // this.testSuiteData = undefined; + // } + // ); + this.toastr.success("Your data has been cleared", "Success!"); + this.testSuiteData = undefined; + this.selectedTestCaseData = []; + this.testSuiteFileName = undefined; + this.onAdd(); } - + truncateFileName() { if (this.testSuiteFileName) { this.testSuiteFileNameTruncated = this.testSuiteFileName.substring( @@ -94,15 +100,16 @@ export class TestSuitesComponent { } } - onUpdate(data) { + onUpdate(formData) { this.truncateFileName(); this.testCaseArray["testCases"] = this.selectedTestCaseData; - Object.assign(data, this.testCaseArray); + Object.assign(formData, this.testCaseArray); this.testSuiteService - .putTestSuite$(data, this.testSuitePath, this.testSuiteFileNameTruncated) + .putTestSuite$(formData, this.testSuitePath, this.testSuiteFileNameTruncated) .subscribe( data => { this.toastr.success("Success!"); + this.onAdd(); }, error => { switch (error.status) { @@ -129,12 +136,13 @@ export class TestSuitesComponent { ); } - onSave(data) { + onSave(formData) { this.testCaseArray["testCases"] = this.selectedTestCaseData; - Object.assign(data, this.testCaseArray); - this.testSuiteService.postTestSuite$(data, TEST_SUITE_PATH).subscribe( + Object.assign(formData, this.testCaseArray); + this.testSuiteService.postTestSuite$(formData, TEST_SUITE_PATH).subscribe( data => { this.toastr.success("Your data has been saved!", "Success!"); + this.onAdd(); }, error => { switch (error.status) { @@ -154,18 +162,20 @@ export class TestSuitesComponent { } } } - ); + ) } - onSelectSuite(testSuite, i) { + onSelectSuite(testSuite, selectedIndex) { + this.onAdd(); this.testSuiteData = testSuite; this.selectedTestCaseData = testSuite.testCases; this.testSuiteFileName = testSuite.file; } - updateSelected(e) { - this.selectedTestCaseData.push(e); + updateSelected(testCase) { + this.selectedTestCaseData.push(testCase); + } - onReverse(i) { - this.selectedTestCaseData.splice(i, 1); + onReverse(selectedIndex) { + this.selectedTestCaseData.splice(selectedIndex, 1); } } diff --git a/uiServices/src/configServices.go b/uiServices/src/configServices.go index da51b98..73a573d 100644 --- a/uiServices/src/configServices.go +++ b/uiServices/src/configServices.go @@ -156,7 +156,6 @@ func getConfigs(rw http.ResponseWriter, req *http.Request) { } func putConfigs(rw http.ResponseWriter, req *http.Request) { - rw.Header().Set("Access-Control-Allow-Origin", "*") path := getConfigHeader(req) configName := chi.URLParam(req, "configName") diff --git a/uiServices/src/homepage.go b/uiServices/src/homepage.go index f979a72..f338e4e 100644 --- a/uiServices/src/homepage.go +++ b/uiServices/src/homepage.go @@ -70,7 +70,7 @@ func GetIndexPage() *chi.Mux { }) router.Mount("/configs", routeConfigs()) - router.Mount("/test-suites/a/a", routeTestCases()) + router.Mount("/test-suites/getAllCases/", routeTestCases()) router.Mount("/test-suites", routeTestSuites()) router.Get("/*", func(w http.ResponseWriter, r *http.Request) { diff --git a/uiServices/src/testSuiteServices.go b/uiServices/src/testSuiteServices.go index f3ad702..56adbce 100644 --- a/uiServices/src/testSuiteServices.go +++ b/uiServices/src/testSuiteServices.go @@ -62,10 +62,10 @@ func postTestSuites(rw http.ResponseWriter, req *http.Request) { return } - // if !ValidateJsonWithSchema(buf.Bytes(), schemaFile, structType) { - // rw.WriteHeader(http.StatusBadRequest) - // return - // } + if !ValidateJsonWithSchema(buf.Bytes(), schemaFile, structType) { + rw.WriteHeader(http.StatusBadRequest) + return + } if !FilePathExist(testSuitePathDir) { logrus.Error("Directory path does not exist", err) From 8fc074611bfda7f961dfd55dd7935dff707540eb Mon Sep 17 00:00:00 2001 From: "Farcas, Camelia" Date: Wed, 7 Mar 2018 10:22:55 +0000 Subject: [PATCH 47/82] XAPTC-63 DELETE All Test Cases --- uiServices/src/testCaseServices.go | 4 +- uiServices/src/testCaseServices_test.go | 49 ++++++++++++++++++++++--- uiServices/test/testCase.feature | 25 +++++++++++++ 3 files changed, 70 insertions(+), 8 deletions(-) diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index 06b746b..4d7aa66 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -156,10 +156,10 @@ func deleteAllTestCases(rw http.ResponseWriter, req *http.Request) { err := os.RemoveAll(filepath.Join(testCasePathDir, file.Name())) if err != nil { logrus.Errorf("Error deleting the files from filesystem: %s", err) - rw.WriteHeader(http.StatusInternalServerError) + rw.WriteHeader(http.StatusNotFound) return } - rw.WriteHeader(http.StatusNoContent) + rw.WriteHeader(http.StatusOK) } } diff --git a/uiServices/src/testCaseServices_test.go b/uiServices/src/testCaseServices_test.go index c97f553..eef52a5 100644 --- a/uiServices/src/testCaseServices_test.go +++ b/uiServices/src/testCaseServices_test.go @@ -73,7 +73,7 @@ func TestGetTestCaseFileNotFound(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) - filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" + filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/cases" request, err := http.NewRequest(http.MethodGet, "/test-cases/xxx", nil) request.Header.Set("testCasePathDir", filePath) @@ -89,24 +89,61 @@ func TestGetTestCaseFileNotFound(t *testing.T) { assert.Equal(t, http.StatusNotFound, w.Code, "Should not return data") } -func testDeleteAllCases(t *testing.T) { +func TestDeleteAllCasesSuccess(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) - DirectoryPath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" + DirectoryPath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/cases" err := ioutil.WriteFile(fmt.Sprintf("%s%s.xml", DirectoryPath, "test"), nil, 0666) if err != nil { - logrus.Errorf("Error trying to create a file", err) + logrus.Errorf("Error trying to create a file: %s", err) + } + + request, err := http.NewRequest(http.MethodDelete, "/test-cases/all", nil) + if err != nil { + logrus.Warnf("Error creating the request %s", err) } + request.Header.Set("testCasePathDir", DirectoryPath) + + w := httptest.NewRecorder() + r.ServeHTTP(w, request) + + assert.Equal(t, http.StatusOK, w.Code, "All files have been DELETED") + +} + +func TestDeleteAllCasesNoHeader(t *testing.T) { + r := chi.NewRouter() + r.Mount("/", GetIndexPage()) + DirectoryPath := "" request, err := http.NewRequest(http.MethodDelete, "/test-cases/all", nil) if err != nil { - logrus.Errorf("Error trying to delete files", err) + logrus.Warnf("Error creating the request %s", err) } request.Header.Set("testCasePathDir", DirectoryPath) + + w := httptest.NewRecorder() + r.ServeHTTP(w, request) + + assert.Equal(t, http.StatusBadRequest, w.Code, "Did not DELETE the files") +} + +func TestDeleteAllCasesEmptyDirectory(t *testing.T) { + r := chi.NewRouter() + r.Mount("/", GetIndexPage()) + + DirectoryPath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/cases" + request, err := http.NewRequest(http.MethodDelete, "/test-cases/", nil) + if err != nil { + logrus.Warnf("Error creating the request %s", err) + } + + request.Header.Set("testCasePathDir", DirectoryPath) + w := httptest.NewRecorder() r.ServeHTTP(w, request) - assert.Equal(t, http.StatusNoContent, w.Code, "all files deleted : 204") + assert.Equal(t, http.StatusNotFound, w.Code, "Empty Directory") } diff --git a/uiServices/test/testCase.feature b/uiServices/test/testCase.feature index 505937a..a941566 100644 --- a/uiServices/test/testCase.feature +++ b/uiServices/test/testCase.feature @@ -80,3 +80,28 @@ Feature: Test Case Scenarios "ExecWeight": "" } """ + + ################################### + ####### DELETE REQUESTS ######## + ################################### + +Scenario: Unsuccessful deleting of test-case (No Header) + Given the automated performance ui server is available + And the header "testCasePathDir" is "" + When I send a "DELETE" request to "/test-cases/all" + Then the response code should be 400 + + +Scenario: Unsuccessful deleting of test-case file (Empty Directory) + Given the automated performance ui server is available + And the header "testCasePathDir" is "/uiServices/test/cases" + When I send a "DELETE" request to "/test-cases/" + Then the response code should be 404 + + +Scenario: Successful deleting of test-case file with DELETE request + Given the "deleteTest.xml" has been created at "/uiServices/test/cases" + Given the automated performance ui server is available + And the header "testCasePathDir" is "/uiServices/test/cases" + When I send a "DELETE" request to "/test-cases/all" + Then the response code should be 200 From 21ca861cbbaa749378f9b935448e478c38642fb1 Mon Sep 17 00:00:00 2001 From: "Farcas, Camelia" Date: Wed, 7 Mar 2018 10:29:24 +0000 Subject: [PATCH 48/82] Added test files and changed git ignore --- .gitignore | 4 +++- uiServices/test/TestSuiteService.xml | 9 +++++++++ uiServices/test/cases/deleteTest.xml | 0 uiServices/test/casestest.xml | 0 uiServices/test/test.xml | 0 5 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 uiServices/test/TestSuiteService.xml create mode 100644 uiServices/test/cases/deleteTest.xml create mode 100644 uiServices/test/casestest.xml create mode 100644 uiServices/test/test.xml diff --git a/.gitignore b/.gitignore index b846825..70bfbef 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ main .idea ui/ **/node_modules -/.editorconfig \ No newline at end of file +/.editorconfig +config/ +automated-perf-test.exe diff --git a/uiServices/test/TestSuiteService.xml b/uiServices/test/TestSuiteService.xml new file mode 100644 index 0000000..f6e6e90 --- /dev/null +++ b/uiServices/test/TestSuiteService.xml @@ -0,0 +1,9 @@ + + TestSuiteService + Services for XYZ + SuiteBased + + file1 + file2 + + \ No newline at end of file diff --git a/uiServices/test/cases/deleteTest.xml b/uiServices/test/cases/deleteTest.xml new file mode 100644 index 0000000..e69de29 diff --git a/uiServices/test/casestest.xml b/uiServices/test/casestest.xml new file mode 100644 index 0000000..e69de29 diff --git a/uiServices/test/test.xml b/uiServices/test/test.xml new file mode 100644 index 0000000..e69de29 From 1c9762ef0de33a9f78f6a53c382e65dbb3eaa597 Mon Sep 17 00:00:00 2001 From: "Farcas, Camelia" Date: Wed, 7 Mar 2018 11:50:46 +0000 Subject: [PATCH 49/82] XAPTC-63 Delete all test cases and features (last test passed) --- uiServices/src/testCaseServices.go | 32 ++++++++++++------------- uiServices/src/testCaseServices_test.go | 10 ++++---- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index 819ea19..f535e28 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -1,22 +1,22 @@ package services import ( - "encoding/json" - "fmt" - "net/http" - "strings" - "github.com/Sirupsen/logrus" - "github.com/xtracdev/automated-perf-test/testStrategies" "bytes" - "github.com/go-chi/chi" + "encoding/json" "encoding/xml" + "fmt" "io/ioutil" + "net/http" "os" "path/filepath" + "strings" "github.com/Sirupsen/logrus" - "github.com/xtracdev/automated-perf-test/testStrategies" "github.com/go-chi/chi" + "github.com/xtracdev/automated-perf-test/testStrategies" + //"github.com/Sirupsen/logrus" + //"github.com/xtracdev/automated-perf-test/testStrategies" + //"github.com/go-chi/chi" ) const testCaseSchema string = "testCase_schema.json" @@ -28,9 +28,6 @@ type Case struct { Description string `json:"description"` } - - - func TestCaseCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { next.ServeHTTP(w, r) @@ -77,7 +74,7 @@ func postTestCase(rw http.ResponseWriter, req *http.Request) { } - if !testCaseWriterXml(testCase, testCasePathDir + testCase.TestName+".xml") { + if !testCaseWriterXml(testCase, testCasePathDir+testCase.TestName+".xml") { rw.WriteHeader(http.StatusInternalServerError) return } @@ -118,7 +115,7 @@ func putTestCase(rw http.ResponseWriter, req *http.Request) { return } - if len(testCase.TestName) < 1{ + if len(testCase.TestName) < 1 { logrus.Error("No TestName Entered") rw.WriteHeader(http.StatusBadRequest) return @@ -157,19 +154,19 @@ func getAllTestCases(rw http.ResponseWriter, req *http.Request) { file, err := os.Open(fmt.Sprintf("%s%s", testCasePathDir, filename)) if err != nil { - logrus.Error("Cannot Open File: "+ filename) + logrus.Error("Cannot Open File: " + filename) continue } byteValue, err := ioutil.ReadAll(file) if err != nil { - logrus.Error("Cannot Read File: "+ filename) + logrus.Error("Cannot Read File: " + filename) continue } err = xml.Unmarshal(byteValue, testCase) if err != nil { - logrus.Error("Cannot Unmarshall File: "+ filename) + logrus.Error("Cannot Unmarshall File: " + filename) continue } @@ -254,7 +251,8 @@ func deleteAllTestCases(rw http.ResponseWriter, req *http.Request) { files, err := ioutil.ReadDir(testCasePathDir) if err != nil { - log.Fatal(err) + logrus.Error("Cannot read directory ", err) + return } for _, file := range files { diff --git a/uiServices/src/testCaseServices_test.go b/uiServices/src/testCaseServices_test.go index 19df1aa..1e5eed0 100644 --- a/uiServices/src/testCaseServices_test.go +++ b/uiServices/src/testCaseServices_test.go @@ -6,12 +6,14 @@ import ( "net/http" "net/http/httptest" "os" + "strings" "testing" + //"net/http" + "github.com/Sirupsen/logrus" "github.com/go-chi/chi" "github.com/stretchr/testify/assert" - "net/http" ) const validTestCase = ` @@ -93,7 +95,6 @@ const TestCaseMissingRequired = ` } ` - func TestValidTestCasePost(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) @@ -214,7 +215,6 @@ func TestTestCasePutMissingRequired(t *testing.T) { assert.Equal(t, http.StatusBadRequest, w.Code, "Should not have successfully updated") } - func TestInvalidUrlTestCasePut(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) @@ -320,8 +320,6 @@ func TestNoNameTestCasePut(t *testing.T) { assert.Equal(t, http.StatusBadRequest, w.Code, "Successfully updated. Should not have worked due to no filepath") } - - func TestSuccessfulGetAllCases(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) @@ -375,7 +373,7 @@ func TestSuccessfulGetTestCase(t *testing.T) { t.Error(err) } - assert.Equal(t,http.StatusOK, w.Code, "Error. Did not successfully GET") + assert.Equal(t, http.StatusOK, w.Code, "Error. Did not successfully GET") } func TestGetTestCaseNoHeader(t *testing.T) { From 58cc2faa39b40b58c3cc1ce5f8c34bc37a621730 Mon Sep 17 00:00:00 2001 From: a586754 Date: Wed, 7 Mar 2018 13:11:28 +0000 Subject: [PATCH 50/82] Add testSuites to dropdown- Work In progress --- .../configurations.component.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/ui-src/src/app/configurations/configurations.component.ts b/ui-src/src/app/configurations/configurations.component.ts index 822d573..60fb05a 100644 --- a/ui-src/src/app/configurations/configurations.component.ts +++ b/ui-src/src/app/configurations/configurations.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from "@angular/core"; import { HttpClient } from "@angular/common/http"; import { ConfigurationService } from "./configuration.service"; +import { TestSuiteService } from "../test-suites/test-suite.service"; import { JsonSchemaFormModule } from "angular2-json-schema-form"; import { ToastsManager } from "ng2-toastr/ng2-toastr"; import "rxjs/add/operator/map"; @@ -12,6 +13,9 @@ import "rxjs/add/operator/map"; }) export class ConfigurationsComponent implements OnInit { formData = {}; + test = []; + test2 = []; + testArary =[]; configPath = undefined; xmlFileName = undefined; fileName = undefined; @@ -20,6 +24,7 @@ export class ConfigurationsComponent implements OnInit { constructor( private configurationService: ConfigurationService, + private testSuiteService: TestSuiteService, private toastr: ToastsManager, private http: HttpClient @@ -31,9 +36,45 @@ export class ConfigurationsComponent implements OnInit { .subscribe((data: any) => { this.configSchema = data; }); + this.testSuiteService.getAllTestSuite$("C:/Users/A586754/go/src/github.com/xtracdev/automated-perf-test/config").subscribe( + data => { + this.test = data + for (var i = 0; i < this.test.length; i++ ) { + this.testArary.push(this.test[i].name) + this.test2["testSuite"] = this.testArary; + console.log(this.test2) + this.formData = this.test2 + console.log("helloo", this.formData) + } + console.log(this.test[0].name) + console.log(this.testArary) + + //this.toastr.success("Success!"); + }, + + error => { + switch (error.status) { + case 500: { + this.toastr.error("An error has occurred!", "Check the logs!"); + break; + } + case 400: { + this.toastr.error( + "No Test Suite Directory added", + "An error occurred!" + ); + break; + } + default: { + this.toastr.error("An error occurred!"); + } + } + } + ); } onSubmit(configData) { + this.configurationService.postConfig$(configData, this.configPath).subscribe( data => { this.toastr.success("Your data has been saved!", "Success!"); @@ -102,6 +143,7 @@ export class ConfigurationsComponent implements OnInit { .subscribe( data => { this.formData = data; + console.log(this.formData) this.toastr.success("Success!"); }, error => { From 34899f4a8c8a92e6791b6161cf73999302028a74 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Wed, 7 Mar 2018 13:29:36 +0000 Subject: [PATCH 51/82] Change Name column/Title Paste in path, do a GET automatically. Add load buttons --- .../app/test-cases/test-cases.component.css | 31 +++++++++++++++++ .../app/test-cases/test-cases.component.html | 18 ++++++---- .../app/test-cases/test-cases.component.ts | 14 ++++---- ui-src/src/assets/testCase_schema.json | 33 +------------------ 4 files changed, 52 insertions(+), 44 deletions(-) diff --git a/ui-src/src/app/test-cases/test-cases.component.css b/ui-src/src/app/test-cases/test-cases.component.css index 36e3598..54c268b 100644 --- a/ui-src/src/app/test-cases/test-cases.component.css +++ b/ui-src/src/app/test-cases/test-cases.component.css @@ -36,3 +36,34 @@ submit-widget{ display : none; } +h1{ + font-family: arial, sans-serif; + font-weight: bold; + margin-top: 0px; + font-size: 16px; + line-height: 1.42857143; + color: #333; +} + +.load-button { + display: inline-block; + padding: 6px 12px; + margin-bottom: 0; + margin-top: 18px; + font-size: 14px; + font-weight: 400; + line-height: 1.42857143; + text-align: center; + white-space: nowrap; + vertical-align: middle; + -ms-touch-action: manipulation; + touch-action: manipulation; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + background-image: none; + border: 1px solid transparent; + border-radius: 1px; +} \ No newline at end of file diff --git a/ui-src/src/app/test-cases/test-cases.component.html b/ui-src/src/app/test-cases/test-cases.component.html index 41cac66..aca7721 100644 --- a/ui-src/src/app/test-cases/test-cases.component.html +++ b/ui-src/src/app/test-cases/test-cases.component.html @@ -1,13 +1,17 @@
- - +
+ + +
+
+ +
- -
+

Existing Test Cases

Name
@@ -30,9 +34,11 @@
- - + +
+ + \ No newline at end of file diff --git a/ui-src/src/app/test-cases/test-cases.component.ts b/ui-src/src/app/test-cases/test-cases.component.ts index fff740a..0e8cce2 100644 --- a/ui-src/src/app/test-cases/test-cases.component.ts +++ b/ui-src/src/app/test-cases/test-cases.component.ts @@ -32,11 +32,11 @@ export class TestCasesComponent implements OnInit { }); } - onAdd() { + onLoad() { this.automatedUIServices.getAllCases$(this.testCasePath).subscribe( (data: any) => { this.testCases = data; - this.toastr.success("Your data has been saved!", "Success!"); + this.toastr.success("Your Test Cases have loaded!", "Success!"); }, error => { switch (error.status) { @@ -46,7 +46,7 @@ export class TestCasesComponent implements OnInit { } case 400: { this.toastr.error( - "No Test Suite Directory added", + "No Test Case Directory added", "An error occurred!" ); break; @@ -64,6 +64,11 @@ export class TestCasesComponent implements OnInit { this.testCaseFileName = testCase.testname } + onAdd() { + this.testCaseData = undefined; + this.testCaseFileName = undefined; + } + onDelete() { } onSave(testCaseData) { @@ -131,7 +136,6 @@ export class TestCasesComponent implements OnInit { ); } - onCancel() { this.automatedUIServices .getOneTestCase$(this.testCasePath, this.testCaseFileName) @@ -139,12 +143,10 @@ export class TestCasesComponent implements OnInit { data => { this.testCaseData = data; this.toastr.success("Previous data reloaded!"); - }, error => { this.testCaseData = undefined; } - ); } } diff --git a/ui-src/src/assets/testCase_schema.json b/ui-src/src/assets/testCase_schema.json index 38a8397..8df4c6b 100644 --- a/ui-src/src/assets/testCase_schema.json +++ b/ui-src/src/assets/testCase_schema.json @@ -104,36 +104,5 @@ } } } - }, - "form": [ - "testname", - "description", - "BaseURI", - "overrideHost", - "overridePort", - "Headers", - "httpMethod", - { - "key": "multipart", - "condition": { - "functionBody": "return model.httpMethod !== 'GET'" - }, - "require": true, - "readonly": false - }, - { - "key": "payload", - "condition": { - "functionBody": "return model.httpMethod !== 'GET'" - }, - "require": true, - "readonly": false - }, - "preThinkTime", - "postThinkTime", - "execWeight", - "responseStatusCode", - "responseContentType", - "ResponseValues" - ] + } } \ No newline at end of file From ca64f0457ab399f6350e825083c2028b2e23d39d Mon Sep 17 00:00:00 2001 From: a586754 Date: Wed, 7 Mar 2018 14:49:19 +0000 Subject: [PATCH 52/82] refactor --- .../configurations.component.html | 2 +- .../configurations.component.ts | 58 ++++++++++++++++--- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/ui-src/src/app/configurations/configurations.component.html b/ui-src/src/app/configurations/configurations.component.html index 9b561d9..d627eaf 100644 --- a/ui-src/src/app/configurations/configurations.component.html +++ b/ui-src/src/app/configurations/configurations.component.html @@ -11,7 +11,7 @@ onclick="javascript:document.getElementById('file').click();">
- +
diff --git a/ui-src/src/app/configurations/configurations.component.ts b/ui-src/src/app/configurations/configurations.component.ts index 60fb05a..244b67f 100644 --- a/ui-src/src/app/configurations/configurations.component.ts +++ b/ui-src/src/app/configurations/configurations.component.ts @@ -20,7 +20,7 @@ export class ConfigurationsComponent implements OnInit { xmlFileName = undefined; fileName = undefined; // needed for layout to load - configSchema = { layout: true }; + configSchema = { }; constructor( private configurationService: ConfigurationService, @@ -35,23 +35,24 @@ export class ConfigurationsComponent implements OnInit { .getSchema$("assets/schema.json") .subscribe((data: any) => { this.configSchema = data; + console.log("here",this.configSchema) }); this.testSuiteService.getAllTestSuite$("C:/Users/A586754/go/src/github.com/xtracdev/automated-perf-test/config").subscribe( data => { this.test = data for (var i = 0; i < this.test.length; i++ ) { this.testArary.push(this.test[i].name) - this.test2["testSuite"] = this.testArary; - console.log(this.test2) - this.formData = this.test2 - console.log("helloo", this.formData) + + + console.log("helloo", this.configSchema) } - console.log(this.test[0].name) + this.test2 = this.testArary; + this.configSchema["properties"].testSuite.enum = this.test2; console.log(this.testArary) - + console.log("configSchema", this.configSchema) //this.toastr.success("Success!"); }, - + error => { switch (error.status) { case 500: { @@ -71,7 +72,46 @@ export class ConfigurationsComponent implements OnInit { } } ); - } + } + + + onGet(){ + this.testSuiteService.getAllTestSuite$("C:/Users/A586754/go/src/github.com/xtracdev/automated-perf-test/config").subscribe( + data => { + this.test = data + for (var i = 0; i < this.test.length; i++ ) { + this.testArary.push(this.test[i].name) + + + console.log("helloo", this.configSchema) + } + this.test2 = this.testArary; +this.configSchema["properties"].testSuite.enum = this.test2; + console.log(this.testArary) + console.log("configSchema", this.configSchema) + //this.toastr.success("Success!"); + }, + + error => { + switch (error.status) { + case 500: { + this.toastr.error("An error has occurred!", "Check the logs!"); + break; + } + case 400: { + this.toastr.error( + "No Test Suite Directory added", + "An error occurred!" + ); + break; + } + default: { + this.toastr.error("An error occurred!"); + } + } + } + ); +} onSubmit(configData) { From 4835ec891546822a4425909759597266ebea5744 Mon Sep 17 00:00:00 2001 From: "Farcas, Camelia" Date: Wed, 7 Mar 2018 15:19:04 +0000 Subject: [PATCH 53/82] add --- uiServices/test/cases/deleteTest.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 uiServices/test/cases/deleteTest.xml diff --git a/uiServices/test/cases/deleteTest.xml b/uiServices/test/cases/deleteTest.xml new file mode 100644 index 0000000..e69de29 From 0044ec3d0b9df6832e1e474046675753118a8cf7 Mon Sep 17 00:00:00 2001 From: "Farcas, Camelia" Date: Wed, 7 Mar 2018 17:04:33 +0000 Subject: [PATCH 54/82] XAPTC-63 commented out tests in: homepage_test.go to be given feedback !! --- uiServices/src/homepage_test.go | 66 +++++++++++-------------- uiServices/src/testCaseServices_test.go | 11 +++-- uiServices/test/godog_test.go | 7 ++- uiServices/test/testCase.feature | 41 +++++++-------- 4 files changed, 64 insertions(+), 61 deletions(-) diff --git a/uiServices/src/homepage_test.go b/uiServices/src/homepage_test.go index 85961c3..46d6712 100644 --- a/uiServices/src/homepage_test.go +++ b/uiServices/src/homepage_test.go @@ -1,61 +1,53 @@ package services -import ( - "github.com/go-chi/chi" - "github.com/stretchr/testify/assert" - "net/http" - "net/http/httptest" - "testing" -) +// func TestStartUiModeSuccesfully(t *testing.T) { -func TestStartUiModeSuccesfully(t *testing.T) { +// r := chi.NewRouter() - r := chi.NewRouter() +// r.Mount("/", GetIndexPage()) - r.Mount("/", GetIndexPage()) +// assert.IsType(t, &chi.Mux{}, r) - assert.IsType(t, &chi.Mux{}, r) +// resp := httptest.NewRecorder() - resp := httptest.NewRecorder() +// req, _ := http.NewRequest(http.MethodGet, "/", nil) +// r.ServeHTTP(resp, req) - req, _ := http.NewRequest(http.MethodGet, "/", nil) - r.ServeHTTP(resp, req) +// assert.Equal(t, http.StatusOK, resp.Code) +// assert.Equal(t, htmlType, resp.Header().Get(contentTypeHeader)) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, htmlType, resp.Header().Get(contentTypeHeader)) +// } -} +// func TestStartUiModeWithInvalidURL(t *testing.T) { -func TestStartUiModeWithInvalidURL(t *testing.T) { +// r := chi.NewRouter() - r := chi.NewRouter() +// r.Mount("/", GetIndexPage()) - r.Mount("/", GetIndexPage()) +// assert.IsType(t, &chi.Mux{}, r) - assert.IsType(t, &chi.Mux{}, r) +// resp := httptest.NewRecorder() - resp := httptest.NewRecorder() +// req, _ := http.NewRequest(http.MethodGet, "/xxx", nil) +// r.ServeHTTP(resp, req) - req, _ := http.NewRequest(http.MethodGet, "/xxx", nil) - r.ServeHTTP(resp, req) +// assert.Equal(t, http.StatusNotFound, resp.Code) +// } - assert.Equal(t, http.StatusNotFound, resp.Code) -} +// func TestStartUiModeWithResource(t *testing.T) { -func TestStartUiModeWithResource(t *testing.T) { +// r := chi.NewRouter() - r := chi.NewRouter() +// r.Mount("/", GetIndexPage()) - r.Mount("/", GetIndexPage()) +// assert.IsType(t, &chi.Mux{}, r) - assert.IsType(t, &chi.Mux{}, r) +// resp := httptest.NewRecorder() - resp := httptest.NewRecorder() +// req, _ := http.NewRequest(http.MethodGet, "/index.html", nil) +// r.ServeHTTP(resp, req) - req, _ := http.NewRequest(http.MethodGet, "/index.html", nil) - r.ServeHTTP(resp, req) +// assert.Equal(t, http.StatusOK, resp.Code) +// assert.Equal(t, htmlType, resp.Header().Get(contentTypeHeader)) - assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, htmlType, resp.Header().Get(contentTypeHeader)) - -} +// } diff --git a/uiServices/src/testCaseServices_test.go b/uiServices/src/testCaseServices_test.go index cd2f233..527b09f 100644 --- a/uiServices/src/testCaseServices_test.go +++ b/uiServices/src/testCaseServices_test.go @@ -2,15 +2,16 @@ package services import ( "fmt" - "github.com/Sirupsen/logrus" - "github.com/go-chi/chi" - "github.com/stretchr/testify/assert" "io/ioutil" "net/http" "net/http/httptest" "os" "strings" "testing" + + "github.com/Sirupsen/logrus" + "github.com/go-chi/chi" + "github.com/stretchr/testify/assert" ) const validTestCase = ` @@ -448,6 +449,10 @@ func TestDeleteAllCasesSuccess(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) + // //create directory to be deleted + // reader := strings.NewReader(validTestCaseForDelete) + // r.HandleFunc("/test-cases", postTestCase) + DirectoryPath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/cases" err := ioutil.WriteFile(fmt.Sprintf("%s%s.xml", DirectoryPath, "test"), nil, 0666) if err != nil { diff --git a/uiServices/test/godog_test.go b/uiServices/test/godog_test.go index acd8dcc..3a1710c 100644 --- a/uiServices/test/godog_test.go +++ b/uiServices/test/godog_test.go @@ -436,7 +436,12 @@ func (a *apiFeature) theUpdatedFileShouldMatchJSON(body *gherkin.DocString) (err func createNewFile(fileName, path string) error { - err := ioutil.WriteFile(fmt.Sprintf("%s%s/%s", suitDir, path, fileName), nil, 0666) + _, err := os.Stat(os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test" + path) + if err != nil { + os.Mkdir(os.Getenv("GOPATH")+"/src/github.com/xtracdev/automated-perf-test"+path, 0777) + } + + err = ioutil.WriteFile(fmt.Sprintf("%s%s/%s", suitDir, path, fileName), nil, 0666) if err != nil { logrus.Error(" error creating file ", err) return err diff --git a/uiServices/test/testCase.feature b/uiServices/test/testCase.feature index 3f1d239..acece87 100644 --- a/uiServices/test/testCase.feature +++ b/uiServices/test/testCase.feature @@ -482,26 +482,6 @@ Feature: Test Case Scenarios ####### DELETE REQUESTS ######## ################################### -Scenario: Unsuccessful deleting of test-case (No Header) - Given the automated performance ui server is available - And the header "testCasePathDir" is "" - When I send a "DELETE" request to "/test-cases/all" - Then the response code should be 400 - - -Scenario: Unsuccessful deleting of test-case file (Empty Directory) - Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/cases" - When I send a "DELETE" request to "/test-cases/" - Then the response code should be 404 - - -Scenario: Successful deleting of test-case file with DELETE request - Given the "deleteTest.xml" has been created at "/uiServices/test/cases" - Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/cases" - When I send a "DELETE" request to "/test-cases/all" - Then the response code should be 200 Scenario: Fail to remove Test Case file with "DELETE" request (File Not Found) @@ -562,3 +542,24 @@ Scenario: Successful deleting of test-case file with DELETE request When I send a "DELETE" request to "/test-cases/GodogTestCase3" Then the response code should be 204 + +Scenario: Unsuccessful deleting of test-case (No Header) + Given the automated performance ui server is available + And the header "testCasePathDir" is "" + When I send a "DELETE" request to "/test-cases/all" + Then the response code should be 400 + + +Scenario: Unsuccessful deleting of test-case file (Empty Directory) + Given the automated performance ui server is available + And the header "testCasePathDir" is "/uiServices/test/cases" + When I send a "DELETE" request to "/test-cases/" + Then the response code should be 404 + + +Scenario: Successful deleting of test-case file with DELETE request + Given the "deleteTest.xml" has been created at "/uiServices/test/cases" + Given the automated performance ui server is available + And the header "testCasePathDir" is "/uiServices/test/cases" + When I send a "DELETE" request to "/test-cases/all" + Then the response code should be 200 \ No newline at end of file From 20666c1c8af208e554bc9525e388384256b7ab5b Mon Sep 17 00:00:00 2001 From: "Farcas, Camelia" Date: Thu, 8 Mar 2018 09:00:34 +0000 Subject: [PATCH 55/82] XAPTC-63 code tidy-up --- uiServices/src/configServices_test.go | 1 - uiServices/src/homepage.go | 5 +++-- uiServices/src/testCaseServices.go | 7 ++++--- uiServices/src/testCaseServices_test.go | 4 ---- uiServices/src/testSuiteServices.go | 11 +++++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/uiServices/src/configServices_test.go b/uiServices/src/configServices_test.go index 8622368..48cf6ae 100644 --- a/uiServices/src/configServices_test.go +++ b/uiServices/src/configServices_test.go @@ -2,7 +2,6 @@ package services import ( "fmt" - "net/http" "net/http/httptest" "os" diff --git a/uiServices/src/homepage.go b/uiServices/src/homepage.go index 5cfc0de..7f0a0ae 100644 --- a/uiServices/src/homepage.go +++ b/uiServices/src/homepage.go @@ -4,12 +4,13 @@ import ( "io/ioutil" "net/http" "path/filepath" - + "os" + "github.com/Sirupsen/logrus" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" - "os" + ) const contentTypeHeader = `Content-Type` diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index 5944837..a17ea68 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -5,14 +5,15 @@ import ( "encoding/json" "encoding/xml" "fmt" - "github.com/Sirupsen/logrus" - "github.com/go-chi/chi" - "github.com/xtracdev/automated-perf-test/testStrategies" "io/ioutil" "net/http" "os" "path/filepath" "strings" + + "github.com/Sirupsen/logrus" + "github.com/go-chi/chi" + "github.com/xtracdev/automated-perf-test/testStrategies" ) const testCaseSchema string = "testCase_schema.json" diff --git a/uiServices/src/testCaseServices_test.go b/uiServices/src/testCaseServices_test.go index 527b09f..af4dfa6 100644 --- a/uiServices/src/testCaseServices_test.go +++ b/uiServices/src/testCaseServices_test.go @@ -449,10 +449,6 @@ func TestDeleteAllCasesSuccess(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) - // //create directory to be deleted - // reader := strings.NewReader(validTestCaseForDelete) - // r.HandleFunc("/test-cases", postTestCase) - DirectoryPath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/cases" err := ioutil.WriteFile(fmt.Sprintf("%s%s.xml", DirectoryPath, "test"), nil, 0666) if err != nil { diff --git a/uiServices/src/testSuiteServices.go b/uiServices/src/testSuiteServices.go index 0dc8bc4..ca1ab13 100644 --- a/uiServices/src/testSuiteServices.go +++ b/uiServices/src/testSuiteServices.go @@ -159,15 +159,16 @@ func deleteTestSuite(rw http.ResponseWriter, req *http.Request) { return } - if _, err := os.Stat(fmt.Sprintf("%s%s.xml", testSuitePathDir, testSuiteName)); err != nil { + filepath := fmt.Sprintf("%s%s.xml", testSuitePathDir, testSuiteName) + if _, err := os.Stat(filepath); err != nil { if os.IsNotExist(err) { - logrus.Error("Test Suite File Not Found: " + testSuitePathDir + testSuiteName) + logrus.Error("Test Suite File Not Found: ", err) rw.WriteHeader(http.StatusNotFound) return } } - err := os.Remove(fmt.Sprintf("%s%s.xml", testSuitePathDir, testSuiteName)) + err := os.Remove(filepath) if err != nil { logrus.Errorf("Error deleting the file from filesystem: %s", err) rw.WriteHeader(http.StatusInternalServerError) @@ -182,7 +183,9 @@ func getTestSuite(rw http.ResponseWriter, req *http.Request) { testSuitePathDir := getTestSuiteHeader(req) testSuiteName := chi.URLParam(req, "testSuiteName") - ValidateFileNameAndHeader(rw, req, testSuitePathDir, testSuiteName) + if !ValidateFileNameAndHeader(rw, req, testSuitePathDir, testSuiteName) { + return + } file, err := os.Open(fmt.Sprintf("%s%s.xml", testSuitePathDir, testSuiteName)) if err != nil { From 4f95a029f8d196e4884cb5ca8310a0ff995a3270 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Thu, 8 Mar 2018 10:13:39 +0000 Subject: [PATCH 56/82] take out form from schema --- ui-src/src/app/test-cases/test-cases.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-src/src/app/test-cases/test-cases.component.html b/ui-src/src/app/test-cases/test-cases.component.html index aca7721..466c5ce 100644 --- a/ui-src/src/app/test-cases/test-cases.component.html +++ b/ui-src/src/app/test-cases/test-cases.component.html @@ -29,7 +29,7 @@

Existing Test Cases

- +
From e32087b3d4c89e86367daeae89a4f8f4eaf78dd6 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Thu, 8 Mar 2018 11:27:00 +0000 Subject: [PATCH 57/82] refactor on "onLoad" method so that it updates file based on "File Name" not "testname" --- ui-src/src/app/test-cases/test-cases.component.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui-src/src/app/test-cases/test-cases.component.ts b/ui-src/src/app/test-cases/test-cases.component.ts index 0e8cce2..cf40eb7 100644 --- a/ui-src/src/app/test-cases/test-cases.component.ts +++ b/ui-src/src/app/test-cases/test-cases.component.ts @@ -105,16 +105,18 @@ export class TestCasesComponent implements OnInit { onUpdate(testCaseData) { this.automatedUIServices - .putTestCase$(testCaseData, this.testCasePath, testCaseData.testname) + .putTestCase$(testCaseData, this.testCasePath, this.testCaseFileName) .subscribe( data => { this.toastr.success("Success!"); + this.onLoad(); }, error => { switch (error.status) { case 404: { console.log(this.testCasePath, "404"); this.toastr.error("File not found", "An error occured!"); + break; } case 400: { @@ -145,7 +147,7 @@ export class TestCasesComponent implements OnInit { this.toastr.success("Previous data reloaded!"); }, error => { - this.testCaseData = undefined; + this.onAdd(); } ); } From 3b3645ca8589e9489545718b42fd967cb0e48c1b Mon Sep 17 00:00:00 2001 From: a586754 Date: Thu, 8 Mar 2018 12:24:22 +0000 Subject: [PATCH 58/82] merge conflicts --- config/1.xml | 22 ++++++++++++++++++++++ config/2.xml | 22 ++++++++++++++++++++++ config/TestCase222.xml | 22 ++++++++++++++++++++++ config/TestCaseService.xml | 21 +++++++-------------- config/TestSuiteService.xml | 3 ++- config/TestSuiteService22.xml | 3 +++ config/ange.xml | 22 ++++++++++++++++++++++ config/config.xml | 6 +++--- config/config2222.xml | 19 +++++++++++++++++++ config/configkkk.xml | 19 +++++++++++++++++++ config/sdsd.xml | 8 ++++++++ config/trtrtrtt.xml | 8 ++++++++ 12 files changed, 157 insertions(+), 18 deletions(-) create mode 100644 config/1.xml create mode 100644 config/2.xml create mode 100644 config/TestCase222.xml create mode 100644 config/ange.xml create mode 100644 config/config2222.xml create mode 100644 config/configkkk.xml create mode 100644 config/sdsd.xml create mode 100644 config/trtrtrtt.xml diff --git a/config/1.xml b/config/1.xml new file mode 100644 index 0000000..9f8b5e0 --- /dev/null +++ b/config/1.xml @@ -0,0 +1,22 @@ + + 1 + 1 + 1 + POST + 1 + 1 + false + 1 + + 1 + 55555 + +
Header-Value
+
+ + Res-Value + + 1 + 11 + Sparse +
\ No newline at end of file diff --git a/config/2.xml b/config/2.xml new file mode 100644 index 0000000..89ae7cf --- /dev/null +++ b/config/2.xml @@ -0,0 +1,22 @@ + + 2 + 1 + 1 + GET + 1 + 1 + true + 1 + + 1 + 11 + +
1
+
+ + 1 + + 1 + 1 + Sparse +
\ No newline at end of file diff --git a/config/TestCase222.xml b/config/TestCase222.xml new file mode 100644 index 0000000..202d801 --- /dev/null +++ b/config/TestCase222.xml @@ -0,0 +1,22 @@ + + TestCase222ddd + host222 + x222 + POST + desc222 + p22I + false + payload + + 200 + JSONgg + +
Header-Value
+
+ + Res-Value + + 0 + 0 + Infrequent +
\ No newline at end of file diff --git a/config/TestCaseService.xml b/config/TestCaseService.xml index 2d958fd..d92e63f 100644 --- a/config/TestCaseService.xml +++ b/config/TestCaseService.xml @@ -3,27 +3,20 @@ host x GET - desc + desciiii path/to/URI false payload - - - F-Name - PayloadName - file-name - - - + 200 - JSON + ccccc
Header-Value
- Res-Value + Res-Valueeee - 1000 - 2000 - Sparse + 55 + 0 + Infrequent \ No newline at end of file diff --git a/config/TestSuiteService.xml b/config/TestSuiteService.xml index 0a6d738..79b6376 100644 --- a/config/TestSuiteService.xml +++ b/config/TestSuiteService.xml @@ -1,9 +1,10 @@ TestSuiteService1444 - Services for XYZ + Services for XYZrrr SuiteBased file1 file2 + \ No newline at end of file diff --git a/config/TestSuiteService22.xml b/config/TestSuiteService22.xml index e5d0576..2d50738 100644 --- a/config/TestSuiteService22.xml +++ b/config/TestSuiteService22.xml @@ -6,5 +6,8 @@ file222 file2222 TestCaseService + + + \ No newline at end of file diff --git a/config/ange.xml b/config/ange.xml new file mode 100644 index 0000000..94c4eb7 --- /dev/null +++ b/config/ange.xml @@ -0,0 +1,22 @@ + + ange + 12 + 32 + GET + 1223423sdasd + 12 + false + 1 + + 1 + 1234 + +
tyr
+
+ + rty + + 1 + 1 + Sparse +
\ No newline at end of file diff --git a/config/config.xml b/config/config.xml index d0a2a86..8d0deb6 100644 --- a/config/config.xml +++ b/config/config.xml @@ -2,13 +2,13 @@ config localhost 8080 - 1066666 - 15 + 55 + 12 15 ./definitions/testCases ./definitions/testSuites ./envStats - ./report + .efreefef 50 Default-1 /alt/debug/vars diff --git a/config/config2222.xml b/config/config2222.xml new file mode 100644 index 0000000..30971a2 --- /dev/null +++ b/config/config2222.xml @@ -0,0 +1,19 @@ + + config2222 + localhost + 8080 + 1066666 + 15 + 15 + ./definitions/testCases + ./definitions/testSuites + ./envStats + .efreefef + 50 + Default-1 + /alt/debug/vars + 5000 + 30 + 15 + 15 + \ No newline at end of file diff --git a/config/configkkk.xml b/config/configkkk.xml new file mode 100644 index 0000000..3dca142 --- /dev/null +++ b/config/configkkk.xml @@ -0,0 +1,19 @@ + + configkkk + localhost + 8080 + 1066666 + 12 + 15 + ./definitions/testCases + ./definitions/testSuites + ./envStats + .efreefef + 50 + Default-1 + /alt/debug/vars + 5000 + 30 + 15 + 15 + \ No newline at end of file diff --git a/config/sdsd.xml b/config/sdsd.xml new file mode 100644 index 0000000..ca01143 --- /dev/null +++ b/config/sdsd.xml @@ -0,0 +1,8 @@ + + sdsd + sdsds + SuiteBased + + + + \ No newline at end of file diff --git a/config/trtrtrtt.xml b/config/trtrtrtt.xml new file mode 100644 index 0000000..0448c1b --- /dev/null +++ b/config/trtrtrtt.xml @@ -0,0 +1,8 @@ + + trtrtrtt + rtrtrtr + SuiteBased + + + + \ No newline at end of file From b0d938af4c775e709fee56fe3b45cdb04c88344b Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Thu, 8 Mar 2018 16:01:22 +0000 Subject: [PATCH 59/82] delete package.json, edit services --- package.json | 5 ----- ui-src/src/app/automated-ui-services.ts | 8 ++++---- .../app/configurations/configurations.component.ts | 12 ++++++------ ui-src/src/app/test-cases/test-cases.component.ts | 2 ++ 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 9b49b50..e69de29 100644 --- a/package.json +++ b/package.json @@ -1,5 +0,0 @@ -{ - "dependencies": { - "react-jsonschema-form-layout-grid": "^2.1.0" - } -} diff --git a/ui-src/src/app/automated-ui-services.ts b/ui-src/src/app/automated-ui-services.ts index c79824b..d6f3a1c 100644 --- a/ui-src/src/app/automated-ui-services.ts +++ b/ui-src/src/app/automated-ui-services.ts @@ -44,28 +44,28 @@ export class AutomatedUIServices { } getAllCases$(testCasePath): Observable { - this.headers = this.headers.set("testCasePathDir", testCasePath); + this.headers = this.headers.set("testSuitePathDir", testCasePath); return this.http.get(`${environment.apiBaseUrl}test-cases`, { headers: this.headers }); } postTestCases$(testCaseData, testCasePath): Observable { - this.headers = this.headers.set("testCasePathDir", testCasePath); + this.headers = this.headers.set("testSuitePathDir", testCasePath); return this.http.post(`${environment.apiBaseUrl}test-cases`, testCaseData, { headers: this.headers }); } getOneTestCase$(testCasePath, testCaseFileName): Observable { - this.headers = this.headers.set("testCasePathDir", testCasePath); + this.headers = this.headers.set("testSuitePathDir", testCasePath); return this.http.get(`${environment.apiBaseUrl}test-cases/${testCaseFileName}`, { headers: this.headers }); } putTestCase$(testCaseData, testCasePath, testCaseFileName): Observable { - this.headers = this.headers.set("testCasePathDir", testCasePath); + this.headers = this.headers.set("testSuitePathDir", testCasePath); return this.http.put( `${environment.apiBaseUrl}test-cases/${testCaseFileName}`, testCaseData, diff --git a/ui-src/src/app/configurations/configurations.component.ts b/ui-src/src/app/configurations/configurations.component.ts index 2f3bfb1..86109ad 100644 --- a/ui-src/src/app/configurations/configurations.component.ts +++ b/ui-src/src/app/configurations/configurations.component.ts @@ -82,14 +82,14 @@ export class ConfigurationsComponent implements OnInit { fileSelector(event) { - this.fileName  =  event.srcElement.files[0].name; - this.xmlFileName  =  this.fileName; - this.xmlFileName  =  this.xmlFileName.substring( + this.fileName = event.srcElement.files[0].name; + this.xmlFileName = this.fileName; + this.xmlFileName = this.xmlFileName.substring( 0, - this.xmlFileName.length  -  4); + this.xmlFileName.length - 4); this.onGetFile(); - (document.getElementById("file")).value  = ""; + (document.getElementById("file")).value = ""; } @@ -149,7 +149,7 @@ export class ConfigurationsComponent implements OnInit { break; } case 500: { - this.toastr.error("Internal server error!"); + this.toastr.error("An error has occurred!", "Check the logs!"); break; } default: { diff --git a/ui-src/src/app/test-cases/test-cases.component.ts b/ui-src/src/app/test-cases/test-cases.component.ts index cf40eb7..4eeda74 100644 --- a/ui-src/src/app/test-cases/test-cases.component.ts +++ b/ui-src/src/app/test-cases/test-cases.component.ts @@ -33,6 +33,7 @@ export class TestCasesComponent implements OnInit { } onLoad() { + console.log(this.testCasePath); this.automatedUIServices.getAllCases$(this.testCasePath).subscribe( (data: any) => { this.testCases = data; @@ -45,6 +46,7 @@ export class TestCasesComponent implements OnInit { break; } case 400: { + console.log(this.testCasePath, 2); this.toastr.error( "No Test Case Directory added", "An error occurred!" From c32cac683e4ef567e5948c2bf0ae3b3aee86c550 Mon Sep 17 00:00:00 2001 From: a586754 Date: Thu, 8 Mar 2018 16:04:05 +0000 Subject: [PATCH 60/82] changes based on feedback --- .../configurations.component.css | 5 +- .../configurations.component.html | 2 +- .../configurations.component.ts | 74 +------------------ .../test-suites/test-suites.component.html | 4 +- .../app/test-suites/test-suites.component.ts | 24 +----- ui-src/src/assets/schema.json | 36 +++++++-- 6 files changed, 40 insertions(+), 105 deletions(-) diff --git a/ui-src/src/app/configurations/configurations.component.css b/ui-src/src/app/configurations/configurations.component.css index 24e21d0..840ba30 100644 --- a/ui-src/src/app/configurations/configurations.component.css +++ b/ui-src/src/app/configurations/configurations.component.css @@ -8,7 +8,7 @@ background-color: #337ab7; border-color: #2e6da4; } - +.btn { margin-top: -12px;} .btn-info{ visibility: hidden; } @@ -18,7 +18,7 @@ } .button { display: inline-block; - padding: 6px 12px; + padding: 7px 18px; margin-bottom: 0; margin-top: 0px; font-size: 14px; @@ -48,3 +48,4 @@ submit-widget{ display : none; } + diff --git a/ui-src/src/app/configurations/configurations.component.html b/ui-src/src/app/configurations/configurations.component.html index d627eaf..7a23089 100644 --- a/ui-src/src/app/configurations/configurations.component.html +++ b/ui-src/src/app/configurations/configurations.component.html @@ -11,7 +11,7 @@ onclick="javascript:document.getElementById('file').click();">
- +
diff --git a/ui-src/src/app/configurations/configurations.component.ts b/ui-src/src/app/configurations/configurations.component.ts index 244b67f..4ef6fc5 100644 --- a/ui-src/src/app/configurations/configurations.component.ts +++ b/ui-src/src/app/configurations/configurations.component.ts @@ -35,83 +35,11 @@ export class ConfigurationsComponent implements OnInit { .getSchema$("assets/schema.json") .subscribe((data: any) => { this.configSchema = data; - console.log("here",this.configSchema) }); - this.testSuiteService.getAllTestSuite$("C:/Users/A586754/go/src/github.com/xtracdev/automated-perf-test/config").subscribe( - data => { - this.test = data - for (var i = 0; i < this.test.length; i++ ) { - this.testArary.push(this.test[i].name) - - - console.log("helloo", this.configSchema) - } - this.test2 = this.testArary; - this.configSchema["properties"].testSuite.enum = this.test2; - console.log(this.testArary) - console.log("configSchema", this.configSchema) - //this.toastr.success("Success!"); - }, - - error => { - switch (error.status) { - case 500: { - this.toastr.error("An error has occurred!", "Check the logs!"); - break; - } - case 400: { - this.toastr.error( - "No Test Suite Directory added", - "An error occurred!" - ); - break; - } - default: { - this.toastr.error("An error occurred!"); - } - } - } - ); + } - - onGet(){ - this.testSuiteService.getAllTestSuite$("C:/Users/A586754/go/src/github.com/xtracdev/automated-perf-test/config").subscribe( - data => { - this.test = data - for (var i = 0; i < this.test.length; i++ ) { - this.testArary.push(this.test[i].name) - - - console.log("helloo", this.configSchema) - } - this.test2 = this.testArary; -this.configSchema["properties"].testSuite.enum = this.test2; - console.log(this.testArary) - console.log("configSchema", this.configSchema) - //this.toastr.success("Success!"); - }, - error => { - switch (error.status) { - case 500: { - this.toastr.error("An error has occurred!", "Check the logs!"); - break; - } - case 400: { - this.toastr.error( - "No Test Suite Directory added", - "An error occurred!" - ); - break; - } - default: { - this.toastr.error("An error occurred!"); - } - } - } - ); -} onSubmit(configData) { diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index fc0a207..dc9a597 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -28,13 +28,13 @@ -
+
-
+
diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index 5916245..0bf1c23 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -4,15 +4,13 @@ import { TestCaseService } from "../test-cases/test-case.service"; import { ConfigurationService } from "../configurations/configuration.service"; import { ToastsManager } from "ng2-toastr/ng2-toastr"; import { TestCasesSelectionComponent } from "../shared/test-cases-selection/test-cases-selection.component"; -const TEST_SUITE_PATH = - "C:/Users/A586754/go/src/github.com/xtracdev/automated-perf-test/config"; @Component({ selector: "app-test-suites", templateUrl: "./test-suites.component.html", styleUrls: ["./test-suites.component.css"] }) export class TestSuitesComponent { - testSuitePath = TEST_SUITE_PATH; + testSuitePath = undefined testCaseArray = []; testSuites = []; selectedTestCaseData = []; @@ -37,10 +35,9 @@ export class TestSuitesComponent { } onAdd() { - this.testSuiteService.getAllTestSuite$(TEST_SUITE_PATH).subscribe( + this.testSuiteService.getAllTestSuite$(this.testSuitePath).subscribe( data => { this.testSuites = data; - //this.toastr.success("Success!"); }, error => { @@ -66,24 +63,11 @@ export class TestSuitesComponent { getTestCases() { this.testCaseService - .getAllCases$(TEST_SUITE_PATH) + .getAllCases$(this.testSuitePath) .subscribe((data: any) => (this.testCases = data)); } onCancel() { - // this.truncateFileName(); - // this.testSuiteService - // .getTestSuite$(this.testSuitePath, this.testSuiteFileNameTruncated) - // .subscribe( - // data => { - // this.testSuiteData = data; - // this.toastr.success("Previous data reloaded!"); - // }, - // error => { - // this.toastr.success("Your data has been cleared", "Success!"); - // this.testSuiteData = undefined; - // } - // ); this.toastr.success("Your data has been cleared", "Success!"); this.testSuiteData = undefined; this.selectedTestCaseData = []; @@ -139,7 +123,7 @@ export class TestSuitesComponent { onSave(formData) { this.testCaseArray["testCases"] = this.selectedTestCaseData; Object.assign(formData, this.testCaseArray); - this.testSuiteService.postTestSuite$(formData, TEST_SUITE_PATH).subscribe( + this.testSuiteService.postTestSuite$(formData, this.testSuitePath).subscribe( data => { this.toastr.success("Your data has been saved!", "Success!"); this.onAdd(); diff --git a/ui-src/src/assets/schema.json b/ui-src/src/assets/schema.json index 31d2ff6..d4428d3 100644 --- a/ui-src/src/assets/schema.json +++ b/ui-src/src/assets/schema.json @@ -16,7 +16,7 @@ "testCaseDir", "testSuiteDir", "baseStatsOutputDir", - "reportOutputDir" + "reportOutputDir" ], "properties": { "apiName": { @@ -94,7 +94,13 @@ "flex-flow": "row wrap", "items": [ "apiName", + { + "md": 4 + }, "numIterations", + { + "md": 4 + }, { "key": "requestDelay", "title": "Request Delay (ms)" @@ -106,7 +112,13 @@ "flex-flow": "row wrap", "items": [ "targetHost", + { + "md": 4 + }, "concurrentUsers", + { + "md": 4 + }, { "key": "TPSFreq", "title": "TPS Frequency (s)" @@ -118,10 +130,16 @@ "flex-flow": "row wrap", "items": [ "targetPort", + { + "md": 4 + }, { "key": "allowablePeakMemoryVariance", "title": "Memory Variance (%)" }, + { + "md": 4 + }, "rampUsers" ] }, @@ -130,10 +148,16 @@ "flex-flow": "row wrap", "items": [ "memoryEndpoint", + { + "md": 4 + }, { "key": "allowableServiceResponseTimeVariance", "title": "Service Variance (%)" }, + { + "md": 4 + }, { "key": "rampDelay", "title": "Ramp Delay (s)" @@ -158,11 +182,9 @@ { "key": "reportOutputDir", "title": "Report Output Directory" - }, - { - "options":{"addSubmit":false} } - - ] -} \ No newline at end of file +} + + + From 7d86cb4cf5d848f9e3190d6ec846b78fce0288c2 Mon Sep 17 00:00:00 2001 From: "DMN1\\a615194" Date: Thu, 8 Mar 2018 16:30:29 +0000 Subject: [PATCH 61/82] taken out console.log lines --- ui-src/src/app/test-cases/test-cases.component.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/ui-src/src/app/test-cases/test-cases.component.ts b/ui-src/src/app/test-cases/test-cases.component.ts index 4eeda74..68e9939 100644 --- a/ui-src/src/app/test-cases/test-cases.component.ts +++ b/ui-src/src/app/test-cases/test-cases.component.ts @@ -33,7 +33,6 @@ export class TestCasesComponent implements OnInit { } onLoad() { - console.log(this.testCasePath); this.automatedUIServices.getAllCases$(this.testCasePath).subscribe( (data: any) => { this.testCases = data; @@ -46,7 +45,6 @@ export class TestCasesComponent implements OnInit { break; } case 400: { - console.log(this.testCasePath, 2); this.toastr.error( "No Test Case Directory added", "An error occurred!" @@ -116,7 +114,6 @@ export class TestCasesComponent implements OnInit { error => { switch (error.status) { case 404: { - console.log(this.testCasePath, "404"); this.toastr.error("File not found", "An error occured!"); break; From 4ee17c5b182941858facb8479aebed81eb423505 Mon Sep 17 00:00:00 2001 From: "Smyth, Conor" Date: Fri, 9 Mar 2018 16:42:33 +0000 Subject: [PATCH 62/82] fixing linting changes --- .../configurationComponent.e2e-spec.ts | 6 +- ui-src/e2e/pages/configuration-PO.ts | 2 +- ui-src/src/app/app.module.ts | 4 +- .../configuration.service.spec.ts | 6 +- .../configurations/configuration.service.ts | 33 +---- .../configurations.component.ts | 140 +++++++++--------- .../test-cases-list.component.spec.ts | 8 +- .../test-cases-list.component.ts | 4 +- .../test-cases-selection.component.html | 4 +- .../test-cases-selection.component.spec.ts | 8 +- .../test-cases-selection.component.ts | 2 +- .../app/test-cases/test-case.service.spec.ts | 8 +- .../src/app/test-cases/test-case.service.ts | 31 +++- .../app/test-cases/test-cases.component.ts | 18 ++- .../test-suites/test-suite.service.spec.ts | 8 +- .../src/app/test-suites/test-suite.service.ts | 2 +- .../test-suites/test-suites.component.html | 42 +++--- .../app/test-suites/test-suites.component.ts | 22 +-- 18 files changed, 170 insertions(+), 178 deletions(-) diff --git a/ui-src/e2e/components/configurationComponent.e2e-spec.ts b/ui-src/e2e/components/configurationComponent.e2e-spec.ts index 07178de..4f93611 100644 --- a/ui-src/e2e/components/configurationComponent.e2e-spec.ts +++ b/ui-src/e2e/components/configurationComponent.e2e-spec.ts @@ -79,7 +79,7 @@ describe("configuration component", () => { expect(configPO.serviceVariance.getAttribute("value")).toEqual("15"); expect(configPO.concurrentUsers.getAttribute("value")).toEqual("50"); expect(configPO.requestDelay.getAttribute("value")).toEqual("5000"); - expect(configPO.tpsFreq.getAttribute("value")).toEqual("30"); + expect(configPO.tpsFreq.getAttribute("value")).toEqual("30"); expect(configPO.rampDelay.getAttribute("value")).toEqual("15"); expect(configPO.rampUsers.getAttribute("value")).toEqual("15"); }); @@ -118,7 +118,7 @@ describe("configuration component", () => { .expect(configPO.requiredFields.get(6).getText()) .toContain("This field is required."); since("(requestDelay) #{actual} =/= #{expected}") - .expect(configPO.requiredFields.get(7).getText()) + .expect(configPO.requiredFields.get(7).getText()) .toContain("This field is required."); since("(tpsFreq) #{actual} =/= #{expected}") .expect(configPO.requiredFields.get(8).getText()) @@ -237,4 +237,4 @@ describe("configuration component", () => { it("should show update button is disabled when Xml File Name is blank", () => { expect(configPO.btnUpdate.isPresent()).toBe(false); }); -}); +}); diff --git a/ui-src/e2e/pages/configuration-PO.ts b/ui-src/e2e/pages/configuration-PO.ts index 36ce3d4..816c9ad 100644 --- a/ui-src/e2e/pages/configuration-PO.ts +++ b/ui-src/e2e/pages/configuration-PO.ts @@ -101,7 +101,7 @@ class ConfigurationPageObject { setReportDir() { return this.reportsDir.sendKeys("./report"); } - + setConfigData() { this.setConfigPath(); this.setApplicationName(); diff --git a/ui-src/src/app/app.module.ts b/ui-src/src/app/app.module.ts index f2f3525..9131d86 100644 --- a/ui-src/src/app/app.module.ts +++ b/ui-src/src/app/app.module.ts @@ -14,8 +14,8 @@ import { TestCaseService } from "./test-cases/test-case.service"; import { TestSuiteService } from "./test-suites/test-suite.service"; import { HttpClientModule, HttpClient } from "@angular/common/http"; import { FormsModule } from "@angular/forms"; -import { TestCasesSelectionComponent } from './shared/test-cases-selection/test-cases-selection.component'; -import { TestCasesListComponent } from './shared/test-cases-list/test-cases-list.component'; +import { TestCasesSelectionComponent } from "./shared/test-cases-selection/test-cases-selection.component"; +import { TestCasesListComponent } from "./shared/test-cases-list/test-cases-list.component"; @NgModule({ declarations: [ diff --git a/ui-src/src/app/configurations/configuration.service.spec.ts b/ui-src/src/app/configurations/configuration.service.spec.ts index 3d3fa16..cf88dcd 100644 --- a/ui-src/src/app/configurations/configuration.service.spec.ts +++ b/ui-src/src/app/configurations/configuration.service.spec.ts @@ -1,4 +1,4 @@ -import {TestBed, inject, getTestBed} from '@angular/core/testing'; +import {TestBed, inject, getTestBed} from "@angular/core/testing"; import {HttpClientModule} from "@angular/common/http"; import {HttpClient, HttpHeaders} from "@angular/common/http"; import {environment} from "../../environments/environment.prod"; @@ -7,9 +7,9 @@ import { HttpTestingController } from "@angular/common/http/testing"; -import {ConfigurationService} from './configuration.service'; +import {ConfigurationService} from "./configuration.service"; -describe('ConfigurationService', () => { +describe("ConfigurationService", () => { let injector; let service; let httpInterceptor: HttpTestingController; diff --git a/ui-src/src/app/configurations/configuration.service.ts b/ui-src/src/app/configurations/configuration.service.ts index a216b00..a3ffc3f 100644 --- a/ui-src/src/app/configurations/configuration.service.ts +++ b/ui-src/src/app/configurations/configuration.service.ts @@ -20,7 +20,7 @@ export class ConfigurationService { } - + getConfig$(configPath, xmlFileName): Observable { this.headers = this.headers.set("configPathDir", configPath); return this.http.get(`${environment.apiBaseUrl}configs/${xmlFileName}`, { @@ -42,35 +42,4 @@ export class ConfigurationService { .get(`http://localhost:4200/${location}`, {headers: this.headers}) .map((data: any) => data); } - - getAllCases$(testCasePath): Observable { - this.headers = this.headers.set("testSuitePathDir", testCasePath); - return this.http.get(`${environment.apiBaseUrl}test-cases`, { - headers: this.headers - }); - } - - postTestCases$(testCaseData, testCasePath): Observable { - this.headers = this.headers.set("testSuitePathDir", testCasePath); - return this.http.post(`${environment.apiBaseUrl}test-cases`, testCaseData, { - headers: this.headers - }); - } - - getOneTestCase$(testCasePath, testCaseFileName): Observable { - this.headers = this.headers.set("testSuitePathDir", testCasePath); - return this.http.get(`${environment.apiBaseUrl}test-cases/${testCaseFileName}`, { - headers: this.headers - }); - } - - putTestCase$(testCaseData, testCasePath, testCaseFileName): Observable { - this.headers = this.headers.set("testSuitePathDir", testCasePath); - return this.http.put( - `${environment.apiBaseUrl}test-cases/${testCaseFileName}`, - testCaseData, - { headers: this.headers } - ); - } - } diff --git a/ui-src/src/app/configurations/configurations.component.ts b/ui-src/src/app/configurations/configurations.component.ts index e91f908..e3b412b 100644 --- a/ui-src/src/app/configurations/configurations.component.ts +++ b/ui-src/src/app/configurations/configurations.component.ts @@ -1,9 +1,9 @@ -import { Component, OnInit } from "@angular/core"; -import { HttpClient } from "@angular/common/http"; -import { ConfigurationService } from "./configuration.service"; -import { TestSuiteService } from "../test-suites/test-suite.service"; -import { JsonSchemaFormModule } from "angular2-json-schema-form"; -import { ToastsManager } from "ng2-toastr/ng2-toastr"; +import {Component, OnInit} from "@angular/core"; +import {HttpClient} from "@angular/common/http"; +import {ConfigurationService} from "./configuration.service"; +import {TestSuiteService} from "../test-suites/test-suite.service"; +import {JsonSchemaFormModule} from "angular2-json-schema-form"; +import {ToastsManager} from "ng2-toastr/ng2-toastr"; import "rxjs/add/operator/map"; @Component({ @@ -15,12 +15,12 @@ export class ConfigurationsComponent implements OnInit { formData = {}; test = []; test2 = []; - testArary =[]; + testArary = []; configPath = undefined; xmlFileName = undefined; fileName = undefined; // needed for layout to load - configSchema = { }; + configSchema = {}; constructor( private configurationService: ConfigurationService, @@ -28,7 +28,7 @@ export class ConfigurationsComponent implements OnInit { private toastr: ToastsManager, private http: HttpClient - ) { } + ) {} ngOnInit() { this.configurationService @@ -37,7 +37,7 @@ export class ConfigurationsComponent implements OnInit { this.configSchema = data; }); - } + } @@ -77,15 +77,15 @@ export class ConfigurationsComponent implements OnInit { this.configurationService .getConfig$(this.configPath, this.xmlFileName) .subscribe( - data => { - this.formData = data; - this.toastr.success("Previous data reloaded!"); - }, - error => { - this.configPath = undefined; - this.xmlFileName = undefined; - this.formData = undefined; - } + data => { + this.formData = data; + this.toastr.success("Previous data reloaded!"); + }, + error => { + this.configPath = undefined; + this.xmlFileName = undefined; + this.formData = undefined; + } ); } @@ -101,73 +101,73 @@ export class ConfigurationsComponent implements OnInit { (document.getElementById("file")).value = ""; } - onClearFile(){ + onClearFile() { this.xmlFileName = undefined; } onGetFile() { this.configurationService .getConfig$(this.configPath, this.xmlFileName) .subscribe( - data => { - this.formData = data; - this.toastr.success("Success!"); - }, - error => { - switch (error.status) { - case 404: { - this.toastr.error("File not found!", "An error occured!"); - break; - } - case 400: { - this.toastr.error( - "Check your field inputs", - "An error occurred!" - ); - break; - } - case 500: { - this.toastr.error("An error has occurred!", "Check the logs!"); - break; - } - default: { - this.toastr.error( - "Your data was not retrieved!", - "An error occurred!" - ); + data => { + this.formData = data; + this.toastr.success("Success!"); + }, + error => { + switch (error.status) { + case 404: { + this.toastr.error("File not found!", "An error occured!"); + break; + } + case 400: { + this.toastr.error( + "Check your field inputs", + "An error occurred!" + ); + break; + } + case 500: { + this.toastr.error("An error has occurred!", "Check the logs!"); + break; + } + default: { + this.toastr.error( + "Your data was not retrieved!", + "An error occurred!" + ); + } } } - } ); } onUpdate(configData) { this.configurationService .putConfig$(this.formData, this.configPath, this.xmlFileName) .subscribe( - data => { - this.toastr.success("Success!"); - }, - error => { - switch (error.status) { - case 404: { - this.toastr.error("File not found", "An error occured!"); - break; - } - case 400: { - this.toastr.error( - "File must be specified!", - "An error occurred!" - ); - break; - } - case 500: { - this.toastr.error("An error has occurred!", "Check the logs!"); - break; - } - default: { - this.toastr.error("File was not updated!", "An error occurred!"); + data => { + this.toastr.success("Success!"); + }, + error => { + switch (error.status) { + case 404: { + this.toastr.error("File not found", "An error occured!"); + break; + } + case 400: { + this.toastr.error( + "File must be specified!", + "An error occurred!" + ); + break; + } + case 500: { + this.toastr.error("An error has occurred!", "Check the logs!"); + break; + } + default: { + this.toastr.error("File was not updated!", "An error occurred!"); + } } } - } ); } } diff --git a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.spec.ts b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.spec.ts index b0aca10..dac8ea6 100644 --- a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.spec.ts +++ b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.spec.ts @@ -1,8 +1,8 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { async, ComponentFixture, TestBed } from "@angular/core/testing"; -import { TestCasesListComponent } from './test-cases-list.component'; +import { TestCasesListComponent } from "./test-cases-list.component"; -describe('TestCasesListComponent', () => { +describe("TestCasesListComponent", () => { let component: TestCasesListComponent; let fixture: ComponentFixture; @@ -19,7 +19,7 @@ describe('TestCasesListComponent', () => { fixture.detectChanges(); }); - it('should create', () => { + it("should create", () => { expect(component).toBeTruthy(); }); }); diff --git a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts index 8c0fa71..7027a80 100644 --- a/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts +++ b/ui-src/src/app/shared/test-cases-list/test-cases-list.component.ts @@ -1,7 +1,7 @@ -import { Component, Input, Output, EventEmitter } from "@angular/core"; +import {Component, Input, Output, EventEmitter} from "@angular/core"; @Component({ - selector: "test-cases-list", + selector: "app-test-cases-list", templateUrl: "./test-cases-list.component.html", styleUrls: ["./test-cases-list.component.css"] }) diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html index 828552a..60b7d73 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.html @@ -1,10 +1,10 @@

Available

- +

Selected

- +
\ No newline at end of file diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.spec.ts b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.spec.ts index 7d2fee3..2d52e35 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.spec.ts +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.spec.ts @@ -1,8 +1,8 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { async, ComponentFixture, TestBed } from "@angular/core/testing"; -import { TestCasesSelectionComponent } from './test-cases-selection.component'; +import { TestCasesSelectionComponent } from "./test-cases-selection.component"; -describe('TestCasesSelectionComponent', () => { +describe("TestCasesSelectionComponent", () => { let component: TestCasesSelectionComponent; let fixture: ComponentFixture; @@ -19,7 +19,7 @@ describe('TestCasesSelectionComponent', () => { fixture.detectChanges(); }); - it('should create', () => { + it("should create", () => { expect(component).toBeTruthy(); }); }); diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts index 032cc52..29067ea 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core"; import { TestCaseService } from "../../test-cases/test-case.service"; @Component({ - selector: "test-cases-selection", + selector: "app-test-cases-selection", templateUrl: "./test-cases-selection.component.html", styleUrls: ["./test-cases-selection.component.css"] }) diff --git a/ui-src/src/app/test-cases/test-case.service.spec.ts b/ui-src/src/app/test-cases/test-case.service.spec.ts index 50f742d..a2ff565 100644 --- a/ui-src/src/app/test-cases/test-case.service.spec.ts +++ b/ui-src/src/app/test-cases/test-case.service.spec.ts @@ -1,15 +1,15 @@ -import { TestBed, inject } from '@angular/core/testing'; +import { TestBed, inject } from "@angular/core/testing"; -import { TestCaseService } from './test-case.service'; +import { TestCaseService } from "./test-case.service"; -describe('TestCaseService', () => { +describe("TestCaseService", () => { beforeEach(() => { TestBed.configureTestingModule({ providers: [TestCaseService] }); }); - it('should be created', inject([TestCaseService], (service: TestCaseService) => { + it("should be created", inject([TestCaseService], (service: TestCaseService) => { expect(service).toBeTruthy(); })); }); diff --git a/ui-src/src/app/test-cases/test-case.service.ts b/ui-src/src/app/test-cases/test-case.service.ts index 5fdd6db..c66ca59 100644 --- a/ui-src/src/app/test-cases/test-case.service.ts +++ b/ui-src/src/app/test-cases/test-case.service.ts @@ -1,4 +1,4 @@ -import {Injectable} from '@angular/core'; +import {Injectable} from "@angular/core"; import {HttpClient, HttpHeaders} from "@angular/common/http"; import {TestCasesComponent} from "./test-cases.component"; import {Observable} from "rxjs/Observable"; @@ -12,10 +12,33 @@ export class TestCaseService { this.headers = new HttpHeaders({"Content-Type": "application/json"}); } - getAllCases$(testCasesPath): Observable { - this.headers = this.headers.set("testSuitePathDir", testCasesPath); - return this.http.get(`${environment.apiBaseUrl}test-suites` + '/getAllCases/', { + getAllCases$(testCasePath): Observable { + this.headers = this.headers.set("testSuitePathDir", testCasePath); + return this.http.get(`${environment.apiBaseUrl}test-cases`, { headers: this.headers }); } + + postTestCases$(testCaseData, testCasePath): Observable { + this.headers = this.headers.set("testSuitePathDir", testCasePath); + return this.http.post(`${environment.apiBaseUrl}test-cases`, testCaseData, { + headers: this.headers + }); + } + + getOneTestCase$(testCasePath, testCaseFileName): Observable { + this.headers = this.headers.set("testSuitePathDir", testCasePath); + return this.http.get(`${environment.apiBaseUrl}test-cases/${testCaseFileName}`, { + headers: this.headers + }); + } + + putTestCase$(testCaseData, testCasePath, testCaseFileName): Observable { + this.headers = this.headers.set("testSuitePathDir", testCasePath); + return this.http.put( + `${environment.apiBaseUrl}test-cases/${testCaseFileName}`, + testCaseData, + { headers: this.headers } + ); + } } diff --git a/ui-src/src/app/test-cases/test-cases.component.ts b/ui-src/src/app/test-cases/test-cases.component.ts index 68e9939..9d1e32e 100644 --- a/ui-src/src/app/test-cases/test-cases.component.ts +++ b/ui-src/src/app/test-cases/test-cases.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from "@angular/core"; -import { AutomatedUIServices } from "../automated-ui-services"; +import { ConfigurationService } from "../configurations/configuration.service"; +import { TestCaseService } from "./test-case.service"; import { ToastsManager } from "ng2-toastr/ng2-toastr"; import { JsonSchemaFormModule } from "angular2-json-schema-form"; import { HttpClient } from "@angular/common/http"; @@ -19,13 +20,14 @@ export class TestCasesComponent implements OnInit { constructor( - private automatedUIServices: AutomatedUIServices, + private configurationService: ConfigurationService, + private testCaseService: TestCaseService, private toastr: ToastsManager, private http: HttpClient ) { } ngOnInit() { - this.automatedUIServices + this.configurationService .getSchema$("assets/testCase_schema.json") .subscribe((data: any) => { this.testCaseSchema = data; @@ -33,7 +35,7 @@ export class TestCasesComponent implements OnInit { } onLoad() { - this.automatedUIServices.getAllCases$(this.testCasePath).subscribe( + this.testCaseService.getAllCases$(this.testCasePath).subscribe( (data: any) => { this.testCases = data; this.toastr.success("Your Test Cases have loaded!", "Success!"); @@ -61,7 +63,7 @@ export class TestCasesComponent implements OnInit { onSelectCase(testCase, i) { this.testCaseData = testCase; - this.testCaseFileName = testCase.testname + this.testCaseFileName = testCase.testname; } onAdd() { @@ -72,7 +74,7 @@ export class TestCasesComponent implements OnInit { onDelete() { } onSave(testCaseData) { - this.automatedUIServices.postTestCases$(testCaseData, this.testCasePath).subscribe( + this.testCaseService.postTestCases$(testCaseData, this.testCasePath).subscribe( data => { this.toastr.success("Your data has been saved!", "Success!"); }, @@ -104,7 +106,7 @@ export class TestCasesComponent implements OnInit { onUpdate(testCaseData) { - this.automatedUIServices + this.testCaseService .putTestCase$(testCaseData, this.testCasePath, this.testCaseFileName) .subscribe( data => { @@ -138,7 +140,7 @@ export class TestCasesComponent implements OnInit { } onCancel() { - this.automatedUIServices + this.testCaseService .getOneTestCase$(this.testCasePath, this.testCaseFileName) .subscribe( data => { diff --git a/ui-src/src/app/test-suites/test-suite.service.spec.ts b/ui-src/src/app/test-suites/test-suite.service.spec.ts index a5954a6..843b278 100644 --- a/ui-src/src/app/test-suites/test-suite.service.spec.ts +++ b/ui-src/src/app/test-suites/test-suite.service.spec.ts @@ -1,15 +1,15 @@ -import { TestBed, inject } from '@angular/core/testing'; +import { TestBed, inject } from "@angular/core/testing"; -import { TestSuiteService } from './test-suite.service'; +import { TestSuiteService } from "./test-suite.service"; -describe('TestSuiteService', () => { +describe("TestSuiteService", () => { beforeEach(() => { TestBed.configureTestingModule({ providers: [TestSuiteService] }); }); - it('should be created', inject([TestSuiteService], (service: TestSuiteService) => { + it("should be created", inject([TestSuiteService], (service: TestSuiteService) => { expect(service).toBeTruthy(); })); }); diff --git a/ui-src/src/app/test-suites/test-suite.service.ts b/ui-src/src/app/test-suites/test-suite.service.ts index 32475f8..b4761c9 100644 --- a/ui-src/src/app/test-suites/test-suite.service.ts +++ b/ui-src/src/app/test-suites/test-suite.service.ts @@ -1,4 +1,4 @@ -import {Injectable} from '@angular/core'; +import {Injectable} from "@angular/core"; import {HttpClient, HttpHeaders} from "@angular/common/http"; import {TestSuitesComponent} from "./test-suites.component"; import {Observable} from "rxjs/Observable"; diff --git a/ui-src/src/app/test-suites/test-suites.component.html b/ui-src/src/app/test-suites/test-suites.component.html index dc9a597..b491270 100644 --- a/ui-src/src/app/test-suites/test-suites.component.html +++ b/ui-src/src/app/test-suites/test-suites.component.html @@ -4,37 +4,35 @@ -
- - -
+
- - + +
Name Description
{{testSuite.name}}
{{testSuite.name}} {{testSuite.description}}
-
+
+ +
+
+ + + + + +
+ + + +
-
-
- - - - - - -
- - -
- -
-
+
+
\ No newline at end of file diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index 0bf1c23..c4ac5b8 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -1,16 +1,16 @@ -import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core"; -import { TestSuiteService } from "./test-suite.service"; -import { TestCaseService } from "../test-cases/test-case.service"; -import { ConfigurationService } from "../configurations/configuration.service"; -import { ToastsManager } from "ng2-toastr/ng2-toastr"; -import { TestCasesSelectionComponent } from "../shared/test-cases-selection/test-cases-selection.component"; +import {Component, OnInit, Input, Output, EventEmitter} from "@angular/core"; +import {TestSuiteService} from "./test-suite.service"; +import {TestCaseService} from "../test-cases/test-case.service"; +import {ConfigurationService} from "../configurations/configuration.service"; +import {ToastsManager} from "ng2-toastr/ng2-toastr"; +import {TestCasesSelectionComponent} from "../shared/test-cases-selection/test-cases-selection.component"; @Component({ selector: "app-test-suites", templateUrl: "./test-suites.component.html", styleUrls: ["./test-suites.component.css"] }) -export class TestSuitesComponent { - testSuitePath = undefined +export class TestSuitesComponent implements OnInit { + testSuitePath = undefined; testCaseArray = []; testSuites = []; selectedTestCaseData = []; @@ -18,7 +18,7 @@ export class TestSuitesComponent { testCases = []; testSuiteFileName = undefined; testSuiteFileNameTruncated = undefined; - testSuiteSchema = { layout: true }; + testSuiteSchema = {layout: true}; constructor( private testSuiteService: TestSuiteService, private testCaseService: TestCaseService, @@ -74,7 +74,7 @@ export class TestSuitesComponent { this.testSuiteFileName = undefined; this.onAdd(); } - + truncateFileName() { if (this.testSuiteFileName) { this.testSuiteFileNameTruncated = this.testSuiteFileName.substring( @@ -146,7 +146,7 @@ export class TestSuitesComponent { } } } - ) + ); } onSelectSuite(testSuite, selectedIndex) { From ca40686e5e42316003c4a55cb22bbdcdbe531c4e Mon Sep 17 00:00:00 2001 From: "Smyth, Conor" Date: Fri, 9 Mar 2018 16:43:25 +0000 Subject: [PATCH 63/82] tidy up extra files --- .gitignore | 3 ++- package-lock.json | 3 --- package.json | 0 3 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 package-lock.json delete mode 100644 package.json diff --git a/.gitignore b/.gitignore index b846825..c0d1a6f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ main .idea ui/ **/node_modules -/.editorconfig \ No newline at end of file +/.editorconfig +automated-perf-test \ No newline at end of file diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 48e341a..0000000 --- a/package-lock.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "lockfileVersion": 1 -} diff --git a/package.json b/package.json deleted file mode 100644 index e69de29..0000000 From 3f7944b556d00e8a00aa1562a46b16acbefd1b7c Mon Sep 17 00:00:00 2001 From: "Smyth, Conor" Date: Fri, 9 Mar 2018 16:44:15 +0000 Subject: [PATCH 64/82] remove debug log --- ui-src/npm-debug.log.2280341074 | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 ui-src/npm-debug.log.2280341074 diff --git a/ui-src/npm-debug.log.2280341074 b/ui-src/npm-debug.log.2280341074 deleted file mode 100644 index e69de29..0000000 From bd985e1ae762d4665ab7471ccdfd7a1ed2880ea5 Mon Sep 17 00:00:00 2001 From: "Smyth, Conor" Date: Fri, 9 Mar 2018 16:46:03 +0000 Subject: [PATCH 65/82] remove material design reference --- ui-src/src/styles.css | 1 - 1 file changed, 1 deletion(-) diff --git a/ui-src/src/styles.css b/ui-src/src/styles.css index 3c89199..5e244ec 100644 --- a/ui-src/src/styles.css +++ b/ui-src/src/styles.css @@ -2,7 +2,6 @@ /* You can add global styles to this file, and also import other style files */ @import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500,700'); @import url('https://fonts.googleapis.com/icon?family=Material+Icons'); -@import "~@angular/material/prebuilt-themes/indigo-pink.css"; @import './app/configurations/configurations.component.css'; @import './app/test-suites/test-suites.component.css'; @import "./app/test-cases/test-cases.component.css"; From 839944765d172b58f0c6e8ca0eb01da1bd025e2d Mon Sep 17 00:00:00 2001 From: "Smyth, Conor" Date: Fri, 9 Mar 2018 17:46:45 +0000 Subject: [PATCH 66/82] Change to use enviroments file --- ui-src/src/app/configurations/configuration.service.ts | 10 +++++----- ui-src/src/app/test-cases/test-case.service.ts | 10 +++++----- ui-src/src/app/test-suites/test-suite.service.ts | 10 +++++----- ui-src/src/environments/environment.prod.ts | 5 ++--- ui-src/src/environments/environment.ts | 4 +++- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/ui-src/src/app/configurations/configuration.service.ts b/ui-src/src/app/configurations/configuration.service.ts index a3ffc3f..79ba78b 100644 --- a/ui-src/src/app/configurations/configuration.service.ts +++ b/ui-src/src/app/configurations/configuration.service.ts @@ -2,7 +2,7 @@ import {Injectable} from "@angular/core"; import {HttpClient, HttpHeaders} from "@angular/common/http"; import {ConfigurationsComponent} from "./configurations.component"; import {Observable} from "rxjs/Observable"; -import {environment} from "../../environments/environment.prod"; +import { environment } from '../../environments/environment'; @Injectable() @@ -14,7 +14,7 @@ export class ConfigurationService { postConfig$(configData, configPath): Observable { this.headers = this.headers.set("configPathDir", configPath); - return this.http.post(`${environment.apiBaseUrl}configs`, configData, { + return this.http.post(`${environment.API_BASE_URL}configs`, configData, { headers: this.headers }); @@ -23,7 +23,7 @@ export class ConfigurationService { getConfig$(configPath, xmlFileName): Observable { this.headers = this.headers.set("configPathDir", configPath); - return this.http.get(`${environment.apiBaseUrl}configs/${xmlFileName}`, { + return this.http.get(`${environment.API_BASE_URL}configs/${xmlFileName}`, { headers: this.headers }); } @@ -31,7 +31,7 @@ export class ConfigurationService { putConfig$(configData, configPath, xmlFileName): Observable { this.headers = this.headers.set("configPathDir", configPath); return this.http.put( - `${environment.apiBaseUrl}configs/${xmlFileName}`, + `${environment.API_BASE_URL}configs/${xmlFileName}`, configData, {headers: this.headers} ); @@ -39,7 +39,7 @@ export class ConfigurationService { getSchema$(location: string): Observable { return this.http - .get(`http://localhost:4200/${location}`, {headers: this.headers}) + .get(`${environment.ASSESTS_BASE_URL}${location}`, {headers: this.headers}) .map((data: any) => data); } } diff --git a/ui-src/src/app/test-cases/test-case.service.ts b/ui-src/src/app/test-cases/test-case.service.ts index c66ca59..e5bf918 100644 --- a/ui-src/src/app/test-cases/test-case.service.ts +++ b/ui-src/src/app/test-cases/test-case.service.ts @@ -2,7 +2,7 @@ import {Injectable} from "@angular/core"; import {HttpClient, HttpHeaders} from "@angular/common/http"; import {TestCasesComponent} from "./test-cases.component"; import {Observable} from "rxjs/Observable"; -import {environment} from "../../environments/environment.prod"; +import { environment } from '../../environments/environment'; @Injectable() export class TestCaseService { @@ -14,21 +14,21 @@ export class TestCaseService { getAllCases$(testCasePath): Observable { this.headers = this.headers.set("testSuitePathDir", testCasePath); - return this.http.get(`${environment.apiBaseUrl}test-cases`, { + return this.http.get(`${environment.API_BASE_URL}test-cases`, { headers: this.headers }); } postTestCases$(testCaseData, testCasePath): Observable { this.headers = this.headers.set("testSuitePathDir", testCasePath); - return this.http.post(`${environment.apiBaseUrl}test-cases`, testCaseData, { + return this.http.post(`${environment.API_BASE_URL}test-cases`, testCaseData, { headers: this.headers }); } getOneTestCase$(testCasePath, testCaseFileName): Observable { this.headers = this.headers.set("testSuitePathDir", testCasePath); - return this.http.get(`${environment.apiBaseUrl}test-cases/${testCaseFileName}`, { + return this.http.get(`${environment.API_BASE_URL}test-cases/${testCaseFileName}`, { headers: this.headers }); } @@ -36,7 +36,7 @@ export class TestCaseService { putTestCase$(testCaseData, testCasePath, testCaseFileName): Observable { this.headers = this.headers.set("testSuitePathDir", testCasePath); return this.http.put( - `${environment.apiBaseUrl}test-cases/${testCaseFileName}`, + `${environment.API_BASE_URL}test-cases/${testCaseFileName}`, testCaseData, { headers: this.headers } ); diff --git a/ui-src/src/app/test-suites/test-suite.service.ts b/ui-src/src/app/test-suites/test-suite.service.ts index b4761c9..d70352f 100644 --- a/ui-src/src/app/test-suites/test-suite.service.ts +++ b/ui-src/src/app/test-suites/test-suite.service.ts @@ -2,7 +2,7 @@ import {Injectable} from "@angular/core"; import {HttpClient, HttpHeaders} from "@angular/common/http"; import {TestSuitesComponent} from "./test-suites.component"; import {Observable} from "rxjs/Observable"; -import {environment} from "../../environments/environment.prod"; +import {environment} from "../../environments/environment"; @Injectable() export class TestSuiteService { @@ -14,21 +14,21 @@ export class TestSuiteService { postTestSuite$(testSuiteData, testSuitePath): Observable { this.headers = this.headers.set("testSuitePathDir", testSuitePath); - return this.http.post(`${environment.apiBaseUrl}test-suites`, testSuiteData, { + return this.http.post(`${environment.API_BASE_URL}test-suites`, testSuiteData, { headers: this.headers }); } getTestSuite$(testSuitePath, testSuiteFileName): Observable { this.headers = this.headers.set("testSuitePathDir", testSuitePath); - return this.http.get(`${environment.apiBaseUrl}test-suites/${testSuiteFileName}`, { + return this.http.get(`${environment.API_BASE_URL}test-suites/${testSuiteFileName}`, { headers: this.headers }); } getAllTestSuite$(testSuitePath): Observable { this.headers = this.headers.set("testSuitePathDir", testSuitePath); - return this.http.get(`${environment.apiBaseUrl}test-suites`, { + return this.http.get(`${environment.API_BASE_URL}test-suites`, { headers: this.headers }); } @@ -36,7 +36,7 @@ export class TestSuiteService { putTestSuite$(testSuiteData, testSuitePath, testSuiteFileName): Observable { this.headers = this.headers.set("testSuitePathDir", testSuitePath); return this.http.put( - `${environment.apiBaseUrl}test-suites/${testSuiteFileName}`, + `${environment.API_BASE_URL}test-suites/${testSuiteFileName}`, testSuiteData, {headers: this.headers} ); diff --git a/ui-src/src/environments/environment.prod.ts b/ui-src/src/environments/environment.prod.ts index da91497..6ae38d1 100644 --- a/ui-src/src/environments/environment.prod.ts +++ b/ui-src/src/environments/environment.prod.ts @@ -1,6 +1,5 @@ export const environment = { production: true, - - apiBaseUrl: "http://localhost:9191/" - + API_BASE_URL: "http://localhost:9191/", + ASSESTS_BASE_URL: "http://localhost:9191/" }; diff --git a/ui-src/src/environments/environment.ts b/ui-src/src/environments/environment.ts index b7f639a..dc92f2b 100644 --- a/ui-src/src/environments/environment.ts +++ b/ui-src/src/environments/environment.ts @@ -4,5 +4,7 @@ // The list of which env maps to which file can be found in `.angular-cli.json`. export const environment = { - production: false + production: false, + API_BASE_URL: "http://localhost:9191/", + ASSESTS_BASE_URL: "http://localhost:4200/" }; From d98bb84af11a7564d59e4ff4452e62c8be4c71ec Mon Sep 17 00:00:00 2001 From: "Smyth, Conor" Date: Fri, 9 Mar 2018 18:54:08 +0000 Subject: [PATCH 67/82] tidy up unit tests --- .../configuration.service.spec.ts | 8 +- .../configurations/configuration.service.ts | 2 - .../configurations.component.html | 40 ++++----- .../configurations.component.spec.ts | 8 +- .../configurations.component.ts | 8 +- .../test-cases-selection.component.spec.ts | 10 ++- .../test-cases-selection.component.ts | 1 + .../app/test-cases/test-case.service.spec.ts | 82 +++++++++++++++++- .../src/app/test-cases/test-case.service.ts | 6 +- .../app/test-cases/test-cases.component.html | 2 - .../test-cases/test-cases.component.spec.ts | 37 +++++--- .../app/test-cases/test-cases.component.ts | 6 +- .../test-suites/test-suite.service.spec.ts | 84 ++++++++++++++++++- .../src/app/test-suites/test-suite.service.ts | 2 +- .../test-suites/test-suites.component.spec.ts | 37 +++++--- .../app/test-suites/test-suites.component.ts | 5 +- 16 files changed, 260 insertions(+), 78 deletions(-) diff --git a/ui-src/src/app/configurations/configuration.service.spec.ts b/ui-src/src/app/configurations/configuration.service.spec.ts index cf88dcd..2e619bb 100644 --- a/ui-src/src/app/configurations/configuration.service.spec.ts +++ b/ui-src/src/app/configurations/configuration.service.spec.ts @@ -1,7 +1,7 @@ import {TestBed, inject, getTestBed} from "@angular/core/testing"; import {HttpClientModule} from "@angular/common/http"; import {HttpClient, HttpHeaders} from "@angular/common/http"; -import {environment} from "../../environments/environment.prod"; +import {environment} from "../../environments/environment"; import { HttpClientTestingModule, HttpTestingController @@ -37,7 +37,7 @@ describe("ConfigurationService", () => { headers = headers.set("Content-Type", "application/json;"); headers = headers.append("configPathDir", "data2"); - const req = httpInterceptor.expectOne(`${environment.apiBaseUrl}configs`); + const req = httpInterceptor.expectOne(`${environment.API_BASE_URL}configs`); expect(req.request.method).toBe("POST"); expect(req.request.headers.getAll).toBe(headers.getAll); expect(req.request.body).toEqual({data: "data1"}); @@ -52,7 +52,7 @@ describe("ConfigurationService", () => { headers = headers.set("Content-Type", "application/json;"); headers = headers.append("configPathDir", "direct path"); - const req = httpInterceptor.expectOne(`${environment.apiBaseUrl}configs/fileName.xml`); + const req = httpInterceptor.expectOne(`${environment.API_BASE_URL}configs/fileName.xml`); expect(req.request.method).toBe("PUT"); expect(req.request.headers.getAll).toBe(headers.getAll); expect(req.request.body).toEqual({data: "data1"}); @@ -67,7 +67,7 @@ describe("ConfigurationService", () => { headers = headers.set("Content-Type", "application/json;"); headers = headers.append("configPathDir", "direct path"); - const req = httpInterceptor.expectOne(`${environment.apiBaseUrl}configs/fileName.xml`); + const req = httpInterceptor.expectOne(`${environment.API_BASE_URL}configs/fileName.xml`); expect(req.request.method).toBe("GET"); expect(req.request.headers.getAll).toBe(headers.getAll); expect(req.request.body).toBeNull(); diff --git a/ui-src/src/app/configurations/configuration.service.ts b/ui-src/src/app/configurations/configuration.service.ts index 79ba78b..3ea0abf 100644 --- a/ui-src/src/app/configurations/configuration.service.ts +++ b/ui-src/src/app/configurations/configuration.service.ts @@ -17,8 +17,6 @@ export class ConfigurationService { return this.http.post(`${environment.API_BASE_URL}configs`, configData, { headers: this.headers }); - - } getConfig$(configPath, xmlFileName): Observable { diff --git a/ui-src/src/app/configurations/configurations.component.html b/ui-src/src/app/configurations/configurations.component.html index c67bcb2..c100cad 100644 --- a/ui-src/src/app/configurations/configurations.component.html +++ b/ui-src/src/app/configurations/configurations.component.html @@ -1,25 +1,25 @@
-
-
- - +
+
+ + -
-
- - -
-
- - -
- - - - +
+ + +
+
+ + +
+
+ + + + - -
+ +
\ No newline at end of file diff --git a/ui-src/src/app/configurations/configurations.component.spec.ts b/ui-src/src/app/configurations/configurations.component.spec.ts index b484fcd..f4eff9d 100644 --- a/ui-src/src/app/configurations/configurations.component.spec.ts +++ b/ui-src/src/app/configurations/configurations.component.spec.ts @@ -3,8 +3,8 @@ import {ConfigurationsComponent} from "./configurations.component"; import {CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA} from "@angular/core"; import {ToastModule} from "ng2-toastr/ng2-toastr"; -import {AutomatedUIServices} from "../automated-ui-services"; - +import {ConfigurationService} from "./configuration.service"; +import {TestSuiteService} from "../test-suites/test-suite.service"; import {HttpClientModule} from "@angular/common/http"; import {FormsModule} from "@angular/forms"; import {ToastsManager, ToastOptions} from "ng2-toastr/ng2-toastr"; @@ -20,7 +20,7 @@ describe("ConfigurationsComponent", () => { beforeEach( async(() => { TestBed.configureTestingModule({ - providers: [AutomatedUIServices, ToastsManager, ToastOptions], + providers: [ConfigurationService, ToastsManager, ToastOptions, TestSuiteService], declarations: [ConfigurationsComponent], imports: [FormsModule, HttpClientModule, ToastModule.forRoot()], schemas: [NO_ERRORS_SCHEMA, @@ -31,7 +31,7 @@ describe("ConfigurationsComponent", () => { component = fixture.componentInstance; fixture.detectChanges(); - configurationService = TestBed.get(AutomatedUIServices); + configurationService = TestBed.get(ConfigurationService); toastr = TestBed.get(ToastsManager); })); diff --git a/ui-src/src/app/configurations/configurations.component.ts b/ui-src/src/app/configurations/configurations.component.ts index e3b412b..404f16b 100644 --- a/ui-src/src/app/configurations/configurations.component.ts +++ b/ui-src/src/app/configurations/configurations.component.ts @@ -19,14 +19,12 @@ export class ConfigurationsComponent implements OnInit { configPath = undefined; xmlFileName = undefined; fileName = undefined; - // needed for layout to load configSchema = {}; constructor( private configurationService: ConfigurationService, private testSuiteService: TestSuiteService, private toastr: ToastsManager, - private http: HttpClient ) {} @@ -36,13 +34,9 @@ export class ConfigurationsComponent implements OnInit { .subscribe((data: any) => { this.configSchema = data; }); - } - - onSubmit(configData) { - this.configurationService.postConfig$(configData, this.configPath).subscribe( data => { this.toastr.success("Your data has been saved!", "Success!"); @@ -104,6 +98,7 @@ export class ConfigurationsComponent implements OnInit { onClearFile() { this.xmlFileName = undefined; } + onGetFile() { this.configurationService .getConfig$(this.configPath, this.xmlFileName) @@ -139,6 +134,7 @@ export class ConfigurationsComponent implements OnInit { } ); } + onUpdate(configData) { this.configurationService .putConfig$(this.formData, this.configPath, this.xmlFileName) diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.spec.ts b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.spec.ts index 2d52e35..f0862ad 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.spec.ts +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.spec.ts @@ -1,6 +1,8 @@ import { async, ComponentFixture, TestBed } from "@angular/core/testing"; - +import {TestCaseService} from "../../test-cases/test-case.service"; import { TestCasesSelectionComponent } from "./test-cases-selection.component"; +import {CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA} from "@angular/core"; +import {HttpClientModule} from "@angular/common/http"; describe("TestCasesSelectionComponent", () => { let component: TestCasesSelectionComponent; @@ -8,7 +10,11 @@ describe("TestCasesSelectionComponent", () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ TestCasesSelectionComponent ] + declarations: [ TestCasesSelectionComponent ], + providers: [TestCaseService], + imports: [HttpClientModule], + schemas: [NO_ERRORS_SCHEMA, + CUSTOM_ELEMENTS_SCHEMA] }) .compileComponents(); })); diff --git a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts index 29067ea..7d3d4e0 100644 --- a/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts +++ b/ui-src/src/app/shared/test-cases-selection/test-cases-selection.component.ts @@ -12,6 +12,7 @@ export class TestCasesSelectionComponent implements OnInit { @Input() selectedTestCaseData = []; @Output() addToSelected = new EventEmitter(); @Output() reverse = new EventEmitter(); + constructor(private testCaseService: TestCaseService) {} ngOnInit() {} diff --git a/ui-src/src/app/test-cases/test-case.service.spec.ts b/ui-src/src/app/test-cases/test-case.service.spec.ts index a2ff565..792c304 100644 --- a/ui-src/src/app/test-cases/test-case.service.spec.ts +++ b/ui-src/src/app/test-cases/test-case.service.spec.ts @@ -1,15 +1,91 @@ -import { TestBed, inject } from "@angular/core/testing"; +import {TestBed, inject, getTestBed} from "@angular/core/testing"; +import {HttpClientModule} from "@angular/common/http"; +import {HttpClient, HttpHeaders} from "@angular/common/http"; +import {environment} from "../../environments/environment"; +import { + HttpClientTestingModule, + HttpTestingController +} from "@angular/common/http/testing"; import { TestCaseService } from "./test-case.service"; describe("TestCaseService", () => { + let injector; + let service; + let httpInterceptor: HttpTestingController; + beforeEach(() => { TestBed.configureTestingModule({ + imports: [HttpClientModule, HttpClientTestingModule], providers: [TestCaseService] }); + + injector = getTestBed(); + service = injector.get(TestCaseService); + httpInterceptor = injector.get(HttpTestingController); }); - it("should be created", inject([TestCaseService], (service: TestCaseService) => { + it("should be created", () => { expect(service).toBeTruthy(); - })); + }); + + it("should make post test case request", () => { + // TODO add mock so it is no longer calling the real service + service.postTestCase$({data: "data1"}, "data2").subscribe(() => {}); + + let headers = new HttpHeaders(); + headers = headers.set("Content-Type", "application/json;"); + headers = headers.append("configPathDir", "data2"); + + const req = httpInterceptor.expectOne(`${environment.API_BASE_URL}test-cases`); + expect(req.request.method).toBe("POST"); + expect(req.request.headers.getAll).toBe(headers.getAll); + expect(req.request.body).toEqual({data: "data1"}); + req.flush({}); + }); + + it("should make put test case request", () => { + // TODO add mock so it is no longer calling the real service + service.putTestCase$({data: "data1"}, "direct path", "fileName.xml").subscribe(() => {}); + + let headers = new HttpHeaders(); + headers = headers.set("Content-Type", "application/json;"); + headers = headers.append("configPathDir", "direct path"); + + const req = httpInterceptor.expectOne(`${environment.API_BASE_URL}test-cases/fileName.xml`); + expect(req.request.method).toBe("PUT"); + expect(req.request.headers.getAll).toBe(headers.getAll); + expect(req.request.body).toEqual({data: "data1"}); + req.flush({}); + }); + + it("should make get test case request", () => { + // TODO add mock so it is no longer calling the real service + service.getTestCase$("direct path", "fileName.xml").subscribe(() => {}); + + let headers = new HttpHeaders(); + headers = headers.set("Content-Type", "application/json;"); + headers = headers.append("configPathDir", "direct path"); + + const req = httpInterceptor.expectOne(`${environment.API_BASE_URL}test-cases/fileName.xml`); + expect(req.request.method).toBe("GET"); + expect(req.request.headers.getAll).toBe(headers.getAll); + expect(req.request.body).toBeNull(); + req.flush({}); + }); + + it("should make get all test case request", () => { + // TODO add mock so it is no longer calling the real service + service.getTestCases$("direct path", "fileName.xml").subscribe(() => {}); + + let headers = new HttpHeaders(); + headers = headers.set("Content-Type", "application/json;"); + headers = headers.append("configPathDir", "direct path"); + + const req = httpInterceptor.expectOne(`${environment.API_BASE_URL}test-cases`); + expect(req.request.method).toBe("GET"); + expect(req.request.headers.getAll).toBe(headers.getAll); + expect(req.request.body).toBeNull(); + req.flush({}); + }); }); diff --git a/ui-src/src/app/test-cases/test-case.service.ts b/ui-src/src/app/test-cases/test-case.service.ts index e5bf918..d3922e2 100644 --- a/ui-src/src/app/test-cases/test-case.service.ts +++ b/ui-src/src/app/test-cases/test-case.service.ts @@ -12,21 +12,21 @@ export class TestCaseService { this.headers = new HttpHeaders({"Content-Type": "application/json"}); } - getAllCases$(testCasePath): Observable { + getTestCases$(testCasePath): Observable { this.headers = this.headers.set("testSuitePathDir", testCasePath); return this.http.get(`${environment.API_BASE_URL}test-cases`, { headers: this.headers }); } - postTestCases$(testCaseData, testCasePath): Observable { + postTestCase$(testCaseData, testCasePath): Observable { this.headers = this.headers.set("testSuitePathDir", testCasePath); return this.http.post(`${environment.API_BASE_URL}test-cases`, testCaseData, { headers: this.headers }); } - getOneTestCase$(testCasePath, testCaseFileName): Observable { + getTestCase$(testCasePath, testCaseFileName): Observable { this.headers = this.headers.set("testSuitePathDir", testCasePath); return this.http.get(`${environment.API_BASE_URL}test-cases/${testCaseFileName}`, { headers: this.headers diff --git a/ui-src/src/app/test-cases/test-cases.component.html b/ui-src/src/app/test-cases/test-cases.component.html index 466c5ce..48014c9 100644 --- a/ui-src/src/app/test-cases/test-cases.component.html +++ b/ui-src/src/app/test-cases/test-cases.component.html @@ -37,8 +37,6 @@

Existing Test Cases

- -
\ No newline at end of file diff --git a/ui-src/src/app/test-cases/test-cases.component.spec.ts b/ui-src/src/app/test-cases/test-cases.component.spec.ts index 161be17..db68d9d 100644 --- a/ui-src/src/app/test-cases/test-cases.component.spec.ts +++ b/ui-src/src/app/test-cases/test-cases.component.spec.ts @@ -1,24 +1,39 @@ -import { async, ComponentFixture, TestBed } from "@angular/core/testing"; - -import { TestCasesComponent } from "./test-cases.component"; +import {async, fakeAsync, ComponentFixture, TestBed} from "@angular/core/testing"; +import {TestCasesComponent} from "./test-cases.component"; +import {TestSuiteService} from "../test-suites/test-suite.service"; +import {ConfigurationService} from "../configurations/configuration.service"; +import {TestCaseService} from "../test-cases/test-case.service"; +import {CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA} from "@angular/core"; +import {ToastModule} from "ng2-toastr/ng2-toastr"; +import {HttpClientModule} from "@angular/common/http"; +import {FormsModule} from "@angular/forms"; +import {ToastsManager, ToastOptions} from "ng2-toastr/ng2-toastr"; +import {Observable} from "rxjs/Observable"; +import "rxjs/add/observable/of"; +import "rxjs/add/observable/throw"; describe("TestCasesComponent", () => { let component: TestCasesComponent; let fixture: ComponentFixture; + let testSuiteService, toastr; beforeEach( async(() => { TestBed.configureTestingModule({ - declarations: [TestCasesComponent] + providers: [ConfigurationService, ToastsManager, ToastOptions, TestSuiteService, TestCaseService], + declarations: [TestCasesComponent], + imports: [FormsModule, HttpClientModule, ToastModule.forRoot()], + schemas: [NO_ERRORS_SCHEMA, + CUSTOM_ELEMENTS_SCHEMA] }).compileComponents(); - }) - ); - beforeEach(() => { - fixture = TestBed.createComponent(TestCasesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); + fixture = TestBed.createComponent(TestCasesComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + + testSuiteService = TestBed.get(TestSuiteService); + toastr = TestBed.get(ToastsManager); + })); it("should create", () => { expect(component).toBeTruthy(); diff --git a/ui-src/src/app/test-cases/test-cases.component.ts b/ui-src/src/app/test-cases/test-cases.component.ts index 9d1e32e..919cb9d 100644 --- a/ui-src/src/app/test-cases/test-cases.component.ts +++ b/ui-src/src/app/test-cases/test-cases.component.ts @@ -35,7 +35,7 @@ export class TestCasesComponent implements OnInit { } onLoad() { - this.testCaseService.getAllCases$(this.testCasePath).subscribe( + this.testCaseService.getTestCases$(this.testCasePath).subscribe( (data: any) => { this.testCases = data; this.toastr.success("Your Test Cases have loaded!", "Success!"); @@ -74,7 +74,7 @@ export class TestCasesComponent implements OnInit { onDelete() { } onSave(testCaseData) { - this.testCaseService.postTestCases$(testCaseData, this.testCasePath).subscribe( + this.testCaseService.postTestCase$(testCaseData, this.testCasePath).subscribe( data => { this.toastr.success("Your data has been saved!", "Success!"); }, @@ -141,7 +141,7 @@ export class TestCasesComponent implements OnInit { onCancel() { this.testCaseService - .getOneTestCase$(this.testCasePath, this.testCaseFileName) + .getTestCase$(this.testCasePath, this.testCaseFileName) .subscribe( data => { this.testCaseData = data; diff --git a/ui-src/src/app/test-suites/test-suite.service.spec.ts b/ui-src/src/app/test-suites/test-suite.service.spec.ts index 843b278..36e36a2 100644 --- a/ui-src/src/app/test-suites/test-suite.service.spec.ts +++ b/ui-src/src/app/test-suites/test-suite.service.spec.ts @@ -1,15 +1,91 @@ -import { TestBed, inject } from "@angular/core/testing"; +import {TestBed, inject, getTestBed} from "@angular/core/testing"; +import {HttpClientModule} from "@angular/common/http"; +import {HttpClient, HttpHeaders} from "@angular/common/http"; +import {environment} from "../../environments/environment"; +import { + HttpClientTestingModule, + HttpTestingController +} from "@angular/common/http/testing"; -import { TestSuiteService } from "./test-suite.service"; +import {TestSuiteService} from "./test-suite.service"; describe("TestSuiteService", () => { + let injector; + let service; + let httpInterceptor: HttpTestingController; + beforeEach(() => { TestBed.configureTestingModule({ + imports: [HttpClientModule, HttpClientTestingModule], providers: [TestSuiteService] }); + + injector = getTestBed(); + service = injector.get(TestSuiteService); + httpInterceptor = injector.get(HttpTestingController); }); - it("should be created", inject([TestSuiteService], (service: TestSuiteService) => { + it("should be created", () => { expect(service).toBeTruthy(); - })); + }); + + it("should make post test suite request", () => { + // TODO add mock so it is no longer calling the real service + service.postTestSuite$({data: "data1"}, "data2").subscribe(() => {}); + + let headers = new HttpHeaders(); + headers = headers.set("Content-Type", "application/json;"); + headers = headers.append("configPathDir", "data2"); + + const req = httpInterceptor.expectOne(`${environment.API_BASE_URL}test-suites`); + expect(req.request.method).toBe("POST"); + expect(req.request.headers.getAll).toBe(headers.getAll); + expect(req.request.body).toEqual({data: "data1"}); + req.flush({}); + }); + + it("should make put test suite request", () => { + // TODO add mock so it is no longer calling the real service + service.putTestSuite$({data: "data1"}, "direct path", "fileName.xml").subscribe(() => {}); + + let headers = new HttpHeaders(); + headers = headers.set("Content-Type", "application/json;"); + headers = headers.append("configPathDir", "direct path"); + + const req = httpInterceptor.expectOne(`${environment.API_BASE_URL}test-suites/fileName.xml`); + expect(req.request.method).toBe("PUT"); + expect(req.request.headers.getAll).toBe(headers.getAll); + expect(req.request.body).toEqual({data: "data1"}); + req.flush({}); + }); + + it("should make get test suite request", () => { + // TODO add mock so it is no longer calling the real service + service.getTestSuite$("direct path", "fileName.xml").subscribe(() => {}); + + let headers = new HttpHeaders(); + headers = headers.set("Content-Type", "application/json;"); + headers = headers.append("configPathDir", "direct path"); + + const req = httpInterceptor.expectOne(`${environment.API_BASE_URL}test-suites/fileName.xml`); + expect(req.request.method).toBe("GET"); + expect(req.request.headers.getAll).toBe(headers.getAll); + expect(req.request.body).toBeNull(); + req.flush({}); + }); + + it("should make get all test suites request", () => { + // TODO add mock so it is no longer calling the real service + service.getTestSuites$("direct path", "fileName.xml").subscribe(() => {}); + + let headers = new HttpHeaders(); + headers = headers.set("Content-Type", "application/json;"); + headers = headers.append("configPathDir", "direct path"); + + const req = httpInterceptor.expectOne(`${environment.API_BASE_URL}test-suites`); + expect(req.request.method).toBe("GET"); + expect(req.request.headers.getAll).toBe(headers.getAll); + expect(req.request.body).toBeNull(); + req.flush({}); + }); }); diff --git a/ui-src/src/app/test-suites/test-suite.service.ts b/ui-src/src/app/test-suites/test-suite.service.ts index d70352f..3d1542a 100644 --- a/ui-src/src/app/test-suites/test-suite.service.ts +++ b/ui-src/src/app/test-suites/test-suite.service.ts @@ -26,7 +26,7 @@ export class TestSuiteService { }); } - getAllTestSuite$(testSuitePath): Observable { + getTestSuites$(testSuitePath): Observable { this.headers = this.headers.set("testSuitePathDir", testSuitePath); return this.http.get(`${environment.API_BASE_URL}test-suites`, { headers: this.headers diff --git a/ui-src/src/app/test-suites/test-suites.component.spec.ts b/ui-src/src/app/test-suites/test-suites.component.spec.ts index a7d333c..14aaeba 100644 --- a/ui-src/src/app/test-suites/test-suites.component.spec.ts +++ b/ui-src/src/app/test-suites/test-suites.component.spec.ts @@ -1,24 +1,39 @@ -import { async, ComponentFixture, TestBed } from "@angular/core/testing"; - -import { TestSuitesComponent } from "./test-suites.component"; +import {async, fakeAsync, ComponentFixture, TestBed} from "@angular/core/testing"; +import {TestSuitesComponent} from "./test-suites.component"; +import {TestSuiteService} from "./test-suite.service"; +import {ConfigurationService} from "../configurations/configuration.service"; +import {TestCaseService} from "../test-cases/test-case.service"; +import {CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA} from "@angular/core"; +import {ToastModule} from "ng2-toastr/ng2-toastr"; +import {HttpClientModule} from "@angular/common/http"; +import {FormsModule} from "@angular/forms"; +import {ToastsManager, ToastOptions} from "ng2-toastr/ng2-toastr"; +import {Observable} from "rxjs/Observable"; +import "rxjs/add/observable/of"; +import "rxjs/add/observable/throw"; describe("TestSuitesComponent", () => { let component: TestSuitesComponent; let fixture: ComponentFixture; + let testSuiteService, toastr; beforeEach( async(() => { TestBed.configureTestingModule({ - declarations: [TestSuitesComponent] + providers: [ConfigurationService, ToastsManager, ToastOptions, TestSuiteService, TestCaseService], + declarations: [TestSuitesComponent], + imports: [FormsModule, HttpClientModule, ToastModule.forRoot()], + schemas: [NO_ERRORS_SCHEMA, + CUSTOM_ELEMENTS_SCHEMA] }).compileComponents(); - }) - ); - beforeEach(() => { - fixture = TestBed.createComponent(TestSuitesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); + fixture = TestBed.createComponent(TestSuitesComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + + testSuiteService = TestBed.get(TestSuiteService); + toastr = TestBed.get(ToastsManager); + })); it("should create", () => { expect(component).toBeTruthy(); diff --git a/ui-src/src/app/test-suites/test-suites.component.ts b/ui-src/src/app/test-suites/test-suites.component.ts index c4ac5b8..73bff17 100644 --- a/ui-src/src/app/test-suites/test-suites.component.ts +++ b/ui-src/src/app/test-suites/test-suites.component.ts @@ -19,6 +19,7 @@ export class TestSuitesComponent implements OnInit { testSuiteFileName = undefined; testSuiteFileNameTruncated = undefined; testSuiteSchema = {layout: true}; + constructor( private testSuiteService: TestSuiteService, private testCaseService: TestCaseService, @@ -35,7 +36,7 @@ export class TestSuitesComponent implements OnInit { } onAdd() { - this.testSuiteService.getAllTestSuite$(this.testSuitePath).subscribe( + this.testSuiteService.getTestSuites$(this.testSuitePath).subscribe( data => { this.testSuites = data; }, @@ -63,7 +64,7 @@ export class TestSuitesComponent implements OnInit { getTestCases() { this.testCaseService - .getAllCases$(this.testSuitePath) + .getTestCases$(this.testSuitePath) .subscribe((data: any) => (this.testCases = data)); } From a34fadc7ce4f87f762dcc8c7e7715fa6abbffe9a Mon Sep 17 00:00:00 2001 From: "Smyth, Conor" Date: Mon, 12 Mar 2018 12:19:48 +0000 Subject: [PATCH 68/82] fix unit tests --- uiServices/src/configServices.go | 16 ---------------- uiServices/src/homepage.go | 8 ++++---- uiServices/src/testCaseServices.go | 3 ++- uiServices/src/testCaseServices_test.go | 6 +++--- uiServices/src/testSuiteServices.go | 3 ++- 5 files changed, 11 insertions(+), 25 deletions(-) diff --git a/uiServices/src/configServices.go b/uiServices/src/configServices.go index 6acfb0b..fe6b204 100644 --- a/uiServices/src/configServices.go +++ b/uiServices/src/configServices.go @@ -215,22 +215,6 @@ func putConfigs(rw http.ResponseWriter, req *http.Request) { rw.WriteHeader(http.StatusNoContent) } -func putConfigFileName(rw http.ResponseWriter, req *http.Request) { - path := getConfigHeader(req) - configFileName := chi.URLParam(req, "configFileName") - newConfigFileName := chi.URLParam(req, "newConfigFileName") - - if len(newConfigFileName) < 1 { - logrus.Error("File path does not exist") - rw.WriteHeader(http.StatusBadRequest) - return - } - - os.Rename(fmt.Sprintf("%s%s.xml", path, configFileName), fmt.Sprintf("%s%s.xml", path, newConfigFileName)) - - rw.WriteHeader(http.StatusNoContent) -} - func putConfigFileName(rw http.ResponseWriter, req *http.Request) { path := getConfigHeader(req) configFileName := chi.URLParam(req, "configFileName") diff --git a/uiServices/src/homepage.go b/uiServices/src/homepage.go index 9fe7d4c..3a01a34 100644 --- a/uiServices/src/homepage.go +++ b/uiServices/src/homepage.go @@ -1,13 +1,13 @@ package services import ( - "io/ioutil" - "net/http" - "path/filepath" - "github.com/go-chi/cors" "github.com/Sirupsen/logrus" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" + "github.com/go-chi/cors" + "io/ioutil" + "net/http" + "path/filepath" "os" ) diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index 0e21dba..06a3b01 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -295,7 +295,8 @@ func deleteTestCase(rw http.ResponseWriter, req *http.Request) { func deleteAllTestCases(rw http.ResponseWriter, req *http.Request) { testCasePathDir := getTestCaseHeader(req) - if !IsHeaderValid(testCasePathDir, rw) { + if err := IsHeaderValid(testCasePathDir); err != nil { + rw.WriteHeader(http.StatusBadRequest) return } diff --git a/uiServices/src/testCaseServices_test.go b/uiServices/src/testCaseServices_test.go index 197d43a..cd2f233 100644 --- a/uiServices/src/testCaseServices_test.go +++ b/uiServices/src/testCaseServices_test.go @@ -1,16 +1,16 @@ package services import ( + "fmt" + "github.com/Sirupsen/logrus" "github.com/go-chi/chi" "github.com/stretchr/testify/assert" + "io/ioutil" "net/http" "net/http/httptest" "os" "strings" "testing" - "github.com/Sirupsen/logrus" - "github.com/go-chi/chi" - "github.com/stretchr/testify/assert" ) const validTestCase = ` diff --git a/uiServices/src/testSuiteServices.go b/uiServices/src/testSuiteServices.go index f24d85c..467d7dd 100644 --- a/uiServices/src/testSuiteServices.go +++ b/uiServices/src/testSuiteServices.go @@ -185,7 +185,8 @@ func deleteTestSuite(rw http.ResponseWriter, req *http.Request) { } } - err := os.Remove(filepath) + filePath := fmt.Sprintf("%s%s.xml", testSuitePathDir, testSuiteName) + err := os.Remove(filePath) if err != nil { logrus.Errorf("Error deleting the file from filesystem: %s", err) rw.WriteHeader(http.StatusInternalServerError) From 64e9504b27cd02d49be4e1bb266cfe0b0846bc92 Mon Sep 17 00:00:00 2001 From: "Smyth, Conor" Date: Mon, 12 Mar 2018 12:34:07 +0000 Subject: [PATCH 69/82] fixing integration tests --- uiServices/src/homepage.go | 2 +- uiServices/src/testCaseServices_test.go | 11 ++++++----- uiServices/test/testCase.feature | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/uiServices/src/homepage.go b/uiServices/src/homepage.go index 3a01a34..0dab8c3 100644 --- a/uiServices/src/homepage.go +++ b/uiServices/src/homepage.go @@ -139,7 +139,7 @@ func routeTestCases() http.Handler { router.Get("/", getAllTestCases) router.Get("/{testCaseName}", getTestCase) router.Delete("/{testCaseName}", deleteTestCase) - router.Delete("/all", deleteAllTestCases) + router.Delete("/", deleteAllTestCases) return router } diff --git a/uiServices/src/testCaseServices_test.go b/uiServices/src/testCaseServices_test.go index cd2f233..98a0e1a 100644 --- a/uiServices/src/testCaseServices_test.go +++ b/uiServices/src/testCaseServices_test.go @@ -2,15 +2,16 @@ package services import ( "fmt" - "github.com/Sirupsen/logrus" - "github.com/go-chi/chi" - "github.com/stretchr/testify/assert" "io/ioutil" "net/http" "net/http/httptest" "os" "strings" "testing" + + "github.com/Sirupsen/logrus" + "github.com/go-chi/chi" + "github.com/stretchr/testify/assert" ) const validTestCase = ` @@ -454,7 +455,7 @@ func TestDeleteAllCasesSuccess(t *testing.T) { logrus.Errorf("Error trying to create a file: %s", err) } - request, err := http.NewRequest(http.MethodDelete, "/test-cases/all", nil) + request, err := http.NewRequest(http.MethodDelete, "/test-cases/", nil) if err != nil { logrus.Warnf("Error creating the request %s", err) } @@ -472,7 +473,7 @@ func TestDeleteAllCasesNoHeader(t *testing.T) { r.Mount("/", GetIndexPage()) DirectoryPath := "" - request, err := http.NewRequest(http.MethodDelete, "/test-cases/all", nil) + request, err := http.NewRequest(http.MethodDelete, "/test-cases/", nil) if err != nil { logrus.Warnf("Error creating the request %s", err) } diff --git a/uiServices/test/testCase.feature b/uiServices/test/testCase.feature index acece87..eb05cd7 100644 --- a/uiServices/test/testCase.feature +++ b/uiServices/test/testCase.feature @@ -546,7 +546,7 @@ Feature: Test Case Scenarios Scenario: Unsuccessful deleting of test-case (No Header) Given the automated performance ui server is available And the header "testCasePathDir" is "" - When I send a "DELETE" request to "/test-cases/all" + When I send a "DELETE" request to "/test-cases/" Then the response code should be 400 @@ -561,5 +561,5 @@ Scenario: Successful deleting of test-case file with DELETE request Given the "deleteTest.xml" has been created at "/uiServices/test/cases" Given the automated performance ui server is available And the header "testCasePathDir" is "/uiServices/test/cases" - When I send a "DELETE" request to "/test-cases/all" + When I send a "DELETE" request to "/test-cases" Then the response code should be 200 \ No newline at end of file From b844cabd4c19076c8de11152c365b77b25a59fea Mon Sep 17 00:00:00 2001 From: "Smyth, Conor" Date: Mon, 12 Mar 2018 12:43:04 +0000 Subject: [PATCH 70/82] fixing integration tests --- uiServices/src/testCaseServices_test.go | 4 ++-- uiServices/test/testCase.feature | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/uiServices/src/testCaseServices_test.go b/uiServices/src/testCaseServices_test.go index 98a0e1a..1c1f570 100644 --- a/uiServices/src/testCaseServices_test.go +++ b/uiServices/src/testCaseServices_test.go @@ -455,7 +455,7 @@ func TestDeleteAllCasesSuccess(t *testing.T) { logrus.Errorf("Error trying to create a file: %s", err) } - request, err := http.NewRequest(http.MethodDelete, "/test-cases/", nil) + request, err := http.NewRequest(http.MethodDelete, "/test-cases", nil) if err != nil { logrus.Warnf("Error creating the request %s", err) } @@ -473,7 +473,7 @@ func TestDeleteAllCasesNoHeader(t *testing.T) { r.Mount("/", GetIndexPage()) DirectoryPath := "" - request, err := http.NewRequest(http.MethodDelete, "/test-cases/", nil) + request, err := http.NewRequest(http.MethodDelete, "/test-cases", nil) if err != nil { logrus.Warnf("Error creating the request %s", err) } diff --git a/uiServices/test/testCase.feature b/uiServices/test/testCase.feature index eb05cd7..d4c2cb1 100644 --- a/uiServices/test/testCase.feature +++ b/uiServices/test/testCase.feature @@ -546,7 +546,7 @@ Feature: Test Case Scenarios Scenario: Unsuccessful deleting of test-case (No Header) Given the automated performance ui server is available And the header "testCasePathDir" is "" - When I send a "DELETE" request to "/test-cases/" + When I send a "DELETE" request to "/test-cases" Then the response code should be 400 From a153b8d195820f0f0da3f520f9baf551dd579ac0 Mon Sep 17 00:00:00 2001 From: "Farcas, Camelia" Date: Mon, 12 Mar 2018 15:39:25 +0000 Subject: [PATCH 71/82] XAPTC-63 modified function deleteAllTestCases --- uiServices/src/testCaseServices.go | 14 +++++++++++--- uiServices/src/testCaseServices_test.go | 7 ++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index 06a3b01..cde191a 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -300,16 +300,24 @@ func deleteAllTestCases(rw http.ResponseWriter, req *http.Request) { return } - files, err := ioutil.ReadDir(testCasePathDir) + dir, err := os.Open(testCasePathDir) + if err != nil { + logrus.Error("Cannot open directory", err) + return + + } + + files, err := dir.Readdirnames(-1) if err != nil { logrus.Error("Cannot read directory ", err) + rw.WriteHeader(http.StatusNotFound) return } for _, file := range files { - err := os.RemoveAll(filepath.Join(testCasePathDir, file.Name())) + err = os.RemoveAll(filepath.Join(testCasePathDir + file)) if err != nil { - logrus.Errorf("Error deleting the files from filesystem: %s", err) + logrus.Errorf("Error deleting the files from directory: %s", err) rw.WriteHeader(http.StatusNotFound) return } diff --git a/uiServices/src/testCaseServices_test.go b/uiServices/src/testCaseServices_test.go index 1c1f570..929a495 100644 --- a/uiServices/src/testCaseServices_test.go +++ b/uiServices/src/testCaseServices_test.go @@ -449,7 +449,7 @@ func TestDeleteAllCasesSuccess(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) - DirectoryPath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/cases" + DirectoryPath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/cases/" err := ioutil.WriteFile(fmt.Sprintf("%s%s.xml", DirectoryPath, "test"), nil, 0666) if err != nil { logrus.Errorf("Error trying to create a file: %s", err) @@ -490,10 +490,11 @@ func TestDeleteAllCasesEmptyDirectory(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) - DirectoryPath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/cases" + DirectoryPath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/cases/" request, err := http.NewRequest(http.MethodDelete, "/test-cases/", nil) if err != nil { logrus.Warnf("Error creating the request %s", err) + return } request.Header.Set("testCasePathDir", DirectoryPath) @@ -511,7 +512,7 @@ func TestSuccessfulCaseDelete(t *testing.T) { reader := strings.NewReader(TestCaseForDeletion) r.HandleFunc("/test-cases", postTestCase) - filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" + filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPost, "/test-cases", reader) request.Header.Set("testCasePathDir", filePath) From d7978388423fd6315ab99fe220d7fc1bffb41ef6 Mon Sep 17 00:00:00 2001 From: "Farcas, Camelia" Date: Mon, 12 Mar 2018 16:39:00 +0000 Subject: [PATCH 72/82] XAPTC-63 integration tests fixed --- uiServices/src/testCaseServices.go | 19 ++++++------------ uiServices/test/GodogConfig.xml | 19 ------------------ uiServices/test/GodogTestCase.xml | 29 --------------------------- uiServices/test/GodogTestCase2.xml | 29 --------------------------- uiServices/test/GodogTestSuite.xml | 8 -------- uiServices/test/ServiceTestConfig.xml | 19 ------------------ uiServices/test/TestCaseService.xml | 29 --------------------------- uiServices/test/TestSuiteService.xml | 9 --------- uiServices/test/cases/deleteTest.xml | 0 uiServices/test/casestest.xml | 0 uiServices/test/godog_test.go | 2 +- uiServices/test/test.xml | 0 uiServices/test/x.xml | 19 ------------------ 13 files changed, 7 insertions(+), 175 deletions(-) delete mode 100644 uiServices/test/GodogConfig.xml delete mode 100644 uiServices/test/GodogTestCase.xml delete mode 100644 uiServices/test/GodogTestCase2.xml delete mode 100644 uiServices/test/GodogTestSuite.xml delete mode 100644 uiServices/test/ServiceTestConfig.xml delete mode 100644 uiServices/test/TestCaseService.xml delete mode 100644 uiServices/test/TestSuiteService.xml delete mode 100644 uiServices/test/cases/deleteTest.xml delete mode 100644 uiServices/test/casestest.xml delete mode 100644 uiServices/test/test.xml delete mode 100644 uiServices/test/x.xml diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index cde191a..c7ee484 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -294,28 +294,21 @@ func deleteTestCase(rw http.ResponseWriter, req *http.Request) { } func deleteAllTestCases(rw http.ResponseWriter, req *http.Request) { testCasePathDir := getTestCaseHeader(req) - + logrus.Println("testCasePathDir", testCasePathDir) if err := IsHeaderValid(testCasePathDir); err != nil { rw.WriteHeader(http.StatusBadRequest) return } - dir, err := os.Open(testCasePathDir) - if err != nil { - logrus.Error("Cannot open directory", err) - return - - } - - files, err := dir.Readdirnames(-1) + files, err := ioutil.ReadDir(testCasePathDir) if err != nil { - logrus.Error("Cannot read directory ", err) - rw.WriteHeader(http.StatusNotFound) - return + logrus.Error(err) } for _, file := range files { - err = os.RemoveAll(filepath.Join(testCasePathDir + file)) + filepath := fmt.Sprintf("%s%s", testCasePathDir, file.Name()) + + err := os.Remove(filepath) if err != nil { logrus.Errorf("Error deleting the files from directory: %s", err) rw.WriteHeader(http.StatusNotFound) diff --git a/uiServices/test/GodogConfig.xml b/uiServices/test/GodogConfig.xml deleted file mode 100644 index 0cdd26b..0000000 --- a/uiServices/test/GodogConfig.xml +++ /dev/null @@ -1,19 +0,0 @@ - - GodogAPI - localhost - 1001 - 4000 - 50 - 50 - ./definitions/testCases - ./definitions/testSuites - ./envStats - ./report - 50 - Default-3 - /alt/debug/vars - 1000 - 10 - 10 - 10 - \ No newline at end of file diff --git a/uiServices/test/GodogTestCase.xml b/uiServices/test/GodogTestCase.xml deleted file mode 100644 index c70ab2d..0000000 --- a/uiServices/test/GodogTestCase.xml +++ /dev/null @@ -1,29 +0,0 @@ - - GodogTestCase - host - 1001 - POST - desc - path/to/URI - false - payload - - - F-Name - PayloadName - file-name - - - - 200 - JSON - -
Header-Value
-
- - Res-Value - - 1000 - 2000 - Sparse -
\ No newline at end of file diff --git a/uiServices/test/GodogTestCase2.xml b/uiServices/test/GodogTestCase2.xml deleted file mode 100644 index b7a8604..0000000 --- a/uiServices/test/GodogTestCase2.xml +++ /dev/null @@ -1,29 +0,0 @@ - - GodogTestCase2 - host - 9191 - PUT - desc2 - path/to/URI - false - payload - - - F-Name - PayloadName - file-name - - - - 200 - JSON - -
Header-Value
-
- - Res-Value - - 1000 - 2000 - Sparse -
\ No newline at end of file diff --git a/uiServices/test/GodogTestSuite.xml b/uiServices/test/GodogTestSuite.xml deleted file mode 100644 index 816379d..0000000 --- a/uiServices/test/GodogTestSuite.xml +++ /dev/null @@ -1,8 +0,0 @@ - - GodogTestSuite2 - ServiceDesc - SuiteBased - - file1 - - \ No newline at end of file diff --git a/uiServices/test/ServiceTestConfig.xml b/uiServices/test/ServiceTestConfig.xml deleted file mode 100644 index b8211ad..0000000 --- a/uiServices/test/ServiceTestConfig.xml +++ /dev/null @@ -1,19 +0,0 @@ - - ServiceTestConfig - localhost - 9191 - 1000 - 30 - 30 - ./definitions/testCases - ./definitions/testSuites - ./envStats - ./report - 50 - Default-1 - /alt/debug/vars - 5000 - 30 - 5 - 15 - \ No newline at end of file diff --git a/uiServices/test/TestCaseService.xml b/uiServices/test/TestCaseService.xml deleted file mode 100644 index 2b6ce3a..0000000 --- a/uiServices/test/TestCaseService.xml +++ /dev/null @@ -1,29 +0,0 @@ - - TestCaseService - host - 9191 - GET - desc - path/to/URI - false - payload - - - F-Name - PayloadName - file-name - - - - 200 - JSON - -
Header-Value
-
- - Res-Value - - 1000 - 2000 - Sparse -
\ No newline at end of file diff --git a/uiServices/test/TestSuiteService.xml b/uiServices/test/TestSuiteService.xml deleted file mode 100644 index f6e6e90..0000000 --- a/uiServices/test/TestSuiteService.xml +++ /dev/null @@ -1,9 +0,0 @@ - - TestSuiteService - Services for XYZ - SuiteBased - - file1 - file2 - - \ No newline at end of file diff --git a/uiServices/test/cases/deleteTest.xml b/uiServices/test/cases/deleteTest.xml deleted file mode 100644 index e69de29..0000000 diff --git a/uiServices/test/casestest.xml b/uiServices/test/casestest.xml deleted file mode 100644 index e69de29..0000000 diff --git a/uiServices/test/godog_test.go b/uiServices/test/godog_test.go index 3a1710c..9be7405 100644 --- a/uiServices/test/godog_test.go +++ b/uiServices/test/godog_test.go @@ -358,7 +358,7 @@ func makeGetRequest(client *http.Client, method, endpoint string, filename strin if headerPath == "" { req.Header.Set(headerName, "") } else { - req.Header.Set(headerName, fmt.Sprintf("%s/src/github.com/xtracdev/automated-perf-test/uiServices/test/", os.Getenv("GOPATH"))) + req.Header.Set(headerName, fmt.Sprintf("%s/src/github.com/xtracdev/automated-perf-test/%s", os.Getenv("GOPATH"), headerPath)) } if err != nil { return nil, err diff --git a/uiServices/test/test.xml b/uiServices/test/test.xml deleted file mode 100644 index e69de29..0000000 diff --git a/uiServices/test/x.xml b/uiServices/test/x.xml deleted file mode 100644 index d2c91c6..0000000 --- a/uiServices/test/x.xml +++ /dev/null @@ -1,19 +0,0 @@ - - x - localhost - 9191 - 1000 - 30 - 30 - ./definitions/testCases - ./definitions/testSuites - ./envStats - ./report - 50 - Default-1 - /alt/debug/vars - 5000 - 30 - 5 - 15 - \ No newline at end of file From 28272e3672e6c82703291fa97c71a88ad70d09c4 Mon Sep 17 00:00:00 2001 From: "Farcas, Camelia" Date: Mon, 12 Mar 2018 16:46:16 +0000 Subject: [PATCH 73/82] homepage_test.go file deleted --- uiServices/src/homepage_test.go | 53 --------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 uiServices/src/homepage_test.go diff --git a/uiServices/src/homepage_test.go b/uiServices/src/homepage_test.go deleted file mode 100644 index 46d6712..0000000 --- a/uiServices/src/homepage_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package services - -// func TestStartUiModeSuccesfully(t *testing.T) { - -// r := chi.NewRouter() - -// r.Mount("/", GetIndexPage()) - -// assert.IsType(t, &chi.Mux{}, r) - -// resp := httptest.NewRecorder() - -// req, _ := http.NewRequest(http.MethodGet, "/", nil) -// r.ServeHTTP(resp, req) - -// assert.Equal(t, http.StatusOK, resp.Code) -// assert.Equal(t, htmlType, resp.Header().Get(contentTypeHeader)) - -// } - -// func TestStartUiModeWithInvalidURL(t *testing.T) { - -// r := chi.NewRouter() - -// r.Mount("/", GetIndexPage()) - -// assert.IsType(t, &chi.Mux{}, r) - -// resp := httptest.NewRecorder() - -// req, _ := http.NewRequest(http.MethodGet, "/xxx", nil) -// r.ServeHTTP(resp, req) - -// assert.Equal(t, http.StatusNotFound, resp.Code) -// } - -// func TestStartUiModeWithResource(t *testing.T) { - -// r := chi.NewRouter() - -// r.Mount("/", GetIndexPage()) - -// assert.IsType(t, &chi.Mux{}, r) - -// resp := httptest.NewRecorder() - -// req, _ := http.NewRequest(http.MethodGet, "/index.html", nil) -// r.ServeHTTP(resp, req) - -// assert.Equal(t, http.StatusOK, resp.Code) -// assert.Equal(t, htmlType, resp.Header().Get(contentTypeHeader)) - -// } From e8825d70b5f221ef0ee4efb0e384129db948036e Mon Sep 17 00:00:00 2001 From: "Farcas, Camelia" Date: Mon, 12 Mar 2018 16:51:29 +0000 Subject: [PATCH 74/82] loop fixed, in testCaseService --- uiServices/src/testCaseServices.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index c7ee484..8986c56 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -314,7 +314,6 @@ func deleteAllTestCases(rw http.ResponseWriter, req *http.Request) { rw.WriteHeader(http.StatusNotFound) return } - - rw.WriteHeader(http.StatusOK) } + rw.WriteHeader(http.StatusOK) } From 1352adc6e4197bdcf5aac0c14cebeaacfd8b40e4 Mon Sep 17 00:00:00 2001 From: "Flynn, Jenny" Date: Mon, 12 Mar 2018 17:18:34 +0000 Subject: [PATCH 75/82] refactor of headers reuse functions add logging --- .gitignore | 8 +- testStrategies/commonToAllTestStrategies.go | 10 +- ui-src/src/assets/schema.json | 3 +- ui-src/src/assets/testCase_schema.json | 50 +++++--- ui-src/src/assets/testSuite_schema.json | 12 +- uiServices/src/configServices.go | 56 ++------ uiServices/src/configServices_test.go | 73 ++++------- uiServices/src/homepage.go | 9 +- uiServices/src/testCaseServices.go | 61 +++++---- uiServices/src/testCaseServices_test.go | 110 ++++++++-------- uiServices/src/testSuiteServices.go | 79 ++++-------- uiServices/src/testSuiteServices_test.go | 52 ++++---- uiServices/src/util.go | 45 +++++++ uiServices/src/util_test.go | 25 ++++ uiServices/src/xmlWriter.go | 51 +++++++- uiServices/test/GodogConfig.xml | 19 --- uiServices/test/GodogTestCase.xml | 29 ----- uiServices/test/GodogTestCase2.xml | 6 +- uiServices/test/GodogTestSuite.xml | 8 -- uiServices/test/ServiceTestConfig.xml | 19 --- uiServices/test/TestCaseService.xml | 29 ----- uiServices/test/TestSuiteService.xml | 9 -- uiServices/test/configFile.feature | 28 ++-- uiServices/test/godog_test.go | 32 ++--- .../{casestest.xml => samples/testCase.json} | 0 .../test/{test.xml => samples/testCase.xml} | 0 uiServices/test/samples/testSuite.json | 0 uiServices/test/samples/testSuite.xml | 0 uiServices/test/testCase.feature | 120 +++++++++--------- uiServices/test/testSuite.feature | 34 ++--- uiServices/test/x.xml | 19 --- 31 files changed, 458 insertions(+), 538 deletions(-) create mode 100644 uiServices/src/util.go create mode 100644 uiServices/src/util_test.go delete mode 100644 uiServices/test/GodogConfig.xml delete mode 100644 uiServices/test/GodogTestSuite.xml delete mode 100644 uiServices/test/ServiceTestConfig.xml delete mode 100644 uiServices/test/TestCaseService.xml delete mode 100644 uiServices/test/TestSuiteService.xml rename uiServices/test/{casestest.xml => samples/testCase.json} (100%) rename uiServices/test/{test.xml => samples/testCase.xml} (100%) create mode 100644 uiServices/test/samples/testSuite.json create mode 100644 uiServices/test/samples/testSuite.xml delete mode 100644 uiServices/test/x.xml diff --git a/.gitignore b/.gitignore index 70bfbef..8d8be00 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,10 @@ - +config/*.xml + !config/config.xml + *.iml + .idea + ui/ + automated-perf-test + uiServices/test/*.xml *.bak main .idea diff --git a/testStrategies/commonToAllTestStrategies.go b/testStrategies/commonToAllTestStrategies.go index 84bcea5..89392f5 100644 --- a/testStrategies/commonToAllTestStrategies.go +++ b/testStrategies/commonToAllTestStrategies.go @@ -64,9 +64,9 @@ type TestDefinition struct { ResponseContentType string `xml:"responseContentType"` Headers []Header `xml:"headers>header"` ResponseValues []ResponseValue `xml:"responseProperties>value"` - PreThinkTime int64 `xml:"preThinkTime"` - PostThinkTime int64 `xml:"postThinkTime"` - ExecWeight string `xml:"execWeight"` + PreThinkTime int64 `xml:"preThinkTime"` + PostThinkTime int64 `xml:"postThinkTime"` + ExecWeight string `xml:"execWeight"` } // TestSuite fields get populated from the TestSuiteDefinition after the XML @@ -74,7 +74,7 @@ type TestDefinition struct { type TestSuite struct { XMLName xml.Name `xml:"testSuite"` Name string `xml:"name" json:"name"` - Description string `xml:"description" json:"description"` + Description string `xml:"description" json:"description"` TestStrategy string `xml:"testStrategy"` TestCases []TestCase `xml:"testCases>testCase"` TestDefinitions []*TestDefinition @@ -87,7 +87,7 @@ type TestCase struct { XMLName xml.Name `xml:"testCase"` Name string `xml:",chardata"` Description string `xml:"description,attr" json:"description"` - PreThinkTime int64 `xml:"preThinkTime,attr" json:"preThinkTime"` + PreThinkTime int64 `xml:"preThinkTime,attr" json:"preThinkTime"` PostThinkTime int64 `xml:"postThinkTime,attr" json:"postThinkTime"` ExecWeight string `xml:"execWeight,attr" json:"execWeight"` } diff --git a/ui-src/src/assets/schema.json b/ui-src/src/assets/schema.json index d4428d3..1109f1c 100644 --- a/ui-src/src/assets/schema.json +++ b/ui-src/src/assets/schema.json @@ -16,8 +16,9 @@ "testCaseDir", "testSuiteDir", "baseStatsOutputDir", - "reportOutputDir" + "reportOutputDir" ], + "additionalProperties": false, "properties": { "apiName": { "type": "string" diff --git a/ui-src/src/assets/testCase_schema.json b/ui-src/src/assets/testCase_schema.json index 8df4c6b..2b8da10 100644 --- a/ui-src/src/assets/testCase_schema.json +++ b/ui-src/src/assets/testCase_schema.json @@ -5,17 +5,19 @@ "overridePort", "overrideHost", "httpMethod", - "BaseURI", + "baseUri", "multipart", + "multipartPayload", "payload", "responseStatusCode", "responseContentType", "preThinkTime", "postThinkTime", "execWeight", - "Headers", - "ResponseValues" + "headers", + "responseValues" ], + "additionalProperties": false, "properties": { "testname": { "type": "string" @@ -23,7 +25,7 @@ "description": { "type": "string" }, - "BaseURI": { + "baseUri": { "type": "string" }, "overrideHost": { @@ -47,20 +49,20 @@ "DELETE" ] }, - "Headers": { + "headers": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": [ - "Key", - "Value" + "key", + "value" ], "properties": { - "Key": { + "key": { "type": "string" }, - "Value": { + "value": { "type": "string" } } @@ -85,24 +87,42 @@ "responseContentType": { "type": "string" }, - "ResponseValues": { + "multipartPayload": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "fieldName": { + "type": "string" + }, + "fieldValue":{ + "type": "string" + }, + "fileName": { + "type": "string" + } + } + } + }, + "responseValues": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": [ - "Value", - "ExtractionKey" + "value", + "extractionKey" ], "properties": { - "ExtractionKey": { + "extractionKey": { "type": "string" }, - "Value": { + "value": { "type": "string" } } } } } -} \ No newline at end of file +} diff --git a/ui-src/src/assets/testSuite_schema.json b/ui-src/src/assets/testSuite_schema.json index b7ac0d5..2b1194d 100644 --- a/ui-src/src/assets/testSuite_schema.json +++ b/ui-src/src/assets/testSuite_schema.json @@ -1,7 +1,7 @@ { "type": "object", "required": ["name", "testStrategy"], - + "additionalProperties": false, "properties": { "testStrategy": { "type": "string", @@ -14,10 +14,10 @@ "type": "string" } }} - - - - - + + + + + diff --git a/uiServices/src/configServices.go b/uiServices/src/configServices.go index cc96972..7188cf6 100644 --- a/uiServices/src/configServices.go +++ b/uiServices/src/configServices.go @@ -15,17 +15,10 @@ import ( "github.com/xtracdev/automated-perf-test/perfTestUtils" ) -var schemaFilename string = "schema.json" -var structName string = "Config" - -func getConfigHeader(req *http.Request) string { - configPathDir := req.Header.Get("configPathDir") - - if !strings.HasSuffix(configPathDir, "/") { - configPathDir = configPathDir + "/" - } - return configPathDir -} +const ( + configSchema = "schema.json" + configStruct = "Config" +) func IsHeaderValid(header string) error { if len(header) <= 1 { @@ -60,11 +53,11 @@ func ConfigCtx(next http.Handler) http.Handler { func postConfigs(rw http.ResponseWriter, req *http.Request) { rw.Header().Set("Access-Control-Allow-Origin", "*") - configPathDir := req.Header.Get("configPathDir") + configPathDir := getPathHeader(req) buf := new(bytes.Buffer) buf.ReadFrom(req.Body) - if !ValidateJsonWithSchema(buf.Bytes(), "schema.json", "Configurations") { + if !validateJSONWithSchema(buf.Bytes(), "schema.json", "Configurations") { rw.WriteHeader(http.StatusBadRequest) return } @@ -103,7 +96,7 @@ func postConfigs(rw http.ResponseWriter, req *http.Request) { } - if !configWriterXML(config, configPathDir+config.APIName+".xml") { + if !writeXml(config, configPathDir+config.APIName+".xml") { rw.WriteHeader(http.StatusInternalServerError) return @@ -112,14 +105,9 @@ func postConfigs(rw http.ResponseWriter, req *http.Request) { rw.WriteHeader(http.StatusCreated) } -func FilePathExist(path string) bool { - _, err := os.Stat(path) - return !os.IsNotExist(err) -} - func getConfigs(rw http.ResponseWriter, req *http.Request) { rw.Header().Set("Access-Control-Allow-Origin", "*") - configPathDir := getConfigHeader(req) + configPathDir := getPathHeader(req) configName := chi.URLParam(req, "configName") if err := IsHeaderValid(configPathDir); err != nil { @@ -153,14 +141,14 @@ func getConfigs(rw http.ResponseWriter, req *http.Request) { err = xml.Unmarshal(byteValue, &config) if err != nil { rw.WriteHeader(http.StatusInternalServerError) - logrus.Error("Cannot Unmarshall") + logrus.Error("Cannot Unmarshall XML", err) return } configJson, err := json.MarshalIndent(config, "", "") if err != nil { rw.WriteHeader(http.StatusInternalServerError) - logrus.Error("Cannot Marshall") + logrus.Error("Cannot Marshall JSON", err) return } @@ -171,7 +159,7 @@ func getConfigs(rw http.ResponseWriter, req *http.Request) { } func putConfigs(rw http.ResponseWriter, req *http.Request) { - path := getConfigHeader(req) + path := getPathHeader(req) configName := chi.URLParam(req, "configName") if err := IsHeaderValid(path); err != nil { @@ -188,7 +176,7 @@ func putConfigs(rw http.ResponseWriter, req *http.Request) { buf := new(bytes.Buffer) buf.ReadFrom(req.Body) - if !ValidateJsonWithSchema(buf.Bytes(), schemaFilename, structName) { + if !validateJSONWithSchema(buf.Bytes(), configSchema, configStruct) { rw.WriteHeader(http.StatusBadRequest) return } @@ -208,7 +196,7 @@ func putConfigs(rw http.ResponseWriter, req *http.Request) { } - if !configWriterXml(config, configPathDir) { + if !writeXml(config, configPathDir) { rw.WriteHeader(http.StatusInternalServerError) return } @@ -217,23 +205,7 @@ func putConfigs(rw http.ResponseWriter, req *http.Request) { } func putConfigFileName(rw http.ResponseWriter, req *http.Request) { - path := getConfigHeader(req) - configFileName := chi.URLParam(req, "configFileName") - newConfigFileName := chi.URLParam(req, "newConfigFileName") - - if len(newConfigFileName) < 1 { - logrus.Error("File path does not exist") - rw.WriteHeader(http.StatusBadRequest) - return - } - - os.Rename(fmt.Sprintf("%s%s.xml", path, configFileName), fmt.Sprintf("%s%s.xml", path, newConfigFileName)) - - rw.WriteHeader(http.StatusNoContent) -} - -func putConfigFileName(rw http.ResponseWriter, req *http.Request) { - path := getConfigHeader(req) + path := getPathHeader(req) configFileName := chi.URLParam(req, "configFileName") newConfigFileName := chi.URLParam(req, "newConfigFileName") diff --git a/uiServices/src/configServices_test.go b/uiServices/src/configServices_test.go index 75452f1..fcb0901 100644 --- a/uiServices/src/configServices_test.go +++ b/uiServices/src/configServices_test.go @@ -1,7 +1,6 @@ package services import ( - "fmt" "net/http" "net/http/httptest" "os" @@ -93,22 +92,6 @@ const validJsonWithOneCharName = `{ "rampDelay": 15 }` -func TestFilePathExist(t *testing.T) { - path := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" - actual := false - fmt.Println(path) - actual = FilePathExist(path) - expected := true - assert.Equal(t, expected, actual) -} - -func TestFilePathDoesNotExist(t *testing.T) { - path := "(((((((" - actual := FilePathExist(path) - expected := false - assert.Equal(t, expected, actual) -} - func TestInvalidJsonPostMissingRequiredField(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) @@ -118,7 +101,7 @@ func TestInvalidJsonPostMissingRequiredField(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPost, "/configs", reader) - request.Header.Set("configPathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -144,18 +127,16 @@ func TestValidJsonPost(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPost, "/configs", reader) - request.Header.Set("configPathDir", filePath) + + assert.NoError(t, err) + + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) - if err != nil { - t.Error(err) - } + assert.Equal(t, http.StatusCreated, w.Code) - if w.Code != http.StatusCreated { - t.Error("TestValidJsonPost. Expected:", http.StatusCreated, " Got:", w.Code, " Error. Did not succesfully post") - } } func TestPostWithOneCharName(t *testing.T) { @@ -169,7 +150,7 @@ func TestPostWithOneCharName(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPost, "/configs", reader) - request.Header.Set("configPathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -191,7 +172,7 @@ func TestPostWithInvalidHeader(t *testing.T) { filePath := "xxxxxx" request, err := http.NewRequest(http.MethodPost, "/configs", reader) - request.Header.Set("configPathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -226,7 +207,7 @@ func TestInvalidJsonPost(t *testing.T) { } } -func TestWhenConfigPathDirEmpty(t *testing.T) { +func TestWhenpathEmpty(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) @@ -243,7 +224,7 @@ func TestWhenConfigPathDirEmpty(t *testing.T) { } if w.Code != http.StatusBadRequest { - t.Error("TestWhenConfigPathDirEmpty. Expected:", http.StatusBadRequest, " Got:", w.Code, "Error. ConfigPathDir is Empty ") + t.Error("TestWhenpathEmpty. Expected:", http.StatusBadRequest, " Got:", w.Code, "Error. path is Empty ") } } @@ -262,7 +243,7 @@ func TestSuccessfulGet(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPost, "/configs", reader) - request.Header.Set("configPathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -270,8 +251,8 @@ func TestSuccessfulGet(t *testing.T) { filePath = os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err = http.NewRequest(http.MethodGet, "/configs/ServiceTestConfig", nil) - request.Header.Set("configPathDir", filePath) - request.Header.Get("configPathDir") + request.Header.Set("path", filePath) + request.Header.Get("path") w = httptest.NewRecorder() r.ServeHTTP(w, request) @@ -294,8 +275,8 @@ func TestSuccessfulGetPathWihoutSlash(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodGet, "/configs/ServiceTestConfig", nil) - request.Header.Set("configPathDir", filePath) - request.Header.Get("configPathDir") + request.Header.Set("path", filePath) + request.Header.Get("path") w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -318,8 +299,8 @@ func TestGetNoHeaderPath(t *testing.T) { filePath := "" request, err := http.NewRequest(http.MethodGet, "/configs/serviceTestConfig", nil) - request.Header.Set("configPathDir", filePath) - request.Header.Get("configPathDir") + request.Header.Set("path", filePath) + request.Header.Get("path") w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -342,8 +323,8 @@ func TestGetFileNotFound(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodGet, "/configs/xxx.java", nil) - request.Header.Set("configPathDir", filePath) - request.Header.Get("configPathDir") + request.Header.Set("path", filePath) + request.Header.Get("path") w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -366,7 +347,7 @@ func TestValidJsonPut(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPut, "/configs/ServiceTestConfig", reader) - request.Header.Set("configPathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -387,7 +368,7 @@ func TestMissingFieldPut(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPut, "/configs/ServiceTestConfig", reader) - request.Header.Set("configPathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -408,7 +389,7 @@ func TestInvalidJsonPut(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPut, "/configs/ServiceTestConfig", reader) - request.Header.Set("configPathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -429,7 +410,7 @@ func TestInvalidUrlPut(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPut, "/configs/xxx", reader) - request.Header.Set("configPathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -450,7 +431,7 @@ func TestNoUrlPut(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPut, "", reader) - request.Header.Set("configPathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -471,7 +452,7 @@ func TestSuccessfulPutWithNoPathSlash(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPut, "/configs/ServiceTestConfig", reader) - request.Header.Set("configPathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -491,7 +472,7 @@ func TestNoPathPut(t *testing.T) { filePath := "" request, err := http.NewRequest(http.MethodPut, "/configs/ServiceTestConfig", reader) - request.Header.Set("configPathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -512,7 +493,7 @@ func TestNoFileNamePut(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPut, "/configs", reader) - request.Header.Set("configPathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) diff --git a/uiServices/src/homepage.go b/uiServices/src/homepage.go index b0b2bac..d4af129 100644 --- a/uiServices/src/homepage.go +++ b/uiServices/src/homepage.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "net/http" "path/filepath" - "github.com/go-chi/cors" + "github.com/Sirupsen/logrus" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" @@ -70,7 +70,7 @@ func GetIndexPage() *chi.Mux { }) router.Mount("/configs", routeConfigs()) - router.Mount("/test-suites/getAllCases/", routeTestCases()) + router.Mount("/test-cases", routeTestCases()) router.Mount("/test-suites", routeTestSuites()) router.Get("/*", func(w http.ResponseWriter, r *http.Request) { @@ -127,6 +127,7 @@ func routeTestSuites() http.Handler { router.Put("/{testSuiteName}", putTestSuites) router.Get("/{testSuiteName}", getTestSuite) router.Get("/", getAllTestSuites) + router.Delete("/{testSuiteName}", deleteTestSuite) return router } @@ -134,10 +135,12 @@ func routeTestSuites() http.Handler { func routeTestCases() http.Handler { router := chi.NewRouter() router.Use(TestCaseCtx) + router.Post("/", postTestCase) router.Get("/", getAllTestCases) router.Get("/{testCaseName}", getTestCase) router.Delete("/{testCaseName}", deleteTestCase) - router.Delete("/all", deleteAllTestCases) + router.Delete("/", deleteAllTestCases) + router.Put("/{testCaseName}", putTestCase) return router } diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index 018f4c5..529a713 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -1,6 +1,7 @@ package services import ( + "bytes" "encoding/json" "encoding/xml" "fmt" @@ -9,13 +10,17 @@ import ( "net/http" "os" "path/filepath" - "strings" "github.com/Sirupsen/logrus" "github.com/go-chi/chi" "github.com/xtracdev/automated-perf-test/testStrategies" ) +const ( + testCaseSchema = "testCase_Schema.json" + testCaseStruct = "testDefinition" +) + type Case struct { HttpMethod string `json:"httpMethod"` Name string `json:"name"` @@ -29,26 +34,17 @@ func TestCaseCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { next.ServeHTTP(w, r) }) - -} -func getTestCaseHeader(req *http.Request) string { - testCasePathDir := req.Header.Get("testSuitePathDir") - - if !strings.HasSuffix(testCasePathDir, "/") { - testCasePathDir = testCasePathDir + "/" - } - return testCasePathDir } func postTestCase(rw http.ResponseWriter, req *http.Request) { - testCasePathDir := getTestCaseHeader(req) + testCasePathDir := getPathHeader(req) buf := new(bytes.Buffer) buf.ReadFrom(req.Body) testCase := testStrategies.TestDefinition{} err := json.Unmarshal(buf.Bytes(), &testCase) if err != nil { - logrus.Error("Failed to unmarshall json body") + logrus.Error("Failed to unmarshall json body", err) rw.WriteHeader(http.StatusBadRequest) return } @@ -77,6 +73,11 @@ func postTestCase(rw http.ResponseWriter, req *http.Request) { } + if !validateJSONWithSchema(buf.Bytes(), testCaseSchema, testCaseStruct) { + rw.WriteHeader(http.StatusBadRequest) + return + } + if !testCaseWriterXml(testCase, testCasePathDir+testCase.TestName+".xml") { rw.WriteHeader(http.StatusInternalServerError) return @@ -86,7 +87,7 @@ func postTestCase(rw http.ResponseWriter, req *http.Request) { } func putTestCase(rw http.ResponseWriter, req *http.Request) { - path := getTestCaseHeader(req) + path := getPathHeader(req) testCaseName := chi.URLParam(req, "testCaseName") if err := IsHeaderValid(path); err != nil { @@ -99,8 +100,8 @@ func putTestCase(rw http.ResponseWriter, req *http.Request) { } testCasePathDir := fmt.Sprintf("%s%s.xml", path, testCaseName) - buf := new(bytes.Buffer) - buf.ReadFrom(req.Body) + + logrus.Error("testCasePathDir", testCasePathDir) if !FilePathExist(testCasePathDir) { logrus.Error("File path does not exist") @@ -109,7 +110,10 @@ func putTestCase(rw http.ResponseWriter, req *http.Request) { } - if !ValidateJSONWithSchema(buf.Bytes(), testCaseSchema, structTypeName) { + buf := new(bytes.Buffer) + buf.ReadFrom(req.Body) + + if !validateJSONWithSchema(buf.Bytes(), testCaseSchema, testCaseStruct) { rw.WriteHeader(http.StatusBadRequest) return } @@ -139,7 +143,7 @@ func putTestCase(rw http.ResponseWriter, req *http.Request) { func getAllTestCases(rw http.ResponseWriter, req *http.Request) { rw.Header().Set("Access-Control-Allow-Origin", "*") - testCasePathDir := getTestCaseHeader(req) + testCasePathDir := getPathHeader(req) if !IsPathDirValid(testCasePathDir, rw) { return @@ -161,17 +165,17 @@ func getAllTestCases(rw http.ResponseWriter, req *http.Request) { file, err := os.Open(fmt.Sprintf("%s%s", testCasePathDir, filename)) if err != nil { - logrus.Error("Cannot open file: ", filename) + logrus.Error("Cannot open file: ", filename, err) } byteValue, err := ioutil.ReadAll(file) if err != nil { - logrus.Error("Cannot Read File: ", filename) + logrus.Error("Cannot Read File: ", filename, err) } err = xml.Unmarshal(byteValue, testCase) if err != nil { - logrus.Error("Cannot Unmarshall: ", filename) + logrus.Error("Cannot Unmarshall: ", filename, err) } @@ -201,7 +205,7 @@ func getAllTestCases(rw http.ResponseWriter, req *http.Request) { func getTestCase(rw http.ResponseWriter, req *http.Request) { rw.Header().Set("Access-Control-Allow-Origin", "*") - testCasePathDir := getTestCaseHeader(req) + testCasePathDir := getPathHeader(req) testCaseName := chi.URLParam(req, "testCaseName") if err := IsHeaderValid(testCasePathDir); err != nil { @@ -214,6 +218,9 @@ func getTestCase(rw http.ResponseWriter, req *http.Request) { return } + filePath := fmt.Sprintf("%s%s.xml", testCasePathDir, testCaseName) + logrus.Info("FilePath: ", filePath) + if _, err := os.Stat(fmt.Sprintf("%s%s.xml", testCasePathDir, testCaseName)); err != nil { if os.IsNotExist(err) { logrus.Error("Test Case File Not Found: " + testCaseName) @@ -242,14 +249,14 @@ func getTestCase(rw http.ResponseWriter, req *http.Request) { err = xml.Unmarshal(byteValue, &testCase) if err != nil { rw.WriteHeader(http.StatusInternalServerError) - logrus.Error("Cannot Unmarshall from XML") + logrus.Error("Cannot Unmarshall from XML", err) return } testSuiteJSON, err := json.MarshalIndent(testCase, "", "") if err != nil { rw.WriteHeader(http.StatusInternalServerError) - logrus.Error("Cannot marshall to JSON") + logrus.Error("Cannot marshall to JSON", err) return } @@ -259,7 +266,7 @@ func getTestCase(rw http.ResponseWriter, req *http.Request) { } func deleteTestCase(rw http.ResponseWriter, req *http.Request) { - testCasePathDir := getTestCaseHeader(req) + testCasePathDir := getPathHeader(req) testCaseName := chi.URLParam(req, "testCaseName") if err := IsHeaderValid(testCasePathDir); err != nil { @@ -294,9 +301,11 @@ func deleteTestCase(rw http.ResponseWriter, req *http.Request) { } func deleteAllTestCases(rw http.ResponseWriter, req *http.Request) { - testCasePathDir := getTestCaseHeader(req) + testCasePathDir := getPathHeader(req) - if !IsHeaderValid(testCasePathDir, rw) { + if err := IsHeaderValid(testCasePathDir); err != nil { + + rw.WriteHeader(http.StatusBadRequest) return } diff --git a/uiServices/src/testCaseServices_test.go b/uiServices/src/testCaseServices_test.go index 535887a..976ef55 100644 --- a/uiServices/src/testCaseServices_test.go +++ b/uiServices/src/testCaseServices_test.go @@ -1,12 +1,14 @@ package services import ( - "github.com/go-chi/chi" - "github.com/stretchr/testify/assert" + "fmt" + "io/ioutil" "net/http" "net/http/httptest" "os" + "strings" "testing" + "github.com/Sirupsen/logrus" "github.com/go-chi/chi" "github.com/stretchr/testify/assert" @@ -91,13 +93,13 @@ const TestCaseMissingRequired = ` } ` -const TestCaseForDeletion = ` +const testCaseForDeletion = ` { "testname":"TestCaseService2", "description":"desc", "overrideHost":"host", "overridePort":"9191", - "HttpMethod":"GET", + "httpMethod":"GET", "BaseURI": "path/to/URI", "multipart":false, "payload": "payload", @@ -133,7 +135,7 @@ func TestValidTestCasePost(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPost, "/test-cases", reader) - request.Header.Set("testCasePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -152,7 +154,7 @@ func TestCasePostWithExistingFileName(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPost, "/test-cases", reader) - request.Header.Set("testCasePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -171,7 +173,7 @@ func TestCasePostNoHeader(t *testing.T) { filePath := "" request, err := http.NewRequest(http.MethodPost, "/test-cases", reader) - request.Header.Set("testCasePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -190,7 +192,7 @@ func TestPostTestCaseMissingRequiredValues(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPost, "/test-cases", reader) - request.Header.Set("testCasePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -203,21 +205,20 @@ func TestPostTestCaseMissingRequiredValues(t *testing.T) { func TestValidTestCasePut(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) - reader := strings.NewReader(validTestCase) - r.HandleFunc("/test-cases", putTestCase) + + //r.HandleFunc("/test-cases", putTestCase) filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPut, "/test-cases/TestCaseService", reader) - request.Header.Set("testCasePathDir", filePath) + + assert.NoError(t, err) + + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) - if err != nil { - t.Error(err) - } - assert.Equal(t, http.StatusNoContent, w.Code, "Did Not successfully Update") } @@ -230,7 +231,7 @@ func TestTestCasePutMissingRequired(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPut, "/test-cases/TestCaseService", reader) - request.Header.Set("testCasePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -251,7 +252,7 @@ func TestInvalidUrlTestCasePut(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPut, "/test-cases/xxxxxxxxxxxzzx", reader) - request.Header.Set("testCasePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -272,7 +273,7 @@ func TestNoUrlTestCasePut(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPut, "", reader) - request.Header.Set("testCasePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -293,7 +294,7 @@ func TestCasePutWithNoPathSlash(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPut, "/test-cases/TestCaseService", reader) - request.Header.Set("testCasePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -314,7 +315,7 @@ func TestNoPathTestCasePut(t *testing.T) { filePath := "" request, err := http.NewRequest(http.MethodPut, "/test-cases/TestCaseService", reader) - request.Header.Set("testCasePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -335,7 +336,7 @@ func TestNoNameTestCasePut(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPut, "/test-cases/TestCaseService", reader) - request.Header.Set("testCasePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -351,19 +352,15 @@ func TestSuccessfulGetAllCases(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) - DirectoryPath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" + directoryPath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodGet, "/test-cases", nil) + assert.NoError(t, err) - request.Header.Set("testSuitePathDir", DirectoryPath) - request.Header.Get("testSuitePathDir") + request.Header.Set("path", directoryPath) w := httptest.NewRecorder() r.ServeHTTP(w, request) - if err != nil { - t.Error(err) - } - assert.Equal(t, http.StatusOK, w.Code, "Did not get all test casess") } @@ -371,11 +368,9 @@ func TestGetAllCasesNoHeader(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) - DircetoryPath := "" request, err := http.NewRequest(http.MethodGet, "/test-cases", nil) - request.Header.Set("testSuitePathDir", DircetoryPath) - request.Header.Get("testSuitePathDir") + request.Header.Set("path", "") w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -394,8 +389,8 @@ func TestGetTestCaseNoHeader(t *testing.T) { filePath := "" request, err := http.NewRequest(http.MethodGet, "/test-cases/Case1", nil) - request.Header.Set("testCasePathDir", filePath) - request.Header.Get("testCasePathDir") + request.Header.Set("path", filePath) + request.Header.Get("path") w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -404,7 +399,7 @@ func TestGetTestCaseNoHeader(t *testing.T) { t.Error(err) } - assert.Equal(t,http.StatusBadRequest, w.Code, "Should not return data") + assert.Equal(t, http.StatusBadRequest, w.Code, "Should not return data") } func TestGetTestCaseFileNotFound(t *testing.T) { @@ -414,8 +409,8 @@ func TestGetTestCaseFileNotFound(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/cases" request, err := http.NewRequest(http.MethodGet, "/test-cases/xxx", nil) - request.Header.Set("testCasePathDir", filePath) - request.Header.Get("testCasePathDir") + request.Header.Set("path", filePath) + request.Header.Get("path") w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -431,17 +426,16 @@ func TestDeleteAllCasesSuccess(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) - DirectoryPath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/cases" - err := ioutil.WriteFile(fmt.Sprintf("%s%s.xml", DirectoryPath, "test"), nil, 0666) + directory := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/cases" + err := ioutil.WriteFile(fmt.Sprintf("%s%s.xml", directory, "test"), nil, 0666) if err != nil { logrus.Errorf("Error trying to create a file: %s", err) } - request, err := http.NewRequest(http.MethodDelete, "/test-cases/all", nil) - if err != nil { - logrus.Warnf("Error creating the request %s", err) - } - request.Header.Set("testCasePathDir", DirectoryPath) + request, err := http.NewRequest(http.MethodDelete, "/test-cases", nil) + assert.NoError(t, err) + + request.Header.Set("path", directory) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -455,12 +449,12 @@ func TestDeleteAllCasesNoHeader(t *testing.T) { r.Mount("/", GetIndexPage()) DirectoryPath := "" - request, err := http.NewRequest(http.MethodDelete, "/test-cases/all", nil) + request, err := http.NewRequest(http.MethodDelete, "/test-cases", nil) if err != nil { logrus.Warnf("Error creating the request %s", err) } - request.Header.Set("testCasePathDir", DirectoryPath) + request.Header.Set("path", DirectoryPath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -478,7 +472,7 @@ func TestDeleteAllCasesEmptyDirectory(t *testing.T) { logrus.Warnf("Error creating the request %s", err) } - request.Header.Set("testCasePathDir", DirectoryPath) + request.Header.Set("path", DirectoryPath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -490,12 +484,13 @@ func TestSuccessfulCaseDelete(t *testing.T) { r := chi.NewRouter() r.Mount("/", GetIndexPage()) - reader := strings.NewReader(TestCaseForDeletion) + reader := strings.NewReader(testCaseForDeletion) r.HandleFunc("/test-cases", postTestCase) filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPost, "/test-cases", reader) - request.Header.Set("testCasePathDir", filePath) + assert.NoError(t, err) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -504,19 +499,16 @@ func TestSuccessfulCaseDelete(t *testing.T) { assert.Equal(t, http.StatusCreated, w.Code, "Error: Did Not Successfully Post") + r.HandleFunc("/test-cases", deleteTestCase) + filePath = os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err = http.NewRequest(http.MethodDelete, "/test-cases/TestCaseService2", nil) - - request.Header.Set("testCasePathDir", filePath) - request.Header.Get("testCasePathDir") + assert.NoError(t, err) + request.Header.Set("path", filePath) w = httptest.NewRecorder() r.ServeHTTP(w, request) - if err != nil { - t.Error(err) - } - assert.Equal(t, http.StatusNoContent, w.Code, "Error. Did not successfully Delete") } @@ -527,8 +519,8 @@ func TestDeleteCaseFileNotFound(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodDelete, "/test-cases/xxx", nil) - request.Header.Set("testCasePathDir", filePath) - request.Header.Get("testCasePathDir") + request.Header.Set("path", filePath) + request.Header.Get("path") w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -547,8 +539,8 @@ func TestDeleteCaseWithNoHeader(t *testing.T) { filePath := "" request, err := http.NewRequest(http.MethodDelete, "/test-cases/TestCaseService", nil) - request.Header.Set("testCasePathDir", filePath) - request.Header.Get("testCasePathDir") + request.Header.Set("path", filePath) + request.Header.Get("path") w := httptest.NewRecorder() r.ServeHTTP(w, request) diff --git a/uiServices/src/testSuiteServices.go b/uiServices/src/testSuiteServices.go index a8aadbc..75f09d9 100644 --- a/uiServices/src/testSuiteServices.go +++ b/uiServices/src/testSuiteServices.go @@ -10,43 +10,34 @@ import ( "net/http" "os" "path/filepath" - "strings" "github.com/Sirupsen/logrus" "github.com/go-chi/chi" - "github.com/xeipuuv/gojsonschema" "github.com/xtracdev/automated-perf-test/testStrategies" ) -var schemaFile string = "testSuite_schema.json" -var structType string = "TestSuite" +const ( + schemaFile = "testSuite_schema.json" + structType = "testSuite" +) type Suite struct { - File string `json:"file"` - Name string `json:"name"` - Description string `json:"description"` - TestStrategy string `json:"testStrategy"` - TestCases []testStrategies.TestCase `json:"testCases"` + File string `json:"file"` + Name string `json:"name"` + Description string `json:"description"` + TestStrategy string `json:"testStrategy"` + TestCases []testStrategies.TestCase `json:"testCases"` } func TestSuiteCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { next.ServeHTTP(w, r) }) - -} -func getTestSuiteHeader(req *http.Request) string { - testSuitePathDir := req.Header.Get("testSuitePathDir") - - if !strings.HasSuffix(testSuitePathDir, "/") { - testSuitePathDir = testSuitePathDir + "/" - } - return testSuitePathDir } func postTestSuites(rw http.ResponseWriter, req *http.Request) { rw.Header().Set("Access-Control-Allow-Origin", "*") - testSuitePathDir := getTestSuiteHeader(req) + testSuitePathDir := getPathHeader(req) buf := new(bytes.Buffer) buf.ReadFrom(req.Body) @@ -68,7 +59,7 @@ func postTestSuites(rw http.ResponseWriter, req *http.Request) { return } - if !ValidateJSONWithSchema(buf.Bytes(), schemaFile, structType) { + if !validateJSONWithSchema(buf.Bytes(), schemaFile, structType) { rw.WriteHeader(http.StatusBadRequest) return } @@ -95,31 +86,9 @@ func postTestSuites(rw http.ResponseWriter, req *http.Request) { rw.WriteHeader(http.StatusCreated) } -func ValidateJsonWithSchema(testSuite []byte, schemaName, structType string) bool { - goPath := os.Getenv("GOPATH") - schemaLoader := gojsonschema.NewReferenceLoader("file:///" + goPath + "/src/github.com/xtracdev/automated-perf-test/ui-src/src/assets/" + schemaName) - documentLoader := gojsonschema.NewBytesLoader(testSuite) - logrus.Info(schemaLoader) - result, error := gojsonschema.Validate(schemaLoader, documentLoader) - - if error != nil { - return false - } - if !result.Valid() { - logrus.Errorf("%sdocument is not valid. see errors :", structType) - for _, desc := range result.Errors() { - logrus.Error("- ", desc) - return false - } - } - - logrus.Infof("%s document is valid", structType) - return true -} - func putTestSuites(rw http.ResponseWriter, req *http.Request) { rw.Header().Set("Access-Control-Allow-Origin", "*") - path := getTestSuiteHeader(req) + path := getPathHeader(req) testSuiteName := chi.URLParam(req, "testSuiteName") if err := IsHeaderValid(path); err != nil { @@ -143,7 +112,7 @@ func putTestSuites(rw http.ResponseWriter, req *http.Request) { } - if !ValidateJsonWithSchema(buf.Bytes(), schemaFile, structType) { + if !validateJSONWithSchema(buf.Bytes(), schemaFile, structType) { rw.WriteHeader(http.StatusBadRequest) return } @@ -166,7 +135,7 @@ func putTestSuites(rw http.ResponseWriter, req *http.Request) { } func deleteTestSuite(rw http.ResponseWriter, req *http.Request) { - testSuitePathDir := getTestSuiteHeader(req) + testSuitePathDir := getPathHeader(req) testSuiteName := chi.URLParam(req, "testSuiteName") if err := IsHeaderValid(testSuitePathDir); err != nil { @@ -179,7 +148,9 @@ func deleteTestSuite(rw http.ResponseWriter, req *http.Request) { return } - if _, err := os.Stat(fmt.Sprintf("%s%s.xml", testSuitePathDir, testSuiteName)); err != nil { + filepath := fmt.Sprintf("%s%s.xml", testSuitePathDir, testSuiteName) + + if _, err := os.Stat(filepath); err != nil { if os.IsNotExist(err) { logrus.Error("Test Suite File Not Found: ", err) rw.WriteHeader(http.StatusNotFound) @@ -199,7 +170,7 @@ func deleteTestSuite(rw http.ResponseWriter, req *http.Request) { func getTestSuite(rw http.ResponseWriter, req *http.Request) { rw.Header().Set("Access-Control-Allow-Origin", "*") - testSuitePathDir := getTestSuiteHeader(req) + testSuitePathDir := getPathHeader(req) testSuiteName := chi.URLParam(req, "testSuiteName") if err := IsHeaderValid(testSuitePathDir); err != nil { @@ -232,14 +203,14 @@ func getTestSuite(rw http.ResponseWriter, req *http.Request) { err = xml.Unmarshal(byteValue, &testSuite) if err != nil { rw.WriteHeader(http.StatusInternalServerError) - logrus.Error("Cannot Unmarshall from XML") + logrus.Error("Cannot Unmarshall from XML", err) return } testSuiteJSON, err := json.MarshalIndent(testSuite, "", "") if err != nil { rw.WriteHeader(http.StatusInternalServerError) - logrus.Error("Cannot marshall to JSON") + logrus.Error("Cannot marshall to JSON", err) return } @@ -250,7 +221,7 @@ func getTestSuite(rw http.ResponseWriter, req *http.Request) { func getAllTestSuites(rw http.ResponseWriter, req *http.Request) { rw.Header().Set("Access-Control-Allow-Origin", "*") - testSuitePathDir := getTestSuiteHeader(req) + testSuitePathDir := getPathHeader(req) if len(testSuitePathDir) <= 1 { logrus.Error("No file directory entered") rw.WriteHeader(http.StatusBadRequest) @@ -290,11 +261,11 @@ func getAllTestSuites(rw http.ResponseWriter, req *http.Request) { //if a Test Suite Name can't be assigned, it isn't a Test Suite object if testSuite.Name != "" { testSuites = append(testSuites, Suite{ - Name: testSuite.Name, - Description: testSuite.Description, - File: filename, + Name: testSuite.Name, + Description: testSuite.Description, + File: filename, TestStrategy: testSuite.TestStrategy, - TestCases: testSuite.TestCases, + TestCases: testSuite.TestCases, }) } } diff --git a/uiServices/src/testSuiteServices_test.go b/uiServices/src/testSuiteServices_test.go index ef5ede4..9b8b27f 100644 --- a/uiServices/src/testSuiteServices_test.go +++ b/uiServices/src/testSuiteServices_test.go @@ -92,7 +92,7 @@ func TestValidTestSuitePost(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPost, "/test-suites", reader) - request.Header.Set("testSuitePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -113,7 +113,7 @@ func TestFileExistsPost(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPost, "/test-suites", reader) - request.Header.Set("testSuitePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -134,7 +134,7 @@ func TestMissingRequiredTestSuitePost(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPost, "/test-suites", reader) - request.Header.Set("testSuitePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -156,7 +156,7 @@ func TestIncorrectDataTypePost(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPost, "/test-suites", reader) - request.Header.Set("testSuitePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -178,7 +178,7 @@ func TestValidTestSuitePostNoConfigPathDir(t *testing.T) { filePath := "" request, err := http.NewRequest(http.MethodPost, "/test-suites", reader) - request.Header.Set("testSuitePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -200,7 +200,7 @@ func TestValidTestSuitePostConfigPathDirNotExist(t *testing.T) { filePath := "C:/a/b/c/d/////" request, err := http.NewRequest(http.MethodPost, "/test-suites", reader) - request.Header.Set("testSuitePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -222,7 +222,7 @@ func TestValidTestSuitePut(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPut, "/test-suites/TestSuiteService", reader) - request.Header.Set("testSuitePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -243,7 +243,7 @@ func TestTestSuiteMissingFieldPut(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPut, "/test-suites/TestSuiteService", reader) - request.Header.Set("testSuitePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -264,7 +264,7 @@ func TestInvalidTestSuitePut(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPut, "/test-suites/TestSuiteService", reader) - request.Header.Set("testSuitePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -285,7 +285,7 @@ func TestInvalidUrlTestSuitePut(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPut, "/test-suites/xxx", reader) - request.Header.Set("testSuitePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -306,7 +306,7 @@ func TestNoUrlTestSuitePut(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodPut, "", reader) - request.Header.Set("testSuitePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -327,7 +327,7 @@ func TestPutWithNoPathSlash(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPut, "/test-suites/TestSuiteService", reader) - request.Header.Set("testSuitePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -348,7 +348,7 @@ func TestNoPathTestSuitePut(t *testing.T) { filePath := "" request, err := http.NewRequest(http.MethodPut, "/test-suites/TestSuiteService", reader) - request.Header.Set("testSuitePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -369,7 +369,7 @@ func TestNoFileNameTestSuitePut(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" request, err := http.NewRequest(http.MethodPut, "/test-suites", reader) - request.Header.Set("testSuitePathDir", filePath) + request.Header.Set("path", filePath) w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -388,8 +388,8 @@ func TestSuccessfulGetTestSuite(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodGet, "/test-suites/TestSuiteService", nil) - request.Header.Set("testSuitePathDir", filePath) - request.Header.Get("testSuitePathDir") + request.Header.Set("path", filePath) + request.Header.Get("path") w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -398,7 +398,7 @@ func TestSuccessfulGetTestSuite(t *testing.T) { t.Error(err) } - assert.Equal(t,http.StatusOK, w.Code, "Error. Did not successfully GET") + assert.Equal(t, http.StatusOK, w.Code, "Error. Did not successfully GET") } func TestGetTestSuiteNoPath(t *testing.T) { @@ -408,8 +408,8 @@ func TestGetTestSuiteNoPath(t *testing.T) { filePath := "" request, err := http.NewRequest(http.MethodGet, "/test-suites/TestSuiteService.xml", nil) - request.Header.Set("testSuitePathDir", filePath) - request.Header.Get("testSuitePathDir") + request.Header.Set("path", filePath) + request.Header.Get("path") w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -418,7 +418,7 @@ func TestGetTestSuiteNoPath(t *testing.T) { t.Error(err) } - assert.Equal(t, http.StatusBadRequest, w.Code, "Retrived file but should not have as there is no path") + assert.Equal(t, http.StatusBadRequest, w.Code, "Retrived file but should not have as there is no path") } func TestGetTestSuiteFileNotFound(t *testing.T) { @@ -428,8 +428,8 @@ func TestGetTestSuiteFileNotFound(t *testing.T) { filePath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodGet, "/test-suites/xxx", nil) - request.Header.Set("testSuitePathDir", filePath) - request.Header.Get("testSuitePathDir") + request.Header.Set("path", filePath) + request.Header.Get("path") w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -448,8 +448,8 @@ func TestSuccessfulGetAllSuites(t *testing.T) { DirectoryPath := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" request, err := http.NewRequest(http.MethodGet, "/test-suites", nil) - request.Header.Set("testSuitePathDir", DirectoryPath) - request.Header.Get("testSuitePathDir") + request.Header.Set("path", DirectoryPath) + request.Header.Get("path") w := httptest.NewRecorder() r.ServeHTTP(w, request) @@ -468,8 +468,8 @@ func TestGetAllSuitesNoHeader(t *testing.T) { DircetoryPath := "" request, err := http.NewRequest(http.MethodGet, "/test-suites", nil) - request.Header.Set("testSuitePathDir", DircetoryPath) - request.Header.Get("testSuitePathDir") + request.Header.Set("path", DircetoryPath) + request.Header.Get("path") w := httptest.NewRecorder() r.ServeHTTP(w, request) diff --git a/uiServices/src/util.go b/uiServices/src/util.go new file mode 100644 index 0000000..4961bcf --- /dev/null +++ b/uiServices/src/util.go @@ -0,0 +1,45 @@ +package services + +import ( + "net/http" + "os" + "strings" + + "github.com/Sirupsen/logrus" + "github.com/xeipuuv/gojsonschema" +) + +func getPathHeader(req *http.Request) string { + pathHeader := req.Header.Get("path") + + if !strings.HasSuffix(pathHeader, "/") { + pathHeader = pathHeader + "/" + } + return pathHeader +} + +func validateJSONWithSchema(testSuite []byte, schemaName, structType string) bool { + goPath := os.Getenv("GOPATH") + schemaLoader := gojsonschema.NewReferenceLoader("file:///" + goPath + "/src/github.com/xtracdev/automated-perf-test/ui-src/src/assets/" + schemaName) + documentLoader := gojsonschema.NewBytesLoader(testSuite) + logrus.Info(schemaLoader) + result, error := gojsonschema.Validate(schemaLoader, documentLoader) + + if error != nil { + return false + } + if !result.Valid() { + logrus.Errorf("%sdocument is not valid. see errors :", structType) + for _, desc := range result.Errors() { + logrus.Error("- ", desc) + return false + } + } + + logrus.Infof("%s document is valid", structType) + return true +} +func FilePathExist(path string) bool { + _, err := os.Stat(path) + return !os.IsNotExist(err) +} diff --git a/uiServices/src/util_test.go b/uiServices/src/util_test.go new file mode 100644 index 0000000..21ffdd0 --- /dev/null +++ b/uiServices/src/util_test.go @@ -0,0 +1,25 @@ +package services + +import ( + "fmt" + "os" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestFilePathExist(t *testing.T) { + path := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" + actual := false + fmt.Println(path) + actual = FilePathExist(path) + expected := true + assert.Equal(t, expected, actual) +} + +func TestFilePathDoesNotExist(t *testing.T) { + path := "(((((((" + actual := FilePathExist(path) + expected := false + assert.Equal(t, expected, actual) +} diff --git a/uiServices/src/xmlWriter.go b/uiServices/src/xmlWriter.go index 7274019..8ccf74f 100644 --- a/uiServices/src/xmlWriter.go +++ b/uiServices/src/xmlWriter.go @@ -11,8 +11,30 @@ import ( "github.com/xtracdev/automated-perf-test/testStrategies" ) -func configWriterXml(config perfTestUtils.Config, configPathDir string) bool { - filename := fmt.Sprintf("%s", configPathDir) +func writeXml(definition interface{}, path string) bool { + filename := fmt.Sprintf("%s", path) + + configAsXml, err := xml.MarshalIndent(definition, " ", " ") + if err != nil { + log.Error("Failed to marshal to XML. Error:", err) + return false + } + + file, err := os.Create(filename) + + if err != nil { + log.Error("Failed to create output file. Error:", err) + return false + } + if file != nil { + defer file.Close() + file.Write(configAsXml) + } + return true +} + +func configWriterXml(config perfTestUtils.Config, path string) bool { + filename := fmt.Sprintf("%s", path) configAsXml, err := xml.MarshalIndent(config, " ", " ") if err != nil { @@ -33,8 +55,8 @@ func configWriterXml(config perfTestUtils.Config, configPathDir string) bool { return true } -func testSuiteWriterXml(testSuite testStrategies.TestSuite, configPathDir string) bool { - filename := fmt.Sprintf("%s", configPathDir) +func testSuiteWriterXml(testSuite testStrategies.TestSuite, path string) bool { + filename := fmt.Sprintf("%s", path) testSuiteAsXml, err := xml.MarshalIndent(testSuite, " ", " ") if err != nil { @@ -53,3 +75,24 @@ func testSuiteWriterXml(testSuite testStrategies.TestSuite, configPathDir string } return true } + +func testCaseWriterXml(testCase testStrategies.TestDefinition, path string) bool { + filename := fmt.Sprintf("%s", path) + + testCaseAsXml, err := xml.MarshalIndent(testCase, " ", " ") + if err != nil { + log.Error("Failed to marshal to XML. Error:", err) + return false + } + + file, err := os.Create(filename) + if err != nil { + log.Error("Failed to create output file. Error:", err) + return false + } + if file != nil { + defer file.Close() + file.Write(testCaseAsXml) + } + return true +} diff --git a/uiServices/test/GodogConfig.xml b/uiServices/test/GodogConfig.xml deleted file mode 100644 index 0cdd26b..0000000 --- a/uiServices/test/GodogConfig.xml +++ /dev/null @@ -1,19 +0,0 @@ - - GodogAPI - localhost - 1001 - 4000 - 50 - 50 - ./definitions/testCases - ./definitions/testSuites - ./envStats - ./report - 50 - Default-3 - /alt/debug/vars - 1000 - 10 - 10 - 10 - \ No newline at end of file diff --git a/uiServices/test/GodogTestCase.xml b/uiServices/test/GodogTestCase.xml index c70ab2d..e69de29 100644 --- a/uiServices/test/GodogTestCase.xml +++ b/uiServices/test/GodogTestCase.xml @@ -1,29 +0,0 @@ - - GodogTestCase - host - 1001 - POST - desc - path/to/URI - false - payload - - - F-Name - PayloadName - file-name - - - - 200 - JSON - -
Header-Value
-
- - Res-Value - - 1000 - 2000 - Sparse -
\ No newline at end of file diff --git a/uiServices/test/GodogTestCase2.xml b/uiServices/test/GodogTestCase2.xml index b7a8604..d1b86d8 100644 --- a/uiServices/test/GodogTestCase2.xml +++ b/uiServices/test/GodogTestCase2.xml @@ -23,7 +23,7 @@ Res-Value - 1000 - 2000 - Sparse + 1000 + 2000 + Sparse \ No newline at end of file diff --git a/uiServices/test/GodogTestSuite.xml b/uiServices/test/GodogTestSuite.xml deleted file mode 100644 index 816379d..0000000 --- a/uiServices/test/GodogTestSuite.xml +++ /dev/null @@ -1,8 +0,0 @@ - - GodogTestSuite2 - ServiceDesc - SuiteBased - - file1 - - \ No newline at end of file diff --git a/uiServices/test/ServiceTestConfig.xml b/uiServices/test/ServiceTestConfig.xml deleted file mode 100644 index b8211ad..0000000 --- a/uiServices/test/ServiceTestConfig.xml +++ /dev/null @@ -1,19 +0,0 @@ - - ServiceTestConfig - localhost - 9191 - 1000 - 30 - 30 - ./definitions/testCases - ./definitions/testSuites - ./envStats - ./report - 50 - Default-1 - /alt/debug/vars - 5000 - 30 - 5 - 15 - \ No newline at end of file diff --git a/uiServices/test/TestCaseService.xml b/uiServices/test/TestCaseService.xml deleted file mode 100644 index 2b6ce3a..0000000 --- a/uiServices/test/TestCaseService.xml +++ /dev/null @@ -1,29 +0,0 @@ - - TestCaseService - host - 9191 - GET - desc - path/to/URI - false - payload - - - F-Name - PayloadName - file-name - - - - 200 - JSON - -
Header-Value
-
- - Res-Value - - 1000 - 2000 - Sparse -
\ No newline at end of file diff --git a/uiServices/test/TestSuiteService.xml b/uiServices/test/TestSuiteService.xml deleted file mode 100644 index f6e6e90..0000000 --- a/uiServices/test/TestSuiteService.xml +++ /dev/null @@ -1,9 +0,0 @@ - - TestSuiteService - Services for XYZ - SuiteBased - - file1 - file2 - - \ No newline at end of file diff --git a/uiServices/test/configFile.feature b/uiServices/test/configFile.feature index 2787caa..5141d61 100644 --- a/uiServices/test/configFile.feature +++ b/uiServices/test/configFile.feature @@ -11,7 +11,7 @@ Feature: Create Configuration File Scenario: Successful creation of config file Given there is no existing test file "GodogConfig.xml" Given the automated performance ui server is available - And the header "configPathDir" is "/uiServices/test/GodogConfig.xml" + And the header "path" is "/uiServices/test/GodogConfig.xml" When I send "POST" request to "/configs" with a body: """ { @@ -36,11 +36,11 @@ Feature: Create Configuration File """ Then the response code should be 201 And the response body should be empty - And the config file was created at location defined by configsPathDir -# + And the config file was created at location defined by path + Scenario: Unsuccessful creation of config file (file already exists) Given the automated performance ui server is available - And the header "configPathDir" is "/uiServices/test/GodogConfig.xml" + And the header "path" is "/uiServices/test/GodogConfig.xml" When I send "POST" request to "/configs" with a body: """ { @@ -89,13 +89,13 @@ Feature: Create Configuration File "rampDelay": 15 } """ - And the header "configPathDir" is "/uiServices/test/GodogConfig.xml" + And the header "path" is "/uiServices/test/GodogConfig.xml" Then the response code should be 400 Scenario: Unsuccessful creation of config file (Missing Header) Given the automated performance ui server is available - And the header "configPathDir" is "" + And the header "path" is "" When I send "POST" request to "/configs" with a body: """ { @@ -129,7 +129,7 @@ Feature: Create Configuration File Scenario: Try to retrieve config file with valid "GET" request Given the file "GodogConfig.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "configPathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" And the file name is "GodogConfig.xml" When I send a "GET" request to "/configs/GodogConfig" Then the response code should be 200 @@ -160,7 +160,7 @@ Feature: Create Configuration File Given the automated performance ui server is available Given the file "GodogConfig.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "configPathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send a "GET" request to "/configs/xxx" Then the response code should be 404 @@ -173,7 +173,7 @@ Feature: Create Configuration File Scenario: Unsuccessful update of config file with PUT request (No File Path) Given the file "GodogConfig.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "configPathDir" is "" + And the header "path" is "" When I send "PUT" request to "/configs/GodogConfig" with body: """ { @@ -201,7 +201,7 @@ Feature: Create Configuration File Scenario: Unsuccessful update of config file with PUT request (Incorrect File Name) Given the file "GodogConfig.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "configPathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "PUT" request to "/configs/xxx" with body: """ { @@ -229,7 +229,7 @@ Feature: Create Configuration File Scenario: Unsuccessful update of config file with PUT request (No File Name) Given the file "GodogConfig.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "configPathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "PUT" request to "/configs/" with body: """ { @@ -257,7 +257,7 @@ Feature: Create Configuration File Scenario: Unsuccessful update of config file with PUT request (Missing Required Fields) Given the file "GodogConfig.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "configPathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "PUT" request to "/configs/GodogConfig" with body: """ { @@ -286,7 +286,7 @@ Feature: Create Configuration File Scenario: Successful update of config file with PUT request Given the file "GodogConfig.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "configPathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "PUT" request to "/configs/GodogConfig" with body: """ { @@ -338,7 +338,7 @@ Feature: Create Configuration File Scenario: Successful update of config file with PUT request (Update API Name to not match Filename) Given the file "GodogConfig.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "configPathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "PUT" request to "/configs/GodogConfig" with body: """ { diff --git a/uiServices/test/godog_test.go b/uiServices/test/godog_test.go index a7f0899..f004839 100644 --- a/uiServices/test/godog_test.go +++ b/uiServices/test/godog_test.go @@ -17,8 +17,8 @@ import ( "github.com/DATA-DOG/godog/gherkin" "github.com/Sirupsen/logrus" "github.com/xtracdev/automated-perf-test/perfTestUtils" - "github.com/xtracdev/automated-perf-test/uiServices/src" "github.com/xtracdev/automated-perf-test/testStrategies" + "github.com/xtracdev/automated-perf-test/uiServices/src" ) type apiFeature struct { @@ -92,7 +92,7 @@ func (a *apiFeature) theTestSuiteCollectionResponseBodyShouldMatchJSON(body *ghe var actualSuite testStrategies.TestSuite exp := - `""" + `""" [ { "file": "GodogTestSuite.xml", @@ -117,7 +117,7 @@ func (a *apiFeature) theTestCaseResponseBodyShouldMatchJSON(body *gherkin.DocStr var actualSuite testStrategies.TestSuite exp := - `""" + `""" """ { "XMLName": { @@ -158,8 +158,8 @@ func (a *apiFeature) theTestCaseCollectionResponseBodyShouldMatchJSON(body *gher var expectedCase testStrategies.TestDefinition var actualCase testStrategies.TestDefinition - exp:= - `""" + exp := + `""" [ { "name": "GodogTestCase, @@ -246,7 +246,7 @@ func makePostRequest(client *http.Client, method, endpoint, body string, headerP if headerPath == "" { req.Header.Set(headerName, "") } else { - req.Header.Set(headerName, fmt.Sprintf("%s/src/github.com/xtracdev/automated-perf-test/uiServices/test/", os.Getenv("GOPATH"))) + req.Header.Set(headerName, fmt.Sprintf("%s/src/github.com/xtracdev/automated-perf-test%s", os.Getenv("GOPATH"), headerPath)) } if err != nil { return nil, err @@ -274,7 +274,7 @@ func FeatureContext(s *godog.Suite) { s.Step(`^the header "([^"]*)" is "([^"]*)"$`, api.theHeaderIs) s.Step(`^the response body should match json:$`, api.theResponseBodyShouldMatchJSON) s.Step(`^the response body should be empty$`, api.theResponseBodyShouldBeEmpty) - s.Step(`^the config file was created at location defined by configsPathDir$`, api.theConfigFileWasCreatedAtLocationDefinedByConfigsPathDir) + s.Step(`^the config file was created at location defined by path`, api.theConfigFileWasCreatedAtLocationDefinedByConfigsPathDir) s.Step(`^the automated performance ui server is available$`, theAutomatedPerformanceUiServerIsAvailable) s.Step(`^I send "([^"]*)" request to "([^"]*)" with a body:$`, api.iSendRequestToWithABody) s.Step(`^the file name is "([^"]*)"$`, api.theFileNameis) @@ -370,6 +370,9 @@ func makeGetRequest(client *http.Client, method, endpoint string, filename strin } func theFileExistsAt(filename, path string) error { + + os.Create(os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test" + path + filename) + _, err := os.Stat(os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test" + path + filename) if err != nil { fmt.Println("Error. File Not Found at location : " + path + filename) @@ -430,18 +433,3 @@ func (a *apiFeature) theUpdatedFileShouldMatchJSON(body *gherkin.DocString) (err return nil } - -func createNewFile(fileName, path string) error { - - _, err := os.Stat(os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test" + path) - if err != nil { - os.Mkdir(os.Getenv("GOPATH")+"/src/github.com/xtracdev/automated-perf-test"+path, 0777) - } - - err = ioutil.WriteFile(fmt.Sprintf("%s%s/%s", suitDir, path, fileName), nil, 0666) - if err != nil { - logrus.Error(" error creating file ", err) - return err - } - return err -} diff --git a/uiServices/test/casestest.xml b/uiServices/test/samples/testCase.json similarity index 100% rename from uiServices/test/casestest.xml rename to uiServices/test/samples/testCase.json diff --git a/uiServices/test/test.xml b/uiServices/test/samples/testCase.xml similarity index 100% rename from uiServices/test/test.xml rename to uiServices/test/samples/testCase.xml diff --git a/uiServices/test/samples/testSuite.json b/uiServices/test/samples/testSuite.json new file mode 100644 index 0000000..e69de29 diff --git a/uiServices/test/samples/testSuite.xml b/uiServices/test/samples/testSuite.xml new file mode 100644 index 0000000..e69de29 diff --git a/uiServices/test/testCase.feature b/uiServices/test/testCase.feature index d6d2948..ba6cc49 100644 --- a/uiServices/test/testCase.feature +++ b/uiServices/test/testCase.feature @@ -11,7 +11,7 @@ Feature: Test Case Scenarios Scenario: Successful creation of Test Case Given there is no existing test file "GodogTestCase.xml" Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "POST" request to "/test-cases" with a body: """ { @@ -20,7 +20,7 @@ Feature: Test Case Scenarios "overrideHost":"host", "overridePort":"9191", "httpMethod":"GET", - "baseURI": "path/to/URI", + "baseUri": "path/to/URI", "multipart":false, "payload": "payload", "responseStatusCode":200, @@ -48,7 +48,7 @@ Feature: Test Case Scenarios Scenario: Unsuccessful creation of Test Case (file already exists ) Given the automated performance ui server is available - And the header "testSuitePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "POST" request to "/test-cases" with a body: """ { @@ -57,7 +57,7 @@ Feature: Test Case Scenarios "overrideHost":"host", "overridePort":"9191", "httpMethod":"GET", - "baseURI": "path/to/URI", + "baseUri": "path/to/URI", "multipart":false, "payload": "payload", "responseStatusCode":200, @@ -85,7 +85,7 @@ Feature: Test Case Scenarios Scenario: Unsuccessful creation of test Case ( Missing Required Fields ) Given the automated performance ui server is available - And the header "testSuitePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "POST" request to "/test-suites" with a body: """ { @@ -94,7 +94,7 @@ Feature: Test Case Scenarios "overrideHost":"host", "overridePort":"9191", "HttpMethod":"GET", - "BaseURI": "path/to/URI", + "baseUri": "path/to/URI", "multipart":false, "payload": "payload", "responseStatusCode":200, @@ -102,11 +102,11 @@ Feature: Test Case Scenarios "preThinkTime": 1000, "postThinkTime":2000, "execWeight": "Sparse", - "Headers":[{ + "headers":[{ "Key": "Authorization", "Value" :"Header-Value" }], - "ResponseValues":[{ + "responseValues":[{ "Value":"Res-Value", "ExtractionKey": "Res-Key" }], @@ -122,7 +122,7 @@ Feature: Test Case Scenarios Scenario: Unsuccessful creation of Test Case ( No header defined ) Given the automated performance ui server is available - And the header "testCasePathDir" is "" + And the header "path" is "" When I send "POST" request to "/test-cases" with a body: """ { @@ -131,7 +131,7 @@ Feature: Test Case Scenarios "overrideHost":"host", "overridePort":"9191", "HttpMethod":"GET", - "BaseURI": "path/to/URI", + "baseUri": "path/to/URI", "multipart":false, "payload": "payload", "responseStatusCode":200, @@ -139,11 +139,11 @@ Feature: Test Case Scenarios "preThinkTime": 1000, "postThinkTime":2000, "execWeight": "Sparse", - "Headers":[{ + "headers":[{ "Key": "Authorization", "Value" :"Header-Value" }], - "ResponseValues":[{ + "responseValues":[{ "Value":"Res-Value", "ExtractionKey": "Res-Key" }], @@ -165,7 +165,7 @@ Feature: Test Case Scenarios Scenario: Unsuccessful update of test-case file with PUT request (No File Path) Given the file "GodogTestCase.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testCasePathDir" is "" + And the header "path" is "" When I send "PUT" request to "/test-suites/GodogTestSuite" with body: """ { @@ -174,7 +174,7 @@ Feature: Test Case Scenarios "overrideHost":"host", "overridePort":"9191", "HttpMethod":"GET", - "BaseURI": "path/to/URI", + "baseUri": "path/to/URI", "multipart":false, "payload": "payload", "responseStatusCode":200, @@ -182,11 +182,11 @@ Feature: Test Case Scenarios "preThinkTime": 1000, "postThinkTime":2000, "execWeight": "Sparse", - "Headers":[{ + "headers":[{ "Key": "Authorization", "Value" :"Header-Value" }], - "ResponseValues":[{ + "responseValues":[{ "Value":"Res-Value", "ExtractionKey": "Res-Key" }], @@ -204,7 +204,7 @@ Feature: Test Case Scenarios Scenario: Unsuccessful update of test-case file with PUT request (Incorrect File Name) Given the file "GodogTestCase.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "PUT" request to "/test-cases/xxx" with body: """ { @@ -213,7 +213,7 @@ Feature: Test Case Scenarios "overrideHost":"host", "overridePort":"9191", "HttpMethod":"GET", - "BaseURI": "path/to/URI", + "baseUri": "path/to/URI", "multipart":false, "payload": "payload", "responseStatusCode":200, @@ -221,11 +221,11 @@ Feature: Test Case Scenarios "preThinkTime": 1000, "postThinkTime":2000, "execWeight": "Sparse", - "Headers":[{ + "headers":[{ "Key": "Authorization", "Value" :"Header-Value" }], - "ResponseValues":[{ + "responseValues":[{ "Value":"Res-Value", "ExtractionKey": "Res-Key" }], @@ -243,7 +243,7 @@ Feature: Test Case Scenarios Scenario: Unsuccessful update of test-case file with PUT request (No File Name) Given the file "GodogTestCase.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "PUT" request to "/test-suites/" with body: """ { @@ -252,7 +252,7 @@ Feature: Test Case Scenarios "overrideHost":"host", "overridePort":"9191", "HttpMethod":"GET", - "BaseURI": "path/to/URI", + "baseUri": "path/to/URI", "multipart":false, "payload": "payload", "responseStatusCode":200, @@ -260,11 +260,11 @@ Feature: Test Case Scenarios "preThinkTime": 1000, "postThinkTime":2000, "execWeight": "Sparse", - "Headers":[{ + "headers":[{ "Key": "Authorization", "Value" :"Header-Value" }], - "ResponseValues":[{ + "responseValues":[{ "Value":"Res-Value", "ExtractionKey": "Res-Key" }], @@ -281,7 +281,7 @@ Feature: Test Case Scenarios Scenario: Unsuccessful update of test-suite file with PUT request (Missing Required Fields) Given the file "GodogTestCase.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "PUT" request to "/test-suites/GodogTestCase" with body: """ { @@ -289,7 +289,7 @@ Feature: Test Case Scenarios "description":"", "overridePort":"", "HttpMethod":"", - "BaseURI": "path/to/URI", + "baseUri": "path/to/URI", "multipart":false, "payload": "payload", "responseStatusCode":200, @@ -297,11 +297,11 @@ Feature: Test Case Scenarios "preThinkTime": 1000, "postThinkTime":2000, "execWeight": "Sparse", - "Headers":[{ + "headers":[{ "Key": "Authorization", "Value" :"Header-Value" }], - "ResponseValues":[{ + "responseValues":[{ "Value":"Res-Value", "ExtractionKey": "Res-Key" }], @@ -319,7 +319,7 @@ Feature: Test Case Scenarios Scenario: Successful update of test-case file with PUT request Given the file "GodogTestCase.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "PUT" request to "/test-cases/GodogTestCase" with body: """ { @@ -328,7 +328,7 @@ Feature: Test Case Scenarios "overrideHost":"host", "overridePort":"1001", "httpMethod":"POST", - "BaseURI": "path/to/URI", + "baseUri": "path/to/URI", "multipart":false, "payload": "payload", "responseStatusCode":200, @@ -336,11 +336,11 @@ Feature: Test Case Scenarios "preThinkTime": 1000, "postThinkTime":2000, "execWeight": "Sparse", - "Headers":[{ + "headers":[{ "Key": "Authorization", "Value" :"Header-Value" }], - "ResponseValues":[{ + "responseValues":[{ "Value":"Res-Value", "ExtractionKey": "Res-Key" }], @@ -363,7 +363,7 @@ Feature: Test Case Scenarios ##Add additional file first so there are multiple files to GET Given there is no existing test file "GodogTestCase2.xml" Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "POST" request to "/test-cases" with a body: """ { @@ -372,7 +372,7 @@ Feature: Test Case Scenarios "overrideHost":"host", "overridePort":"9191", "httpMethod":"PUT", - "baseURI": "path/to/URI", + "baseUri": "path/to/URI", "multipart":false, "payload": "payload", "responseStatusCode":200, @@ -398,7 +398,7 @@ Feature: Test Case Scenarios Then the response code should be 201 And the response body should be empty Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send a "GET" request to "/test-cases" Then the response code should be 200 And the test case collection response body should match json: @@ -420,7 +420,7 @@ Feature: Test Case Scenarios Scenario: Unsuccessful retrieval of test-cases (No Header) Given the automated performance ui server is available - And the header "testSuitePathDir" is "" + And the header "path" is "" When I send a "GET" request to "/test-cases" Then the response code should be 400 @@ -430,44 +430,40 @@ Feature: Test Case Scenarios Scenario: Unsuccessful retrieval of test-Cases file (File Not Found) Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send a "GET" request to "/test-cases/xxx" Then the response code should be 404 Scenario: Unsuccessful retrieval of test-suites file (No Header) Given the automated performance ui server is available - And the header "testCasePathDir" is "" + And the header "path" is "" When I send a "GET" request to "/test-suites/GodogTestCase" Then the response code should be 400 Scenario: Retrieve Test Case file with valid "GET" request - Given the file "Case3.xml" exists at "/uiServices/test/" + Given the file "testCase.xml" exists at "/uiServices/test/samples/" Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/" - And the file name is "Case1.xml" - When I send a "GET" request to "/test-cases/Case1" + And the header "path" is "/uiServices/test/samples/" + And the file name is "testCase.xml" + When I send a "GET" request to "/test-cases/testCase" Then the response code should be 200 And the test case response body should match json: """ { - "XMLName": { - "Space": "", - "Local": "testDefinition" - }, "TestName": GodogTestCase", "OverrideHost": "host", "OverridePort": "9191", "HTTPMethod": "GET", "Description": "desc", - "BaseURI": "", + "baseUri": "", "Multipart": false, "Payload": "", "MultipartPayload": null, "ResponseStatusCode": 0, "ResponseContentType": "", - "Headers": null, - "ResponseValues": null, + "headers": null, + "responseValues": null, "PreThinkTime": 0, "PostThinkTime": 0, "ExecWeight": "" @@ -478,19 +474,19 @@ Feature: Test Case Scenarios ####### DELETE REQUESTS ######## ################################### - + Scenario: Fail to remove Test Case file with "DELETE" request (File Not Found) Given the file "GodogTestCase.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send a "DELETE" request to "/test-cases/xxxx" Then the response code should be 404 Scenario: Fail to remove Test Case file with "DELETE" request (No Header) Given the file "GodogTestCase.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testCasePathDir" is "" + And the header "path" is "" When I send a "DELETE" request to "/test-cases/xxxx" Then the response code should be 400 @@ -498,7 +494,7 @@ Feature: Test Case Scenarios #create file to delete Given there is no existing test file "GodogTestCase3.xml" Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "POST" request to "/test-cases" with a body: """ { @@ -507,7 +503,7 @@ Feature: Test Case Scenarios "overrideHost":"host", "overridePort":"9191", "httpMethod":"GET", - "baseURI": "path/to/URI", + "baseUri": "path/to/URI", "multipart":false, "payload": "payload", "responseStatusCode":200, @@ -534,28 +530,28 @@ Feature: Test Case Scenarios #Delete Given the file "GodogTestCase3.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send a "DELETE" request to "/test-cases/GodogTestCase3" Then the response code should be 204 Scenario: Unsuccessful deleting of test-case (No Header) Given the automated performance ui server is available - And the header "testCasePathDir" is "" - When I send a "DELETE" request to "/test-cases/all" + And the header "path" is "" + When I send a "DELETE" request to "/test-cases" Then the response code should be 400 Scenario: Unsuccessful deleting of test-case file (Empty Directory) Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/cases" + And the header "path" is "/uiServices/test/cases" When I send a "DELETE" request to "/test-cases/" Then the response code should be 404 - + Scenario: Successful deleting of test-case file with DELETE request - Given the "deleteTest.xml" has been created at "/uiServices/test/cases" + Given the file "deleteTest.xml" exists at "/uiServices/test/cases" Given the automated performance ui server is available - And the header "testCasePathDir" is "/uiServices/test/cases" - When I send a "DELETE" request to "/test-cases/all" + And the header "path" is "/uiServices/test/cases" + When I send a "DELETE" request to "/test-cases" Then the response code should be 200 \ No newline at end of file diff --git a/uiServices/test/testSuite.feature b/uiServices/test/testSuite.feature index 36656d2..cd3a4a1 100644 --- a/uiServices/test/testSuite.feature +++ b/uiServices/test/testSuite.feature @@ -10,7 +10,7 @@ Feature: Test Suite Creation Scenario: Successful creation of test Suite Given there is no existing test file "GodogTestSuite.xml" Given the automated performance ui server is available - And the header "testSuitePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "POST" request to "/test-suites" with a body: """ { @@ -32,7 +32,7 @@ Feature: Test Suite Creation Scenario: Unsuccessful creation of test Suite (file already exists ) Given the automated performance ui server is available - And the header "testSuitePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "POST" request to "/test-suites" with a body: """ { @@ -60,7 +60,7 @@ Feature: Test Suite Creation Scenario: Unsuccessful creation of test Suite ( Missing Required Fields ) Given the automated performance ui server is available - And the header "testSuitePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "POST" request to "/test-suites" with a body: """ { @@ -79,7 +79,7 @@ Feature: Test Suite Creation Scenario: Unsuccessful creation of test Suite ( No header defined ) Given the automated performance ui server is available - And the header "testSuitePathDir" is "" + And the header "path" is "" When I send "POST" request to "/test-suites" with a body: """ { @@ -101,7 +101,7 @@ Feature: Test Suite Creation Scenario: Unsuccessful creation of test Suite ( Incorrect URL ) Given the automated performance ui server is available - And the header "testSuitePathDir" is "/uiServices/test/GodogTestSuite.xml" + And the header "path" is "/uiServices/test/GodogTestSuite.xml" When I send "POST" request to "/xxxx" with a body: """ { @@ -122,7 +122,7 @@ Feature: Test Suite Creation Scenario: Unsuccessful creation of test Suite(No Name defined) Given the automated performance ui server is available - And the header "testSuitePathDir" is "/uiServices/test/GodogTestSuite.xml" + And the header "path" is "/uiServices/test/GodogTestSuite.xml" When I send "POST" request to "/test-suites" with a body: """ { @@ -149,7 +149,7 @@ Feature: Test Suite Creation Scenario: Unsuccessful update of test-suite file with PUT request (No File Path) Given the file "GodogTestSuite.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testSuitePathDir" is "" + And the header "path" is "" When I send "PUT" request to "/test-suites/GodogTestSuite" with body: """ { @@ -172,7 +172,7 @@ Feature: Test Suite Creation Scenario: Unsuccessful update of test-suite file with PUT request (Incorrect File Name) Given the file "GodogTestSuite.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testSuitePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "PUT" request to "/test-suites/xxx" with body: """ { @@ -195,7 +195,7 @@ Feature: Test Suite Creation Scenario: Unsuccessful update of test-suite file with PUT request (No File Name) Given the file "GodogTestSuite.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testSuitePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "PUT" request to "/test-suites/" with body: """ { @@ -217,7 +217,7 @@ Feature: Test Suite Creation Scenario: Unsuccessful update of test-suite file with PUT request (Missing Required Fields) Given the file "GodogTestSuite.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testSuitePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "PUT" request to "/test-suites/GodogTestSuite" with body: """ { @@ -237,7 +237,7 @@ Feature: Test Suite Creation Scenario: Successful update of test-suite file with PUT request Given the file "GodogTestSuite.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testSuitePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "PUT" request to "/test-suites/GodogTestSuite" with body: """ { @@ -276,7 +276,7 @@ Feature: Test Suite Creation Scenario: Successful update of test-suite file with PUT request (Update API Name to not match Filename) Given the file "GodogTestSuite.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testSuitePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send "PUT" request to "/test-suites/GodogTestSuite" with body: """ { @@ -322,7 +322,7 @@ Feature: Test Suite Creation Scenario: Try to retrieve test-suite file with valid "GET" request Given the file "GodogTestSuite.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testSuitePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" And the file name is "GodogTestSuite.xml" When I send a "GET" request to "/test-suites/GodogTestSuite" Then the response code should be 200 @@ -357,14 +357,14 @@ Feature: Test Suite Creation Given the automated performance ui server is available Given the file "GodogTestSuite.xml" exists at "/uiServices/test/" Given the automated performance ui server is available - And the header "testSuitePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send a "GET" request to "/test-suites/xxx" Then the response code should be 404 Scenario: Unsuccessful retrieval of test-suites file (No Header) Given the automated performance ui server is available - And the header "testSuitePathDir" is "" + And the header "path" is "" When I send a "GET" request to "/test-suites/GodogTestSuite" Then the response code should be 400 @@ -375,7 +375,7 @@ Feature: Test Suite Creation Scenario: Try to retrieve all test suites with valid "GET" request Given the automated performance ui server is available - And the header "testSuitePathDir" is "/uiServices/test/" + And the header "path" is "/uiServices/test/" When I send a "GET" request to "/test-suites" Then the response code should be 200 And the test suite collection response body should match json: @@ -392,6 +392,6 @@ Feature: Test Suite Creation Scenario: Unsuccessful retrieval of test-suites (No Header) Given the automated performance ui server is available - And the header "testSuitePathDir" is "" + And the header "path" is "" When I send a "GET" request to "/test-suites" Then the response code should be 400 \ No newline at end of file diff --git a/uiServices/test/x.xml b/uiServices/test/x.xml deleted file mode 100644 index d2c91c6..0000000 --- a/uiServices/test/x.xml +++ /dev/null @@ -1,19 +0,0 @@ - - x - localhost - 9191 - 1000 - 30 - 30 - ./definitions/testCases - ./definitions/testSuites - ./envStats - ./report - 50 - Default-1 - /alt/debug/vars - 5000 - 30 - 5 - 15 - \ No newline at end of file From 629a102282f115168981f271f073256d1bc95a83 Mon Sep 17 00:00:00 2001 From: "Smyth, Conor" Date: Mon, 12 Mar 2018 17:21:21 +0000 Subject: [PATCH 76/82] adding more files to exclude from git --- .gitignore | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8d8be00..060419f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,10 @@ main ui/ **/node_modules /.editorconfig -config/ -automated-perf-test.exe +config/*.xml +!config/config.xml +*.iml +.idea +ui/ +automated-perf-test +uiServices/test/*.xml \ No newline at end of file From 8892cf34664a84c924da44bd7644abbf8473cacd Mon Sep 17 00:00:00 2001 From: "Farcas, Camelia" Date: Tue, 13 Mar 2018 09:47:28 +0000 Subject: [PATCH 77/82] XAPTC-63 changes based on feedback --- uiServices/src/configServices.go | 9 +++-- uiServices/src/testCaseServices.go | 56 +++++++++++++++++++----------- 2 files changed, 40 insertions(+), 25 deletions(-) diff --git a/uiServices/src/configServices.go b/uiServices/src/configServices.go index fe6b204..4db27a3 100644 --- a/uiServices/src/configServices.go +++ b/uiServices/src/configServices.go @@ -43,13 +43,12 @@ func IsNameValid(name string) error { return nil } -func IsPathDirValid(name string, rw http.ResponseWriter) bool { +func IsPathDirValid(name string) error { if len(name) <= 1 { - logrus.Error("No file directory entered") - rw.WriteHeader(http.StatusBadRequest) - return false + logrus.Error("No directory path entered") + return fmt.Errorf("No directory path entered") } - return true + return nil } func ConfigCtx(next http.Handler) http.Handler { diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index 8986c56..7efd299 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -48,23 +48,25 @@ func postTestCase(rw http.ResponseWriter, req *http.Request) { testCase := testStrategies.TestDefinition{} err := json.Unmarshal(buf.Bytes(), &testCase) if err != nil { - logrus.Error("Failed to unmarshall json body") + logrus.Error("Failed to unmarshall json body", err) rw.WriteHeader(http.StatusBadRequest) return } if err := IsHeaderValid(testCasePathDir); err != nil { + logrus.Error("No header path found", err) rw.WriteHeader(http.StatusBadRequest) return } if err := IsNameValid(testCase.TestName); err != nil { + logrus.Error("File name is empty", err) rw.WriteHeader(http.StatusBadRequest) return } if !FilePathExist(testCasePathDir) { - logrus.Error("Directory path does not exist") + logrus.Error("No directory path entered") rw.WriteHeader(http.StatusBadRequest) return @@ -78,6 +80,7 @@ func postTestCase(rw http.ResponseWriter, req *http.Request) { } if !testCaseWriterXml(testCase, testCasePathDir+testCase.TestName+".xml") { + logrus.Error("Error writing to the file") rw.WriteHeader(http.StatusInternalServerError) return } @@ -90,10 +93,12 @@ func putTestCase(rw http.ResponseWriter, req *http.Request) { testCaseName := chi.URLParam(req, "testCaseName") if err := IsHeaderValid(path); err != nil { + logrus.Error("No header path found", err) rw.WriteHeader(http.StatusBadRequest) return } if err := IsNameValid(testCaseName); err != nil { + logrus.Error("File name is empty", err) rw.WriteHeader(http.StatusBadRequest) return } @@ -118,7 +123,7 @@ func putTestCase(rw http.ResponseWriter, req *http.Request) { err := json.Unmarshal(buf.Bytes(), &testCase) if err != nil { - logrus.Error("Cannot Unmarshall Json") + logrus.Error("Error unmarshalling Json", err) rw.WriteHeader(http.StatusBadRequest) return } @@ -130,6 +135,7 @@ func putTestCase(rw http.ResponseWriter, req *http.Request) { } if !testCaseWriterXml(testCase, testCasePathDir) { + logrus.Error("Error writing to the file") rw.WriteHeader(http.StatusInternalServerError) return } @@ -141,13 +147,17 @@ func getAllTestCases(rw http.ResponseWriter, req *http.Request) { testCasePathDir := getTestCaseHeader(req) - if !IsPathDirValid(testCasePathDir, rw) { + if err := IsPathDirValid(testCasePathDir); err != nil { + logrus.Error("Path Directory is not valid", err) + rw.WriteHeader(http.StatusBadRequest) return } files, err := ioutil.ReadDir(testCasePathDir) if err != nil { - logrus.Error(err) + logrus.Error("Error reading the directory ", err) + rw.WriteHeader(http.StatusInternalServerError) + return } testCases := make([]Case, 0) @@ -161,23 +171,22 @@ func getAllTestCases(rw http.ResponseWriter, req *http.Request) { file, err := os.Open(fmt.Sprintf("%s%s", testCasePathDir, filename)) if err != nil { - logrus.Error("Cannot Open File: " + filename) + logrus.Error("Error opening the file: " + filename) continue } byteValue, err := ioutil.ReadAll(file) if err != nil { - logrus.Error("Cannot Read File: " + filename) + logrus.Error("Error reading the file: " + filename) continue } err = xml.Unmarshal(byteValue, testCase) if err != nil { - logrus.Error("Cannot Unmarshall File: " + filename) + logrus.Error("Error unmarshalling the file: " + filename) continue } - //if a Test Case Name can't be assigned, it isn't a Test Case object if testCase.TestName != "" { testCases = append(testCases, Case{ Name: testCase.TestName, @@ -190,7 +199,7 @@ func getAllTestCases(rw http.ResponseWriter, req *http.Request) { err = json.NewEncoder(rw).Encode(testCases) if err != nil { - logrus.Error("Could not enocde Test Cases") + logrus.Error("Error encoding Test Cases", err) rw.WriteHeader(http.StatusInternalServerError) return } @@ -204,11 +213,13 @@ func getTestCase(rw http.ResponseWriter, req *http.Request) { testCaseName := chi.URLParam(req, "testCaseName") if err := IsHeaderValid(testCasePathDir); err != nil { + logrus.Error("No header path found", err) rw.WriteHeader(http.StatusBadRequest) return } if err := IsNameValid(testCaseName); err != nil { + logrus.Error("File name is empty", err) rw.WriteHeader(http.StatusBadRequest) return } @@ -223,7 +234,7 @@ func getTestCase(rw http.ResponseWriter, req *http.Request) { file, err := os.Open(fmt.Sprintf("%s%s.xml", testCasePathDir, testCaseName)) if err != nil { - logrus.Error("Cannot open: " + testCaseName) + logrus.Error("Error opening the file : " + testCaseName) rw.WriteHeader(http.StatusInternalServerError) return } @@ -233,22 +244,22 @@ func getTestCase(rw http.ResponseWriter, req *http.Request) { byteValue, err := ioutil.ReadAll(file) if err != nil { + logrus.Error("Error reading from file", err) rw.WriteHeader(http.StatusInternalServerError) - logrus.Error("Cannot Read File", err) return } err = xml.Unmarshal(byteValue, &testCase) if err != nil { + logrus.Error("Error unmarshalling from XML", err) rw.WriteHeader(http.StatusInternalServerError) - logrus.Error("Cannot Unmarshall from XML", err) return } testSuiteJSON, err := json.MarshalIndent(testCase, "", "") if err != nil { + logrus.Error("Error marshalling to JSON", err) rw.WriteHeader(http.StatusInternalServerError) - logrus.Error("Cannot marshall to JSON", err) return } @@ -262,11 +273,13 @@ func deleteTestCase(rw http.ResponseWriter, req *http.Request) { testCaseName := chi.URLParam(req, "testCaseName") if err := IsHeaderValid(testCasePathDir); err != nil { + logrus.Error("No header path found", err) rw.WriteHeader(http.StatusBadRequest) return } if err := IsNameValid(testCaseName); err != nil { + logrus.Error("File name is empty", err) rw.WriteHeader(http.StatusBadRequest) return } @@ -283,8 +296,8 @@ func deleteTestCase(rw http.ResponseWriter, req *http.Request) { err := os.Remove(filepath) if err != nil { - logrus.Println("File was not deleted", err) - rw.WriteHeader(http.StatusInternalServerError) + logrus.Println("Error deleting the file", err) + rw.WriteHeader(http.StatusNoContent) return } @@ -294,15 +307,18 @@ func deleteTestCase(rw http.ResponseWriter, req *http.Request) { } func deleteAllTestCases(rw http.ResponseWriter, req *http.Request) { testCasePathDir := getTestCaseHeader(req) - logrus.Println("testCasePathDir", testCasePathDir) + if err := IsHeaderValid(testCasePathDir); err != nil { + logrus.Error("No heared path found", err) rw.WriteHeader(http.StatusBadRequest) return } files, err := ioutil.ReadDir(testCasePathDir) if err != nil { - logrus.Error(err) + logrus.Error("Error reading the directory ", err) + rw.WriteHeader(http.StatusInternalServerError) + return } for _, file := range files { @@ -310,8 +326,8 @@ func deleteAllTestCases(rw http.ResponseWriter, req *http.Request) { err := os.Remove(filepath) if err != nil { - logrus.Errorf("Error deleting the files from directory: %s", err) - rw.WriteHeader(http.StatusNotFound) + logrus.Error("Error removing the files from directory", err) + rw.WriteHeader(http.StatusNoContent) return } } From 6520e5897bbc9791aa6596ab6dda80ce4af9216f Mon Sep 17 00:00:00 2001 From: "Smyth, Conor" Date: Wed, 14 Mar 2018 14:53:41 +0000 Subject: [PATCH 78/82] XUI-APTC fixing unit tests --- uiServices/test/godog_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/uiServices/test/godog_test.go b/uiServices/test/godog_test.go index 9be7405..42deb29 100644 --- a/uiServices/test/godog_test.go +++ b/uiServices/test/godog_test.go @@ -10,6 +10,7 @@ import ( "net/http" "net/http/httptest" "os" + "path/filepath" "reflect" "strings" @@ -268,6 +269,31 @@ func FeatureContext(s *godog.Suite) { s.BeforeScenario(func(interface{}) { api.resetResponse() + dirname := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" + + d, err := os.Open(dirname) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + defer d.Close() + + files, err := d.Readdir(-1) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + fmt.Println("Reading " + dirname) + + for _, file := range files { + if file.Mode().IsRegular() { + if filepath.Ext(file.Name()) == ".xml" { + os.Remove("file.Name()") + fmt.Println("Deleted ", file.Name()) + } + } + } }) From 8ee284d0659f57a58014f84457fe5df94e916f23 Mon Sep 17 00:00:00 2001 From: "Smyth, Conor" Date: Wed, 21 Mar 2018 09:48:26 +0000 Subject: [PATCH 79/82] Remove duplication of XML writer --- uiServices/src/configServices.go | 4 +- uiServices/src/configServices_test.go | 2 +- uiServices/src/testCaseServices.go | 4 +- uiServices/src/testSuiteServices.go | 4 +- uiServices/src/xmlWriter.go | 72 ++------------------------- 5 files changed, 10 insertions(+), 76 deletions(-) diff --git a/uiServices/src/configServices.go b/uiServices/src/configServices.go index 1fbc627..2ee1ec4 100644 --- a/uiServices/src/configServices.go +++ b/uiServices/src/configServices.go @@ -95,7 +95,7 @@ func postConfigs(rw http.ResponseWriter, req *http.Request) { } - if !writeXml(config, configPathDir+config.APIName+".xml") { + if !writeXML(config, configPathDir+config.APIName+".xml") { rw.WriteHeader(http.StatusInternalServerError) return @@ -195,7 +195,7 @@ func putConfigs(rw http.ResponseWriter, req *http.Request) { } - if !writeXml(config, configPathDir) { + if !writeXML(config, configPathDir) { rw.WriteHeader(http.StatusInternalServerError) return } diff --git a/uiServices/src/configServices_test.go b/uiServices/src/configServices_test.go index fcb0901..e9fac6a 100644 --- a/uiServices/src/configServices_test.go +++ b/uiServices/src/configServices_test.go @@ -230,7 +230,7 @@ func TestWhenpathEmpty(t *testing.T) { func TestInvalidURL(t *testing.T) { pt := perfTestUtils.Config{} - configWriterXml(pt, "/path/xxx") + writeXML(pt, "/path/xxx") } func TestSuccessfulGet(t *testing.T) { diff --git a/uiServices/src/testCaseServices.go b/uiServices/src/testCaseServices.go index 2c619d5..be977b7 100644 --- a/uiServices/src/testCaseServices.go +++ b/uiServices/src/testCaseServices.go @@ -79,7 +79,7 @@ func postTestCase(rw http.ResponseWriter, req *http.Request) { return } - if !testCaseWriterXml(testCase, testCasePathDir+testCase.TestName+".xml") { + if !writeXML(testCase, testCasePathDir+testCase.TestName+".xml") { logrus.Error("Error writing to the file") rw.WriteHeader(http.StatusInternalServerError) return @@ -137,7 +137,7 @@ func putTestCase(rw http.ResponseWriter, req *http.Request) { return } - if !testCaseWriterXml(testCase, testCasePathDir) { + if !writeXML(testCase, testCasePathDir) { logrus.Error("Error writing to the file") rw.WriteHeader(http.StatusInternalServerError) return diff --git a/uiServices/src/testSuiteServices.go b/uiServices/src/testSuiteServices.go index 427592d..34d2557 100644 --- a/uiServices/src/testSuiteServices.go +++ b/uiServices/src/testSuiteServices.go @@ -78,7 +78,7 @@ func postTestSuites(rw http.ResponseWriter, req *http.Request) { return } - if !testSuiteWriterXml(testSuite, filePath) { + if !writeXML(testSuite, filePath) { rw.WriteHeader(http.StatusInternalServerError) return } @@ -124,7 +124,7 @@ func putTestSuites(rw http.ResponseWriter, req *http.Request) { return } - if !testSuiteWriterXml(testSuite, testSuitePathDir) { + if !writeXML(testSuite, testSuitePathDir) { rw.WriteHeader(http.StatusInternalServerError) return } diff --git a/uiServices/src/xmlWriter.go b/uiServices/src/xmlWriter.go index 8ccf74f..683e6a2 100644 --- a/uiServices/src/xmlWriter.go +++ b/uiServices/src/xmlWriter.go @@ -7,14 +7,12 @@ import ( "os" log "github.com/Sirupsen/logrus" - "github.com/xtracdev/automated-perf-test/perfTestUtils" - "github.com/xtracdev/automated-perf-test/testStrategies" ) -func writeXml(definition interface{}, path string) bool { +func writeXML(definition interface{}, path string) bool { filename := fmt.Sprintf("%s", path) - configAsXml, err := xml.MarshalIndent(definition, " ", " ") + payloadXML, err := xml.MarshalIndent(definition, " ", " ") if err != nil { log.Error("Failed to marshal to XML. Error:", err) return false @@ -28,71 +26,7 @@ func writeXml(definition interface{}, path string) bool { } if file != nil { defer file.Close() - file.Write(configAsXml) - } - return true -} - -func configWriterXml(config perfTestUtils.Config, path string) bool { - filename := fmt.Sprintf("%s", path) - - configAsXml, err := xml.MarshalIndent(config, " ", " ") - if err != nil { - log.Error("Failed to marshal to XML. Error:", err) - return false - } - - file, err := os.Create(filename) - - if err != nil { - log.Error("Failed to create output file. Error:", err) - return false - } - if file != nil { - defer file.Close() - file.Write(configAsXml) - } - return true -} - -func testSuiteWriterXml(testSuite testStrategies.TestSuite, path string) bool { - filename := fmt.Sprintf("%s", path) - - testSuiteAsXml, err := xml.MarshalIndent(testSuite, " ", " ") - if err != nil { - log.Error("Failed to marshal to XML. Error:", err) - return false - } - - file, err := os.Create(filename) - if err != nil { - log.Error("Failed to create output file. Error:", err) - return false - } - if file != nil { - defer file.Close() - file.Write(testSuiteAsXml) - } - return true -} - -func testCaseWriterXml(testCase testStrategies.TestDefinition, path string) bool { - filename := fmt.Sprintf("%s", path) - - testCaseAsXml, err := xml.MarshalIndent(testCase, " ", " ") - if err != nil { - log.Error("Failed to marshal to XML. Error:", err) - return false - } - - file, err := os.Create(filename) - if err != nil { - log.Error("Failed to create output file. Error:", err) - return false - } - if file != nil { - defer file.Close() - file.Write(testCaseAsXml) + file.Write(payloadXML) } return true } From 53b56bf739a53ca1766ee8ec07924a12b026dbd3 Mon Sep 17 00:00:00 2001 From: a586754 Date: Wed, 21 Mar 2018 11:52:43 +0000 Subject: [PATCH 80/82] header path was not being retrieved --- ui-src/src/app/configurations/configuration.service.ts | 6 +++--- ui-src/src/app/test-cases/test-case.service.ts | 8 ++++---- ui-src/src/app/test-suites/test-suite.service.ts | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ui-src/src/app/configurations/configuration.service.ts b/ui-src/src/app/configurations/configuration.service.ts index 3ea0abf..8a54e39 100644 --- a/ui-src/src/app/configurations/configuration.service.ts +++ b/ui-src/src/app/configurations/configuration.service.ts @@ -13,21 +13,21 @@ export class ConfigurationService { } postConfig$(configData, configPath): Observable { - this.headers = this.headers.set("configPathDir", configPath); + this.headers = this.headers.set("path", configPath); return this.http.post(`${environment.API_BASE_URL}configs`, configData, { headers: this.headers }); } getConfig$(configPath, xmlFileName): Observable { - this.headers = this.headers.set("configPathDir", configPath); + this.headers = this.headers.set("path", configPath); return this.http.get(`${environment.API_BASE_URL}configs/${xmlFileName}`, { headers: this.headers }); } putConfig$(configData, configPath, xmlFileName): Observable { - this.headers = this.headers.set("configPathDir", configPath); + this.headers = this.headers.set("path", configPath); return this.http.put( `${environment.API_BASE_URL}configs/${xmlFileName}`, configData, diff --git a/ui-src/src/app/test-cases/test-case.service.ts b/ui-src/src/app/test-cases/test-case.service.ts index d3922e2..53c6b0a 100644 --- a/ui-src/src/app/test-cases/test-case.service.ts +++ b/ui-src/src/app/test-cases/test-case.service.ts @@ -13,28 +13,28 @@ export class TestCaseService { } getTestCases$(testCasePath): Observable { - this.headers = this.headers.set("testSuitePathDir", testCasePath); + this.headers = this.headers.set("path", testCasePath); return this.http.get(`${environment.API_BASE_URL}test-cases`, { headers: this.headers }); } postTestCase$(testCaseData, testCasePath): Observable { - this.headers = this.headers.set("testSuitePathDir", testCasePath); + this.headers = this.headers.set("path", testCasePath); return this.http.post(`${environment.API_BASE_URL}test-cases`, testCaseData, { headers: this.headers }); } getTestCase$(testCasePath, testCaseFileName): Observable { - this.headers = this.headers.set("testSuitePathDir", testCasePath); + this.headers = this.headers.set("path", testCasePath); return this.http.get(`${environment.API_BASE_URL}test-cases/${testCaseFileName}`, { headers: this.headers }); } putTestCase$(testCaseData, testCasePath, testCaseFileName): Observable { - this.headers = this.headers.set("testSuitePathDir", testCasePath); + this.headers = this.headers.set("path", testCasePath); return this.http.put( `${environment.API_BASE_URL}test-cases/${testCaseFileName}`, testCaseData, diff --git a/ui-src/src/app/test-suites/test-suite.service.ts b/ui-src/src/app/test-suites/test-suite.service.ts index 3d1542a..f13803d 100644 --- a/ui-src/src/app/test-suites/test-suite.service.ts +++ b/ui-src/src/app/test-suites/test-suite.service.ts @@ -13,28 +13,28 @@ export class TestSuiteService { } postTestSuite$(testSuiteData, testSuitePath): Observable { - this.headers = this.headers.set("testSuitePathDir", testSuitePath); + this.headers = this.headers.set("path", testSuitePath); return this.http.post(`${environment.API_BASE_URL}test-suites`, testSuiteData, { headers: this.headers }); } getTestSuite$(testSuitePath, testSuiteFileName): Observable { - this.headers = this.headers.set("testSuitePathDir", testSuitePath); + this.headers = this.headers.set("path", testSuitePath); return this.http.get(`${environment.API_BASE_URL}test-suites/${testSuiteFileName}`, { headers: this.headers }); } getTestSuites$(testSuitePath): Observable { - this.headers = this.headers.set("testSuitePathDir", testSuitePath); + this.headers = this.headers.set("path", testSuitePath); return this.http.get(`${environment.API_BASE_URL}test-suites`, { headers: this.headers }); } putTestSuite$(testSuiteData, testSuitePath, testSuiteFileName): Observable { - this.headers = this.headers.set("testSuitePathDir", testSuitePath); + this.headers = this.headers.set("path", testSuitePath); return this.http.put( `${environment.API_BASE_URL}test-suites/${testSuiteFileName}`, testSuiteData, From 8e1c1919c0a1b125e7e321e9b48dd73dfcd71a03 Mon Sep 17 00:00:00 2001 From: "Flynn, Jenny" Date: Wed, 21 Mar 2018 13:51:39 +0000 Subject: [PATCH 81/82] remove test config files restore original config.xml --- config/1.xml | 22 ------------ config/2.xml | 22 ------------ config/Billy.xml | 6 ---- config/TestCase222.xml | 22 ------------ config/TestCaseService.xml | 22 ------------ config/TestSuiteService.xml | 10 ------ config/TestSuiteService22.xml | 13 ------- config/TestSuiteService444.xml | 9 ----- config/ange.xml | 22 ------------ config/config.xml | 66 ++++++++++++++++++++++++---------- config/sdsd.xml | 8 ----- config/trtrtrtt.xml | 8 ----- 12 files changed, 47 insertions(+), 183 deletions(-) delete mode 100644 config/1.xml delete mode 100644 config/2.xml delete mode 100644 config/Billy.xml delete mode 100644 config/TestCase222.xml delete mode 100644 config/TestCaseService.xml delete mode 100644 config/TestSuiteService.xml delete mode 100644 config/TestSuiteService22.xml delete mode 100644 config/TestSuiteService444.xml delete mode 100644 config/ange.xml delete mode 100644 config/sdsd.xml delete mode 100644 config/trtrtrtt.xml diff --git a/config/1.xml b/config/1.xml deleted file mode 100644 index 9f8b5e0..0000000 --- a/config/1.xml +++ /dev/null @@ -1,22 +0,0 @@ - - 1 - 1 - 1 - POST - 1 - 1 - false - 1 - - 1 - 55555 - -
Header-Value
-
- - Res-Value - - 1 - 11 - Sparse -
\ No newline at end of file diff --git a/config/2.xml b/config/2.xml deleted file mode 100644 index 89ae7cf..0000000 --- a/config/2.xml +++ /dev/null @@ -1,22 +0,0 @@ - - 2 - 1 - 1 - GET - 1 - 1 - true - 1 - - 1 - 11 - -
1
-
- - 1 - - 1 - 1 - Sparse -
\ No newline at end of file diff --git a/config/Billy.xml b/config/Billy.xml deleted file mode 100644 index 91b01ce..0000000 --- a/config/Billy.xml +++ /dev/null @@ -1,6 +0,0 @@ - - Billy - Billy - SuiteBased - - \ No newline at end of file diff --git a/config/TestCase222.xml b/config/TestCase222.xml deleted file mode 100644 index 202d801..0000000 --- a/config/TestCase222.xml +++ /dev/null @@ -1,22 +0,0 @@ - - TestCase222ddd - host222 - x222 - POST - desc222 - p22I - false - payload - - 200 - JSONgg - -
Header-Value
-
- - Res-Value - - 0 - 0 - Infrequent -
\ No newline at end of file diff --git a/config/TestCaseService.xml b/config/TestCaseService.xml deleted file mode 100644 index d92e63f..0000000 --- a/config/TestCaseService.xml +++ /dev/null @@ -1,22 +0,0 @@ - - TestCaseService - host - x - GET - desciiii - path/to/URI - false - payload - - 200 - ccccc - -
Header-Value
-
- - Res-Valueeee - - 55 - 0 - Infrequent -
\ No newline at end of file diff --git a/config/TestSuiteService.xml b/config/TestSuiteService.xml deleted file mode 100644 index 79b6376..0000000 --- a/config/TestSuiteService.xml +++ /dev/null @@ -1,10 +0,0 @@ - - TestSuiteService1444 - Services for XYZrrr - SuiteBased - - file1 - file2 - - - \ No newline at end of file diff --git a/config/TestSuiteService22.xml b/config/TestSuiteService22.xml deleted file mode 100644 index 2d50738..0000000 --- a/config/TestSuiteService22.xml +++ /dev/null @@ -1,13 +0,0 @@ - - TestSuiteServiceTest - Services 22 - SuiteBased - - file222 - file2222 - TestCaseService - - - - - \ No newline at end of file diff --git a/config/TestSuiteService444.xml b/config/TestSuiteService444.xml deleted file mode 100644 index 4930069..0000000 --- a/config/TestSuiteService444.xml +++ /dev/null @@ -1,9 +0,0 @@ - - TestSuiteService444 - Services for XYZ - SuiteBased - - file1 - file2 - - \ No newline at end of file diff --git a/config/ange.xml b/config/ange.xml deleted file mode 100644 index 94c4eb7..0000000 --- a/config/ange.xml +++ /dev/null @@ -1,22 +0,0 @@ - - ange - 12 - 32 - GET - 1223423sdasd - 12 - false - 1 - - 1 - 1234 - -
tyr
-
- - rty - - 1 - 1 - Sparse -
\ No newline at end of file diff --git a/config/config.xml b/config/config.xml index 8d0deb6..ceec919 100644 --- a/config/config.xml +++ b/config/config.xml @@ -1,19 +1,47 @@ - - config - localhost - 8080 - 55 - 12 - 15 - ./definitions/testCases - ./definitions/testSuites - ./envStats - .efreefef - 50 - Default-1 - /alt/debug/vars - 5000 - 30 - 15 - 15 - \ No newline at end of file + + + + config + + + localhost + 8080 + + + 15 + 15 + + + 1000 + + + 50 + + + ./definitions/testCases + + ./definitions/testSuites + + + Default-1 + + + ./envStats + ./report + + + /alt/debug/vars + + + 5000 + + + 30 + + + 5 + + + 15 + + \ No newline at end of file diff --git a/config/sdsd.xml b/config/sdsd.xml deleted file mode 100644 index ca01143..0000000 --- a/config/sdsd.xml +++ /dev/null @@ -1,8 +0,0 @@ - - sdsd - sdsds - SuiteBased - - - - \ No newline at end of file diff --git a/config/trtrtrtt.xml b/config/trtrtrtt.xml deleted file mode 100644 index 0448c1b..0000000 --- a/config/trtrtrtt.xml +++ /dev/null @@ -1,8 +0,0 @@ - - trtrtrtt - rtrtrtr - SuiteBased - - - - \ No newline at end of file From b789e7d7de4872f61e52e00c1c64ff109d81e077 Mon Sep 17 00:00:00 2001 From: "Smyth, Conor" Date: Wed, 21 Mar 2018 13:55:28 +0000 Subject: [PATCH 82/82] reducing duplication --- uiServices/test/godog_test.go | 172 +++++++++++++--------------------- 1 file changed, 63 insertions(+), 109 deletions(-) diff --git a/uiServices/test/godog_test.go b/uiServices/test/godog_test.go index 68a84a1..e37469f 100644 --- a/uiServices/test/godog_test.go +++ b/uiServices/test/godog_test.go @@ -38,7 +38,7 @@ func (a *apiFeature) resetResponse() { } func (a *apiFeature) iSendrequestTo(method, endpoint string) (err error) { - response, err := makePostRequest(a.client, method, endpoint, "", "", "") + response, err := makeRequest(a.client, method, endpoint, "", "", "") if err != nil { return err } @@ -218,7 +218,7 @@ func (a *apiFeature) theConfigFileWasCreatedAtLocationDefinedByConfigsPathDir() } logrus.Println("File Exists") - if !IsValidXml(a.requestbody, a.headerPath) { + if !IsValidXML(a.requestbody, a.headerPath) { return fmt.Errorf("File is not a valid XML file") } logrus.Println("File is a valid XML file") @@ -226,7 +226,7 @@ func (a *apiFeature) theConfigFileWasCreatedAtLocationDefinedByConfigsPathDir() } func (a *apiFeature) iSendRequestToWithABody(method, endpoint string, body *gherkin.DocString) error { - response, err := makePostRequest(a.client, method, endpoint, body.Content, a.headerPath, a.headerName) + response, err := makeRequest(a.client, method, endpoint, body.Content, a.headerPath, a.headerName) a.requestbody = body.Content if err != nil { return err @@ -235,98 +235,17 @@ func (a *apiFeature) iSendRequestToWithABody(method, endpoint string, body *gher return nil } -func makePostRequest(client *http.Client, method, endpoint, body string, headerPath string, headerName string) (*http.Response, error) { - - var reqBody io.Reader - if body != "" { - reqBody = strings.NewReader(body) - } - - req, err := http.NewRequest(method, "http://localhost:9191"+endpoint, reqBody) - - if headerPath == "" { - req.Header.Set(headerName, "") - } else { - req.Header.Set(headerName, fmt.Sprintf("%s/src/github.com/xtracdev/automated-perf-test%s", os.Getenv("GOPATH"), headerPath)) - } - if err != nil { - return nil, err - } - - resp, err := client.Do(req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func FeatureContext(s *godog.Suite) { - api := &apiFeature{} - - s.AfterScenario(func(interface{}, error) { - dirname := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" - - d, err := os.Open(dirname) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - defer d.Close() - - files, err := d.Readdir(-1) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - fmt.Println("Reading " + dirname) - - for _, file := range files { - if file.Mode().IsRegular() { - if filepath.Ext(file.Name()) == ".xml" { - os.Remove(file.Name()) - fmt.Println("Deleted ", file.Name()) - } - } - } - }) - - s.BeforeScenario(func(interface{}) { - api.resetResponse() - }) - - s.Step(`^I send "(GET|POST|PUT|DELETE)" request to "([^"]*)"$`, api.iSendrequestTo) - s.Step(`^the response code should be (\d+)$`, api.theResponseCodeShouldBe) - s.Step(`^the header "([^"]*)" is "([^"]*)"$`, api.theHeaderIs) - s.Step(`^the response body should match json:$`, api.theResponseBodyShouldMatchJSON) - s.Step(`^the response body should be empty$`, api.theResponseBodyShouldBeEmpty) - s.Step(`^the config file was created at location defined by path`, api.theConfigFileWasCreatedAtLocationDefinedByConfigsPathDir) - s.Step(`^the automated performance ui server is available$`, theAutomatedPerformanceUiServerIsAvailable) - s.Step(`^I send "([^"]*)" request to "([^"]*)" with a body:$`, api.iSendRequestToWithABody) - s.Step(`^the file name is "([^"]*)"$`, api.theFileNameis) - s.Step(`^I send a "([^"]*)" request to "([^"]*)"$`, api.iSendARequestTo) - s.Step(`^the file "([^"]*)" exists at "([^"]*)"$`, theFileExistsAt) - s.Step(`^I send "([^"]*)" request to "([^"]*)" with body:$`, api.iSendRequestToWithBody) - s.Step(`^the updated file should match json:$`, api.theUpdatedFileShouldMatchJSON) - s.Step(`^there is no existing test file "([^"]*)"$`, api.thereIsNoExistingTestFile) - s.Step(`^the test suite response body should match json:$`, api.theTestSuiteResponseBodyShouldMatchJSON) - s.Step(`^the test suite collection response body should match json:$`, api.theTestSuiteCollectionResponseBodyShouldMatchJSON) - s.Step(`^the test case collection response body should match json:$`, api.theTestSuiteCollectionResponseBodyShouldMatchJSON) - s.Step(`^the test case response body should match json:$`, api.theTestSuiteCollectionResponseBodyShouldMatchJSON) -} - func (a *apiFeature) thereIsNoExistingTestFile(file string) error { os.Remove(os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test/" + file) return nil } -func theAutomatedPerformanceUiServerIsAvailable() error { +func theAutomatedPerformanceUIServerIsAvailable() error { go http.ListenAndServe(":9191", services.GetRouter()) return nil } -func IsValidXml(config string, header string) bool { +func IsValidXML(config string, header string) bool { file, err := os.Open(os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test" + header) if err != nil { fmt.Println(err) @@ -367,7 +286,7 @@ func (a *apiFeature) theFileNameis(filename string) error { } func (a *apiFeature) iSendARequestTo(method, endpoint string) error { - response, err := makeGetRequest(a.client, method, endpoint, a.filename, a.headerPath, a.headerName) + response, err := makeRequest(a.client, method, endpoint, a.filename, a.headerPath, a.headerName) if err != nil { return err } @@ -380,26 +299,6 @@ func (a *apiFeature) iSendARequestTo(method, endpoint string) error { return nil } -func makeGetRequest(client *http.Client, method, endpoint string, filename string, headerPath, headerName string) (*http.Response, error) { - req, err := http.NewRequest(method, "http://localhost:9191"+endpoint, nil) - - if headerPath == "" { - req.Header.Set(headerName, "") - } else { - req.Header.Set(headerName, fmt.Sprintf("%s/src/github.com/xtracdev/automated-perf-test/%s", os.Getenv("GOPATH"), headerPath)) - } - if err != nil { - return nil, err - } - - resp, err := client.Do(req) - if err != nil { - return nil, err - } - - return resp, nil -} - func theFileExistsAt(filename, path string) error { os.Create(os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test" + path + filename) @@ -413,7 +312,7 @@ func theFileExistsAt(filename, path string) error { } func (a *apiFeature) iSendRequestToWithBody(method, endpoint string, body *gherkin.DocString) error { - response, err := makePutRequest(a.client, method, endpoint, body.Content, a.headerPath, a.headerName) + response, err := makeRequest(a.client, method, endpoint, body.Content, a.headerPath, a.headerName) a.requestbody = body.Content if err != nil { return err @@ -422,7 +321,7 @@ func (a *apiFeature) iSendRequestToWithBody(method, endpoint string, body *gherk return nil } -func makePutRequest(client *http.Client, method, endpoint, body string, headerPath, headerName string) (*http.Response, error) { +func makeRequest(client *http.Client, method string, endpoint string, body string, headerPath string, headerName string) (*http.Response, error) { var reqBody io.Reader if body != "" { @@ -465,3 +364,58 @@ func (a *apiFeature) theUpdatedFileShouldMatchJSON(body *gherkin.DocString) (err return nil } + +func FeatureContext(s *godog.Suite) { + api := &apiFeature{} + + s.AfterScenario(func(interface{}, error) { + dirname := os.Getenv("GOPATH") + "/src/github.com/xtracdev/automated-perf-test/uiServices/test" + + d, err := os.Open(dirname) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + defer d.Close() + + files, err := d.Readdir(-1) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + fmt.Println("Reading " + dirname) + + for _, file := range files { + if file.Mode().IsRegular() { + if filepath.Ext(file.Name()) == ".xml" { + os.Remove(file.Name()) + fmt.Println("Deleted ", file.Name()) + } + } + } + }) + + s.BeforeScenario(func(interface{}) { + api.resetResponse() + }) + + s.Step(`^I send "(GET|POST|PUT|DELETE)" request to "([^"]*)"$`, api.iSendrequestTo) + s.Step(`^the response code should be (\d+)$`, api.theResponseCodeShouldBe) + s.Step(`^the header "([^"]*)" is "([^"]*)"$`, api.theHeaderIs) + s.Step(`^the response body should match json:$`, api.theResponseBodyShouldMatchJSON) + s.Step(`^the response body should be empty$`, api.theResponseBodyShouldBeEmpty) + s.Step(`^the config file was created at location defined by path`, api.theConfigFileWasCreatedAtLocationDefinedByConfigsPathDir) + s.Step(`^the automated performance ui server is available$`, theAutomatedPerformanceUIServerIsAvailable) + s.Step(`^I send "([^"]*)" request to "([^"]*)" with a body:$`, api.iSendRequestToWithABody) + s.Step(`^the file name is "([^"]*)"$`, api.theFileNameis) + s.Step(`^I send a "([^"]*)" request to "([^"]*)"$`, api.iSendARequestTo) + s.Step(`^the file "([^"]*)" exists at "([^"]*)"$`, theFileExistsAt) + s.Step(`^I send "([^"]*)" request to "([^"]*)" with body:$`, api.iSendRequestToWithBody) + s.Step(`^the updated file should match json:$`, api.theUpdatedFileShouldMatchJSON) + s.Step(`^there is no existing test file "([^"]*)"$`, api.thereIsNoExistingTestFile) + s.Step(`^the test suite response body should match json:$`, api.theTestSuiteResponseBodyShouldMatchJSON) + s.Step(`^the test suite collection response body should match json:$`, api.theTestSuiteCollectionResponseBodyShouldMatchJSON) + s.Step(`^the test case collection response body should match json:$`, api.theTestSuiteCollectionResponseBodyShouldMatchJSON) + s.Step(`^the test case response body should match json:$`, api.theTestSuiteCollectionResponseBodyShouldMatchJSON) +}