Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 3e62c60

Browse files
committed
Changes to the install; Added prefix to commands c a r
1 parent f90755e commit 3e62c60

File tree

37 files changed

+712
-114
lines changed

37 files changed

+712
-114
lines changed

KITE-Engine/src/main/java/org/webrtc/kite/CallbackThread.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ public CallbackThread(String callbackURL, int callbackPort, String username, Str
6969
/**
7070
* Posts result to the callback URL.
7171
*/
72-
public void postResult() throws IOException {
72+
public void postResult() {
7373
FTPClient ftp = new FTPClient();
7474
boolean error = false;
75+
FileInputStream inputStream = null;
7576
try {
7677
int reply;
7778
ftp.connect(callbackURL, callbackPort);
@@ -84,16 +85,23 @@ public void postResult() throws IOException {
8485
ftp.disconnect();
8586
logger.error("FTP server refused connection.");
8687
}
87-
FileInputStream inputStream = new FileInputStream(file);
88+
inputStream = new FileInputStream(file);
8889
this.uploadComplete = ftp.storeFile(file.getName(), inputStream);
8990
if(this.uploadComplete) {
90-
inputStream.close();
9191
this.file.delete();
9292
}
9393
ftp.logout();
9494
} catch(IOException e) {
95-
e.printStackTrace();
95+
// e.printStackTrace();
96+
logger.error( "Could not upload result zip file: " + e.getMessage());
9697
} finally {
98+
if (inputStream != null) {
99+
try {
100+
inputStream.close();
101+
} catch (Exception e) {
102+
//
103+
}
104+
}
97105
if(ftp.isConnected()) {
98106
try {
99107
ftp.disconnect();
@@ -106,11 +114,7 @@ public void postResult() throws IOException {
106114

107115
@Override
108116
public void run() {
109-
try {
110-
this.postResult();
111-
} catch (IOException e) {
112-
e.printStackTrace();
113-
}
117+
this.postResult();
114118
}
115119

116120
public boolean isUploadComplete() {

KITE-Engine/src/main/java/org/webrtc/kite/Engine.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,18 @@ private static List<String> getJsonFiles (File file) {
223223
}
224224

225225
public static boolean upload(String desFile, String sourcePath, String callbackUrl, int callbackPort, String username, String password) {
226-
String fileName = ReportUtils.zipFile(sourcePath, desFile, true);
227-
File zipToSend = new File(fileName);
228-
if (zipToSend.exists()) {
229-
CallbackThread callbackThread = new CallbackThread(callbackUrl, callbackPort, username, password, zipToSend);
230-
callbackThread.run();
231-
return callbackThread.isUploadComplete();
226+
try{
227+
String fileName = ReportUtils.zipFile(sourcePath, desFile, true);
228+
File zipToSend = new File(fileName);
229+
if (zipToSend.exists()) {
230+
CallbackThread callbackThread = new CallbackThread(callbackUrl, callbackPort, username, password, zipToSend);
231+
callbackThread.run();
232+
return callbackThread.isUploadComplete();
233+
}
234+
} catch (Exception e) {
235+
logger.error("Could not upload the file (" + desFile +") to -> " + callbackUrl);
232236
}
237+
233238
return false;
234239
}
235240

KITE-Engine/src/main/java/org/webrtc/kite/MatrixRunner.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ private void terminate() {
226226
}
227227
testSuite.setStopTimestamp();
228228
if (currentPhase == null || !currentPhase.equals(StepPhase.RAMPUP)) {
229-
testConfig.getReporter().generateReportFiles();
229+
if (testConfig.generateReport()) {
230+
testConfig.getReporter().generateReportFiles();
231+
}
230232
}
231233
}
232234

KITE-Engine/src/main/java/org/webrtc/kite/TestManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private KiteBaseTest buildTest()
145145
test.setTuple(tuple);
146146
test.setCurrentIteration(this.id);
147147
test.setDelayForClosing(testConfig.getDelayForClosing());
148-
148+
test.setGenerateReport(testConfig.generateReport());
149149
test.setPhases(this.phases);
150150

151151
test.setParentSuite(testSuite.getParentSuite());

KITE-Example-Test/configs/search.local.config.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"tests": [
1010
{
1111
"name": "KiteExampleSearchTest %ts",
12-
"tupleSize": 3,
12+
"tupleSize": 1,
1313
"description": "This example test opens google and searches for Cosmo Software Consulting and verify the first result",
1414
"testImpl": "org.webrtc.kite.example.KiteExampleSearchTest",
1515
"payload": {
@@ -22,10 +22,6 @@
2222
{
2323
"browserName": "chrome",
2424
"platform": "localhost"
25-
},
26-
{
27-
"browserName": "firefox",
28-
"platform": "localhost"
2925
}
3026
]
3127
}

KITE-Example-Test/src/main/java/org/webrtc/kite/example/checks/GoogleFirstResultCheck.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
import io.cosmosoftware.kite.steps.TestCheck;
77
import org.webrtc.kite.example.pages.GoogleResultPage;
88

9+
import static io.cosmosoftware.kite.entities.Timeouts.ONE_SECOND_INTERVAL;
910
import static io.cosmosoftware.kite.util.ReportUtils.saveScreenshotPNG;
1011
import static io.cosmosoftware.kite.util.TestUtils.waitAround;
1112

1213
public class GoogleFirstResultCheck extends TestCheck {
13-
private final String EXPECTED_RESULT = "CoSMo Software | WebRTC Technology & Implementation";
14+
private final String EXPECTED_RESULT = "CoSMo Software - Cosmo Software";
1415
private final GoogleResultPage resultPage;
1516

1617
public GoogleFirstResultCheck(Runner runner) {
@@ -20,15 +21,15 @@ public GoogleFirstResultCheck(Runner runner) {
2021

2122
@Override
2223
protected void step() throws KiteTestException {
23-
// resultPage.openFirstResult();
24-
// String found = resultPage.getTitle().trim();
25-
// if (!found.equalsIgnoreCase(EXPECTED_RESULT)) {
26-
// throw new KiteTestException("The title of the first Google result was not correct: \n" +
27-
// "Expected: " + EXPECTED_RESULT + " but found " + found, Status.FAILED);
28-
// }
29-
// reporter.screenshotAttachment(report, saveScreenshotPNG(webDriver));
24+
resultPage.openFirstResult();
25+
String found = resultPage.getTitle().trim();
26+
if (!found.equalsIgnoreCase(EXPECTED_RESULT)) {
27+
throw new KiteTestException("The title of the first Google result was not correct: \n" +
28+
"Expected: " + EXPECTED_RESULT + " but found " + found, Status.FAILED);
29+
}
30+
reporter.screenshotAttachment(report, saveScreenshotPNG(webDriver));
3031
for (int i = 0; i < 10; i++) {
31-
waitAround(1000);
32+
waitAround(ONE_SECOND_INTERVAL);
3233
logger.info("Staying in page: " + i + "s");
3334
webDriver.getTitle();
3435
}

KITE-Example-Test/src/main/java/org/webrtc/kite/example/pages/GoogleSearchPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
public class GoogleSearchPage extends BasePage {
1010

11-
private final static String GOOGLE_PAGE = "https://www.youtube.com/watch?v=DCgfVBoBy9s";
11+
private final static String GOOGLE_PAGE = "https://google.com";
1212

1313
@FindBy(className = "gLFyf")
1414
WebElement searchBar;

KITE-Example-Test/src/main/java/org/webrtc/kite/example/steps/GoogleSearchStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public GoogleSearchStep(Runner runner) {
1818
protected void step() {
1919

2020
searchPage.open();
21-
// searchPage.searchFor(TARGET);
21+
searchPage.searchFor(TARGET);
2222
}
2323

2424
@Override

KITE-Framework/src/main/java/org/webrtc/kite/config/test/TestConfig.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,18 @@ public class TestConfig extends KiteEntity implements JsonBuilder, SampleData {
8888
private NetworkInstrumentation networkInstrumentation = null;
8989
private Boolean done = false;
9090
private EmailSender emailSender = null;
91-
private Boolean csvReport;
92-
91+
private Boolean csvReport = false;
92+
private boolean generateReport = true;
93+
94+
9395
/**
9496
* Instantiates a new test config.
9597
*/
9698
public TestConfig() {
9799
super();
98100
}
99-
101+
102+
100103
/**
101104
* Constructs a new TestConfig with the given callback url and JsonObject.
102105
* <p>
@@ -131,7 +134,8 @@ public TestConfig(JsonObject jsonObject) throws KiteInsufficientValueException,
131134
this.description = jsonObject.getString("description", DEFAULT_DESC);
132135

133136
this.reporter = new Reporter(this.name);
134-
this.csvReport = jsonObject.getBoolean("csvReport", false);
137+
this.csvReport = jsonObject.getBoolean("csvReport", csvReport);
138+
this.generateReport = jsonObject.getBoolean("generateReport", generateReport);
135139
this.payload = jsonObject.getJsonObject("payload").toString();
136140

137141
// Override the global value with the local value
@@ -759,4 +763,13 @@ public Boolean getCsvReport() {
759763
public void setCsvReport(Boolean csvReport) {
760764
this.csvReport = csvReport;
761765
}
766+
767+
768+
public boolean generateReport() {
769+
return generateReport;
770+
}
771+
772+
public void setGenerateReport(boolean generateReport) {
773+
this.generateReport = generateReport;
774+
}
762775
}

KITE-Framework/src/main/java/org/webrtc/kite/stats/GetStatsStep.java

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ public class GetStatsStep extends TestStep {
3333
private final Runner runner;
3434
private String customName = "";
3535
private boolean getRaw = true;
36-
36+
private boolean keepStats = false;
37+
private RTCStatMap statMap;
3738

3839
public GetStatsStep(Runner runner, JsonObject getStatsConfig) {
3940
super(runner);
4041
this.runner = runner;
4142
this.getStatsConfig = getStatsConfig;
43+
this.keepStats = getStatsConfig.getBoolean("keepStats", this.keepStats);
4244
}
4345

4446
@Override
@@ -49,33 +51,43 @@ public String stepDescription() {
4951
@Override
5052
protected void step() throws KiteTestException {
5153
try {
52-
RTCStatMap statsOverTime = getPCStatOvertime(webDriver, getStatsConfig);
53-
statsOverTime.setRegionId(this.runner.getClientRegion());
54-
statsOverTime.setNetworkProfile(this.runner.getNetworkProfile());
55-
RTCStatList localPcStats = statsOverTime.getLocalPcStats();
56-
JsonObject temp = transformToJson(localPcStats);
57-
if (!temp.isEmpty()) {
58-
for (String pc : statsOverTime.keySet()) {
54+
RTCStatMap results = getPCStatOvertime(webDriver, getStatsConfig);
55+
results.setRegionId(this.runner.getClientRegion());
56+
results.setNetworkProfile(this.runner.getNetworkProfile());
57+
if (keepStats) {
58+
this.statMap = results;
59+
}
60+
if (!results.isEmpty()) {
61+
for (String pc : results.keySet()) {
5962
if (getRaw) {
6063
reporter.jsonAttachment(
6164
this.report,
6265
customName + "Stats(Raw)_" + pc.replaceAll("\"", ""),
63-
transformToJson(statsOverTime.get(pc)));
66+
transformToJson(results.get(pc)));
6467
}
65-
reporter.jsonAttachment(this.report, customName + "Stats(Summary)_" + pc.replaceAll("\"", ""), buildStatSummary(statsOverTime.get(pc)));
68+
reporter.jsonAttachment(this.report, customName + "Stats(Summary)_" + pc.replaceAll("\"", ""), buildStatSummary(
69+
results.get(pc)));
6670
}
6771
}
6872
} catch (Exception e) {
69-
logger.error(getStackTrace(e));
70-
throw new KiteTestException("Failed to getStats", Status.BROKEN, e);
73+
throw new KiteTestException("Failed to getStats: " + e.getLocalizedMessage(), Status.BROKEN, e);
7174
}
7275
}
7376

77+
78+
public RTCStatMap getResults() {
79+
return statMap;
80+
}
81+
7482
public void setCustomName(String customName) {
7583
this.customName = customName;
7684
}
7785

7886
public void setGetRaw(boolean getRaw) {
7987
this.getRaw = getRaw;
8088
}
89+
90+
public void setKeepStats(boolean keepStats) {
91+
this.keepStats = keepStats;
92+
}
8193
}

0 commit comments

Comments
 (0)