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

Commit f73aefb

Browse files
committed
Added Tutorials and Example test for auth
1 parent 13515e9 commit f73aefb

File tree

24 files changed

+722
-545
lines changed

24 files changed

+722
-545
lines changed

KITE-AppRTC-Test/src/main/java/org/webrtc/kite/apprtc/checks/BitrateCheck.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import io.cosmosoftware.kite.steps.TestCheck;
2222
import org.openqa.selenium.WebDriver;
2323
import org.webrtc.kite.apprtc.pages.AppRTCMeetingPage;
24+
import org.webrtc.kite.stats.StatsUtils;
2425

2526
import javax.json.Json;
2627
import javax.json.JsonArray;
@@ -59,7 +60,7 @@ protected void step() throws KiteTestException {
5960
.add(stat)
6061
.build();
6162
// Get a stats array of the selected stat for 5 seconds
62-
JsonObject stats = appRTCMeetingPage.getStatOvertime(
63+
JsonObject stats = StatsUtils.getStatOvertime(
6364
webDriver, FIVE_SECOND_INTERVAL, ONE_SECOND_INTERVAL, selectedStat).build();
6465
double avgBitrate = computeBitrate(stats.getJsonArray("statsArray"), stat, mediaType);
6566
System.out.println("avgBitrate lah =>>>>>> " + avgBitrate);

KITE-AppRTC-Test/src/main/java/org/webrtc/kite/apprtc/pages/AppRTCMeetingPage.java

Lines changed: 13 additions & 458 deletions
Large diffs are not rendered by default.

KITE-AppRTC-Test/src/main/java/org/webrtc/kite/apprtc/steps/GetStatsStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected void step() throws KiteTestException {
5454
}
5555
LinkedHashMap<String, String> results = new LinkedHashMap<>();
5656
try {
57-
JsonObject stats = getPCStatOvertime(webDriver, getStatsConfig).get(0);
57+
JsonObject stats = appRTCMeetingPage.getPCStatOvertime(webDriver, getStatsConfig).get(0);
5858
JsonObject statsSummary = appRTCMeetingPage.buildstatSummary(stats, getStatsConfig.getJsonArray("selectedStats"));
5959
results = appRTCMeetingPage.statsHashMap(statsSummary);
6060
Reporter.getInstance().jsonAttachment(report, "getStatsRaw", stats);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ public static void run(TestConf testConf) {
7171
try {
7272
List<Tuple> tupleList = Configurator.getInstance()
7373
.buildTuples(testConf.getTupleSize(), testConf.isPermute(), testConf.isRegression());
74-
75-
tupleList.addAll(Configurator.getInstance().getCustomBrowserMatrix());
7674

7775
service.submit(new TestRunThread(testConf, tupleList)).get();
7876
} catch (Exception e) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,20 @@ private KiteBaseTest buildTest() throws ClassNotFoundException, NoSuchMethodExce
7575
KiteBaseTest test = testConf.isJavascript()
7676
? new KiteJsTest(testConf.getTestImpl())
7777
: (KiteBaseTest) Class.forName(this.testConf.getTestImpl()).getConstructor().newInstance();
78+
7879
phases = getPhases(testConf.isLoadTest());
7980
test.setCloseWebDrivers(testConf.isCloseWebDrivers());
8081
test.setPhases(phases);
8182
test.setSuite(testSuite.getName());
82-
8383

8484
test.setConfigFilePath(Configurator.getInstance().getConfigFilePath());
8585
test.setInstrumentation(Configurator.getInstance().getInstrumentation());
86-
test.setParentSuite(Configurator.getInstance().getName());
87-
86+
test.setNetworks(Configurator.getInstance().getNetworks());
87+
test.setParentSuite(Configurator.getInstance().getName());
8888
test.setLogger(testConf.getLogger());
8989
test.setDescription(testConf.getDescription());
9090
test.setPayload(testConf.getPayload());
91-
91+
test.setRemoteAddress(Configurator.getInstance().getRemoteAddress());
9292
test.setEndPointList(tuple);
9393

9494
if (testConf.isLoadTest()) {

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

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import io.cosmosoftware.kite.exception.KiteTestException;
2020
import io.cosmosoftware.kite.instrumentation.Instrumentation;
21+
import io.cosmosoftware.kite.instrumentation.NetworkProfileHashMap;
2122
import io.cosmosoftware.kite.report.Reporter;
2223
import org.apache.log4j.Logger;
2324
import org.webrtc.kite.exception.KiteInsufficientValueException;
@@ -60,16 +61,16 @@ public class Configurator {
6061
private String name;
6162
private String commandName;
6263
private String configFilePath;
63-
private boolean customMatrixOnly = false;
6464
private boolean skipSame = false;
6565
private long timeStamp = System.currentTimeMillis();
6666
private JsonObject jsonConfigObject;
6767
private ConfigHandler configHandler;
68-
private List<Tuple> customBrowserMatrix = new ArrayList<>();
6968
private List<JsonObject> testObjectList;
7069
private List<JsonObject> customMatrix;
7170
private List<JsonObject> remoteObjectList = null;
7271
private Instrumentation instrumentation = null;
72+
private NetworkProfileHashMap networks = null;
73+
private String instrumentUrl = null;
7374

7475
private Configurator() {
7576
}
@@ -135,8 +136,6 @@ public void buildConfig()
135136
throw new KiteInsufficientValueException("Less than one browser or app object.");
136137
}
137138

138-
this.customMatrixOnly = jsonConfigObject.getBoolean("customMatrixOnly", this.customMatrixOnly);
139-
140139
this.customMatrix = (List<JsonObject>)
141140
throwNoKeyOrBadValueException(jsonConfigObject, "matrix", JsonArray.class, true);
142141

@@ -169,24 +168,33 @@ public void buildConfig()
169168
new ConfigHandler(permute, callbackURL, remoteObjectList, testObjectList,
170169
browserObjectList, appObjectList);
171170

172-
String instrumentUrl = jsonConfigObject.getString("instrumentUrl", null);
171+
this.instrumentUrl = jsonConfigObject.getString("instrumentUrl", null);
173172
if (instrumentUrl != null) {
174173
try {
175174
String instrumentFile = System.getProperty("java.io.tmpdir") + "instrumentation.json";
176175
if (instrumentUrl.contains("://")) {
177176
//if this is a url, then download it
178-
downloadFile(instrumentUrl, instrumentFile);
177+
downloadFile(this.instrumentUrl, instrumentFile);
179178
} else {
180179
//otherwise assume it can be read directly.
181-
instrumentFile = instrumentUrl;
180+
instrumentFile = this.instrumentUrl;
182181
}
183182
JsonObject instrumentObject = readJsonFile(instrumentFile);
184-
this.instrumentation = new Instrumentation(instrumentObject);
183+
this.instrumentation = new Instrumentation(instrumentObject, instrumentUrl, getRemoteAddress());
185184
} catch (KiteTestException e) {
186185
logger.error(getStackTrace(e));
187186
}
188187
}
189-
skipSame = jsonConfigObject.getBoolean("skipSame", skipSame);
188+
JsonArray networksArray = jsonConfigObject.containsKey("networks") ? jsonConfigObject.getJsonArray("networks"):null;
189+
if (networksArray != null ) {
190+
try {
191+
this.networks = new NetworkProfileHashMap(networksArray);
192+
} catch (Exception e) {
193+
logger.error(getStackTrace(e));
194+
}
195+
196+
}
197+
skipSame = jsonConfigObject.getBoolean("skipSame", skipSame);
190198
logger.info("Finished reading the configuration file");
191199
}
192200

@@ -204,17 +212,16 @@ public List<Tuple> buildTuples(int tupleSize, boolean permute, boolean regressio
204212
listOfTuples.add(new Tuple());
205213
} else {
206214
if (this.customMatrix != null) {
215+
List<Tuple> customBrowserMatrix = new ArrayList<>();
207216
for (JsonStructure structure : this.customMatrix) {
208217
JsonArray jsonArray = (JsonArray) structure;
209218
Tuple tuple = new Tuple();
210219
for (int i = 0; i < jsonArray.size(); i++) {
211220
tuple.add(this.configHandler.getEndPointList().get(jsonArray.getInt(i)));
212221
}
213-
this.customBrowserMatrix.add(tuple);
222+
customBrowserMatrix.add(tuple);
214223
}
215-
216-
if (this.customMatrixOnly)
217-
return null;
224+
return customBrowserMatrix;
218225
}
219226

220227
List<EndPoint> endPointList = this.configHandler.getEndPointList();
@@ -234,9 +241,8 @@ public List<Tuple> buildTuples(int tupleSize, boolean permute, boolean regressio
234241
|| (skipSame && tuple.stream().distinct().limit(2).count() <= 1)) {
235242
listOfTuples.remove(tuple);
236243
}
237-
}
238-
239-
Collections.shuffle(listOfTuples);
244+
}
245+
//Collections.shuffle(listOfTuples);
240246
}
241247
return listOfTuples;
242248
}
@@ -275,15 +281,6 @@ public void setConfigFilePath(String configFilePath) {
275281
public ConfigHandler getConfigHandler() {
276282
return this.configHandler;
277283
}
278-
279-
/**
280-
* getCustomBrowserMatrix
281-
*
282-
* @return the custom browser matrix
283-
*/
284-
public List<Tuple> getCustomBrowserMatrix() {
285-
return this.customBrowserMatrix;
286-
}
287284

288285
/**
289286
* Gets instance.
@@ -297,6 +294,12 @@ public static Configurator getInstance() {
297294
public Instrumentation getInstrumentation() {
298295
return instrumentation;
299296
}
297+
298+
public String getInstrumentUrl() { return this.instrumentUrl; }
299+
300+
public NetworkProfileHashMap getNetworks() {
301+
return networks;
302+
}
300303

301304
/**
302305
* Gets name.
@@ -314,7 +317,7 @@ public String getName() {
314317
*/
315318
public String getRemoteAddress() {
316319
if (remoteObjectList != null && remoteObjectList.size() > 0) {
317-
return remoteObjectList.get(0).getString("remoteAddress");
320+
return remoteObjectList.get(0).getString("remoteAddress").split("/")[2].split(":")[0];
318321
}
319322
return null;
320323
}
@@ -337,15 +340,6 @@ public long getTimeStamp() {
337340
return this.timeStamp;
338341
}
339342

340-
/**
341-
* isCustomerMatrixOnly
342-
*
343-
* @return true if the test is using custom matrix only
344-
*/
345-
public boolean isCustomMatrixOnly() {
346-
return customMatrixOnly;
347-
}
348-
349343
/**
350344
* Build a list of tuple from given endpoints list, permutation or combination
351345
*
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "Kite Test Example with Allure reporting",
3+
"remotes": [
4+
{
5+
"type": "local",
6+
"remoteAddress": "http://localhost:4444/wd/hub"
7+
}
8+
],
9+
"tests": [
10+
{
11+
"name": "KiteExampleAuthTest %ts",
12+
"tupleSize": 1,
13+
"description": "This example test opens gmail page, sign in and verifies it.",
14+
"testImpl": "org.webrtc.kite.example.KiteExampleAuthTest",
15+
"payload" : {
16+
"test1": "ONE",
17+
"test2": "TWO"
18+
}
19+
}
20+
],
21+
"browsers": [
22+
{
23+
"browserName": "chrome",
24+
"version": "74",
25+
"platform": "localhost",
26+
"flags": []
27+
}
28+
],
29+
"apps":[]
30+
}

KITE-Example-Test/configs/js.example.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"tests": [
1010
{
11-
"name": "JS KiteExampleTest %ts",
11+
"name": "JS KiteExampleSearchTest %ts",
1212
"tupleSize": 1,
1313
"description": "This example test opens google and searches for Cosmo Software Consulting and verify the first result",
1414
"testImpl": "Example.js",

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "Kite Test Example with Allure reporting",
2+
"name": "Kite Test Search Example with Allure reporting",
33
"remotes": [
44
{
55
"type": "local",
@@ -8,10 +8,10 @@
88
],
99
"tests": [
1010
{
11-
"name": "KiteExampleTest %ts",
11+
"name": "KiteExampleSearchTest %ts",
1212
"tupleSize": 1,
1313
"description": "This example test opens google and searches for Cosmo Software Consulting and verify the first result",
14-
"testImpl": "org.webrtc.kite.example.KiteExampleTest",
14+
"testImpl": "org.webrtc.kite.example.KiteExampleSearchTest",
1515
"payload" : {
1616
"test1": "ONE",
1717
"test2": "TWO"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.webrtc.kite.example;
2+
3+
import org.webrtc.kite.example.checks.GmailSignInCheck;
4+
import org.webrtc.kite.example.checks.GoogleFirstResultCheck;
5+
import org.webrtc.kite.example.steps.GmailSignInStep;
6+
import org.webrtc.kite.example.steps.GoogleSearchStep;
7+
import org.webrtc.kite.tests.KiteBaseTest;
8+
import org.webrtc.kite.tests.TestRunner;
9+
10+
public class KiteExampleAuthTest extends KiteBaseTest {
11+
12+
13+
@Override
14+
protected void payloadHandling() {}
15+
16+
@Override
17+
public void populateTestSteps(TestRunner runner) {
18+
runner.addStep(new GmailSignInStep(runner.getWebDriver()));
19+
runner.addStep(new GmailSignInCheck(runner.getWebDriver()));
20+
}
21+
22+
}

0 commit comments

Comments
 (0)