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

Commit cee77b3

Browse files
committed
new webrtc stats
1 parent 0ebd85a commit cee77b3

File tree

59 files changed

+1343
-951
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1343
-951
lines changed

KITE-AppRTC-Test/configs/js.iceconnection.apprtc.config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
{
3232
"browserName": "chrome",
3333
"platform": "localhost",
34+
"headless": true
3435
}
3536
]
3637
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import io.cosmosoftware.kite.interfaces.Runner;
2020
import io.cosmosoftware.kite.report.Status;
2121
import io.cosmosoftware.kite.steps.TestCheck;
22-
import org.webrtc.kite.stats.RTCStatList;
22+
import org.webrtc.kite.stats.rtc.RTCStatList;
2323

2424
import static io.cosmosoftware.kite.entities.Timeouts.ONE_SECOND_INTERVAL;
2525
import static org.webrtc.kite.stats.StatsUtils.getPCStatOvertime;

KITE-AppRTC-Test/src/test/java/org/webrtc/kite/AppRTCTestTest.java

Lines changed: 0 additions & 78 deletions
This file was deleted.

KITE-Engine/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@
152152
<artifactId>sqlite-jdbc</artifactId>
153153
<version>${kite.sqlite.jdbc.version}</version>
154154
</dependency>
155+
<dependency>
156+
<groupId>commons-net</groupId>
157+
<artifactId>commons-net</artifactId>
158+
<version>3.7</version>
159+
</dependency>
155160
</dependencies>
156161

157162
</project>

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

Lines changed: 46 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
import io.cosmosoftware.kite.report.KiteLogger;
2020
import java.util.HashMap;
21+
22+
import org.apache.commons.net.ftp.FTP;
23+
import org.apache.commons.net.ftp.FTPClient;
24+
import org.apache.commons.net.ftp.FTPClientConfig;
25+
import org.apache.commons.net.ftp.FTPReply;
2126
import org.apache.http.client.methods.CloseableHttpResponse;
2227
import org.apache.http.client.methods.HttpPost;
2328
import org.apache.http.entity.FileEntity;
@@ -39,64 +44,64 @@
3944
public class CallbackThread extends Thread {
4045

4146
private static final KiteLogger logger = KiteLogger.getLogger(CallbackThread.class.getName());
42-
47+
4348
private String callbackURL;
49+
private int callbackPort;
50+
private String username;
51+
private String password;
4452
private File file;
45-
private HashMap<String,String> parameters = new HashMap<>();
46-
53+
private boolean uploadComplete;
54+
4755
/**
4856
* Constructs a new CallBackThread object with the given callbackURL and JsonObject.
4957
*
5058
* @param callbackURL a string representation of the callback URL.
5159
* @param file File
5260
*/
53-
public CallbackThread(String callbackURL, File file) {
61+
public CallbackThread(String callbackURL, int callbackPort, String username, String password, File file) {
5462
this.callbackURL = callbackURL;
5563
this.file = file;
56-
64+
this.callbackPort = callbackPort;
65+
this.username = username;
66+
this.password = password;
5767
}
5868

5969
/**
6070
* Posts result to the callback URL.
6171
*/
6272
public void postResult() throws IOException {
63-
String charset = "UTF-8";
64-
String boundary = Long.toHexString(System.currentTimeMillis()); // Just generate some unique random value.
65-
String CRLF = "\r\n"; // Line separator required by multipart/form-data.
66-
67-
URLConnection connection = new URL(this.callbackURL + this.getParameterString()).openConnection();
68-
logger.debug("Sending result to callback url: " + connection);
69-
connection.setDoOutput(true);
70-
connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
71-
72-
try (
73-
OutputStream output = connection.getOutputStream();
74-
PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, charset), true);
75-
) {
76-
// Send binary file.
77-
writer.append("--" + boundary).append(CRLF);
78-
writer.append("Content-Disposition: form-data; name=\"binaryFile\"; filename=\"" + this.file.getName() + "\"").append(CRLF);
79-
writer.append("Content-Type: " + URLConnection.guessContentTypeFromName(this.file.getName())).append(CRLF);
80-
writer.append("Content-Transfer-Encoding: binary").append(CRLF);
81-
writer.append(CRLF).flush();
82-
Files.copy(this.file.toPath(), output);
83-
output.flush(); // Important before continuing with writer!
84-
writer.append(CRLF).flush(); // CRLF is important! It indicates end of boundary.
85-
86-
// End of multipart/form-data.
87-
writer.append("--" + boundary + "--").append(CRLF).flush();
88-
} catch (IOException e) {
89-
e.printStackTrace();
90-
}
91-
92-
// Request is lazily fired whenever you need to obtain information about response.
93-
int responseCode = 0;
73+
FTPClient ftp = new FTPClient();
74+
boolean error = false;
9475
try {
95-
responseCode = ((HttpURLConnection) connection).getResponseCode();
96-
} catch (IOException e) {
76+
int reply;
77+
ftp.connect(callbackURL, callbackPort);
78+
ftp.login(username, password);
79+
ftp.enterLocalPassiveMode();
80+
ftp.setFileType(FTP.BINARY_FILE_TYPE);
81+
logger.info("Connected to " + callbackURL + ".");
82+
reply = ftp.getReplyCode();
83+
if(!FTPReply.isPositiveCompletion(reply)) {
84+
ftp.disconnect();
85+
logger.error("FTP server refused connection.");
86+
}
87+
FileInputStream inputStream = new FileInputStream(file);
88+
this.uploadComplete = ftp.storeFile(file.getName(), inputStream);
89+
if(this.uploadComplete) {
90+
inputStream.close();
91+
this.file.delete();
92+
}
93+
ftp.logout();
94+
} catch(IOException e) {
9795
e.printStackTrace();
96+
} finally {
97+
if(ftp.isConnected()) {
98+
try {
99+
ftp.disconnect();
100+
} catch(IOException ioe) {
101+
// do nothing
102+
}
103+
}
98104
}
99-
System.out.println(responseCode); // Should be 200
100105
}
101106

102107
@Override
@@ -108,20 +113,8 @@ public void run() {
108113
}
109114
}
110115

111-
private String getParameterString() {
112-
String res = "?";
113-
if (this.parameters.isEmpty()) {
114-
return "";
115-
}
116-
for (String key : parameters.keySet()) {
117-
res += key + "=" + parameters.get(key) + "&";
118-
}
119-
// to remove the last &
120-
return res.substring(0,res.length() - 1);
116+
public boolean isUploadComplete() {
117+
return this.uploadComplete;
121118
}
122119

123-
public void addParameter(String key, String value) {
124-
this.parameters.put(key, value);
125-
}
126-
127120
}

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,8 @@ public static void main(String[] args) {
186186
}
187187

188188
if(testConfig.getCallbackUrl() != null) {
189-
String desFile = testConfig.getReporter().getReportPath() + "../" + System.currentTimeMillis() + ".zip";
190-
ReportUtils.zipFile(testConfig.getReporter().getReportPath(), desFile);
191-
File zipToSend = new File(desFile);
192-
if (zipToSend.exists()) {
193-
CallbackThread callbackThread = new CallbackThread(testConfig.getCallbackUrl(), zipToSend);
194-
callbackThread.addParameter("tagName", testConfig.getTagName() == null
195-
? String.valueOf(System.currentTimeMillis())
196-
: testConfig.getTagName());
197-
callbackThread.run();
198-
zipToSend.delete();
199-
}
189+
upload(testConfig.getReporter().getReportPath() + "../" + testConfig.getName() + "-allure." + System.currentTimeMillis() + ".zip",
190+
testConfig.getReporter().getReportPath(), testConfig.getCallbackUrl(), testConfig.getCallbackPort(), testConfig.getCallbackUsername(), testConfig.getCallbackPassword());
200191
}
201192

202193
} catch (Exception e) {
@@ -231,6 +222,17 @@ private static List<String> getJsonFiles (File file) {
231222
return files;
232223
}
233224

225+
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();
232+
}
233+
return false;
234+
}
235+
234236
/**
235237
* Run interop.
236238
*
@@ -399,11 +401,11 @@ public static CircularLinkedList<Paas> getPaasWithProfile(List<Paas> originalLis
399401
// logger.info("looking for paas with spec " + client.getBrowserSpecs());
400402
// if (paas.getSpecList().contains(client.getBrowserSpecs())) {
401403
logger.info("looking for paas with profile " + client.getNetworkProfile().getName());
402-
if (paas.getNetworkProfile().getName().equals(client.getNetworkProfile().getName())) {
403-
if (paas.getAvailableSlots() > 0) {
404+
// if (paas.getNetworkProfile().getName().equals(client.getNetworkProfile().getName())) {
405+
// if (paas.getAvailableSlots() > 0) {
404406
res.add(paas);
405-
}
406-
}
407+
// }
408+
// }
407409
// }
408410
}
409411
return new CircularLinkedList<Paas>(res);

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,15 @@ synchronized private void shutdownExecutors() {
256256
*/
257257
private KiteLogger createTestLogger(String kiteRequestId, String testName) {
258258
KiteLogger testLogger = KiteLogger.getLogger(new SimpleDateFormat("yyyy-MM-dd-HHmmss").format(new Date()));
259-
String logFileName = (kiteRequestId.equals("") ?
260-
"logs/" : ( System.getProperty("catalina.base") + "/logs/" +kiteRequestId + "_")) + testName + "/test_" + testLogger.getName() + ".log";
259+
String logFileName = ((kiteRequestId == null || kiteRequestId.equals("null")) ?
260+
"" : (kiteRequestId + "_")) + testName + "/test_" + testLogger.getName() + ".log";
261+
String logFilePath = "logs/" + logFileName;
262+
if (System.getProperty("catalina.base") != null) {
263+
logFilePath = System.getProperty("catalina.base") + "/" + logFilePath;
264+
}
261265
try {
262266
FileAppender fileAppender = new FileAppender(
263-
new PatternLayout("%d %-5p - %m%n"), logFileName, false);
267+
new PatternLayout("%d %-5p - %m%n"), logFilePath, false);
264268
fileAppender.setThreshold(Level.INFO);
265269
testLogger.addAppender(fileAppender);
266270
} catch (IOException e) {

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,13 @@ public List<Tuple> buildTuples(int tupleSize, boolean permute, boolean regressio
217217

218218
listOfTuples = recursivelyBuildTuples(tupleSize, 0, clientList, (new Tuple()).getClients(), permute);
219219

220-
// List<Tuple> tempListOfTuples = new ArrayList<>(listOfTuples);
221-
// for (Tuple tuple : tempListOfTuples) {
222-
// if (Collections.disjoint(tuple.getClients(), focusedList)
223-
// || (skipSame && tuple.getClients().stream().distinct().limit(2).count() <= 1)) {
224-
// listOfTuples.remove(tuple);
225-
// }
226-
// }
220+
List<Tuple> tempListOfTuples = new ArrayList<>(listOfTuples);
221+
for (Tuple tuple : tempListOfTuples) {
222+
if (Collections.disjoint(tuple.getClients(), focusedList)
223+
|| (skipSame && tuple.getClients().stream().distinct().limit(2).count() <= 1)) {
224+
listOfTuples.remove(tuple);
225+
}
226+
}
227227
for (Tuple t :listOfTuples) {
228228
logger.debug("Tuple = " + t.getId());
229229
}

KITE-Framework/src/main/java/org/webrtc/kite/Utils.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,4 +400,14 @@ public static String fetchMediaPath(MediaFile media, String browserName) {
400400
}
401401
return media.getFilepath() + extension;
402402
}
403+
404+
public static boolean deleteDirectory(File directoryToBeDeleted) {
405+
File[] allContents = directoryToBeDeleted.listFiles();
406+
if (allContents != null) {
407+
for (File file : allContents) {
408+
deleteDirectory(file);
409+
}
410+
}
411+
return directoryToBeDeleted.delete();
412+
}
403413
}

KITE-Framework/src/main/java/org/webrtc/kite/WebDriverFactory.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,14 @@ private static MutableCapabilities buildBrowserCapabilities(Client client) {
137137
break;
138138
case "safari":
139139
SafariOptions options = new SafariOptions();
140-
options.setUseTechnologyPreview(client.getCapability().isTechnologyPreview());
141140
capabilities.setCapability(SafariOptions.CAPABILITY, options);
142141
break;
142+
case "Safari Technology Preview":
143+
SafariOptions TPoptions = new SafariOptions();
144+
TPoptions.setCapability(CapabilityType.BROWSER_NAME, specs.getBrowserName());
145+
TPoptions.setUseTechnologyPreview(true);
146+
capabilities.setCapability(SafariOptions.CAPABILITY, TPoptions);
147+
break;
143148
default:
144149
capabilities.setCapability(CapabilityType.BROWSER_NAME, specs.getBrowserName());
145150
break;
@@ -311,6 +316,9 @@ private static ChromeOptions setCommonChromeOptions(Capability capability, Brows
311316
}
312317
}
313318

319+
if (specs.getPlatform().equals(Platform.ANDROID)) {
320+
return chromeOptions;
321+
}
314322
// Create an Hashmap to edit user profile
315323
Map<String, Object> prefs = new HashMap<String, Object>();
316324
// Allow access to camera & micro
@@ -321,9 +329,6 @@ private static ChromeOptions setCommonChromeOptions(Capability capability, Brows
321329
chromeOptions.setExperimentalOption("prefs", prefs);
322330

323331

324-
if (specs.getPlatform().equals(Platform.ANDROID)) {
325-
return chromeOptions;
326-
}
327332

328333
chromeOptions.addArguments("auto-select-desktop-capture-source=Entire screen");
329334
if (! "electron".equals(specs.getVersion())) {

0 commit comments

Comments
 (0)