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

Commit

Permalink
Improvements on KITE Engine:
Browse files Browse the repository at this point in the history
 - Removed test logic from engine.
 - Randomized test running process for better utilization of the given Grid.
 - Improved mobile browser recognition.
 - Removed single queue for now.

Improvements on KITE Test interface.
  • Loading branch information
namvuCosmo committed Apr 26, 2018
1 parent 2707c39 commit c33d066
Show file tree
Hide file tree
Showing 50 changed files with 2,157 additions and 1,936 deletions.
50 changes: 50 additions & 0 deletions KITE-Base-Test/pom.xml
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.webrtc.kite</groupId>
<artifactId>kite-base-test</artifactId>
<name>kite-base-test</name>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kite.version>${project.version}</kite.version>
<kite.java.version>1.8</kite.java.version>
<kite.junit.version>4.12</kite.junit.version>
<kite.log4j.version>1.2.17</kite.log4j.version>
<!-- maven plugin versions, shouldn't need be changed very often -->
<kite.test.mvn.compiler.version>3.6.1</kite.test.mvn.compiler.version>
</properties>

<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${kite.log4j.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.webrtc.kite</groupId>
<artifactId>kite-if</artifactId>
<version>${kite.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.webrtc.kite</groupId>
<artifactId>kite-engine</artifactId>
<version>${kite.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${kite.junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
28 changes: 15 additions & 13 deletions KITE-Engine-IF/pom.xml
@@ -1,24 +1,26 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.webrtc.kite</groupId>
<parent>
<groupId>org.webrtc.kite</groupId>
<artifactId>kite-base</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>kite-if</artifactId>
<version>1.0</version>
<name>kite-if</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<version>${kite.mvn.compiler.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>${kite.java.version}</source>
<target>${kite.java.version}</target>
</configuration>
</plugin>
</plugins>
Expand All @@ -28,12 +30,12 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.7.1</version>
<version>${kite.selenium.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
<version>${kite.json.version}</version>
</dependency>
</dependencies>

Expand Down
26 changes: 26 additions & 0 deletions KITE-Engine-IF/src/main/java/org/webrtc/kite/KiteTest.java
Expand Up @@ -17,8 +17,15 @@
package org.webrtc.kite;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.logging.LogEntries;
import org.openqa.selenium.logging.LogEntry;
import org.openqa.selenium.logging.LogType;

import javax.json.JsonValue;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
* Parent class for a test case.
Expand Down Expand Up @@ -65,4 +72,23 @@ public void setWebDriverList(List<WebDriver> webDriverList) {
*/
public abstract Object testScript() throws Exception;

/**
*
* @param driver the subject web driver that we want to get console log
* @return List of log entries.
*/
public List<String> analyzeLog(WebDriver driver) {
List<String> log = new ArrayList<>();
Set<String> logTypes = driver.manage().logs().getAvailableLogTypes();
if (logTypes.contains(LogType.BROWSER)) {
LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER);
for (LogEntry entry : logEntries) {
log.add(entry.getLevel() + " " + entry.getMessage());
}
} else {
log.add("This browser does not support getting console log.");
}
return log;
}

}
40 changes: 36 additions & 4 deletions KITE-Engine/README.md
Expand Up @@ -7,7 +7,39 @@ java -cp kite-jar-with-dependencies.jar:[Path and name of the test implementatio
# Examples:
## AppRTC
java -cp kite-jar-with-dependencies.jar:apprtc-test-1.0.jar org.webrtc.kite.Engine local.config.json


# TODO:
config.json example

{
"name": "local selenium example",
"callback": "http://localhost:8080/kiteweb/datacenter",
"remotes": [
{
"type": "local",
"remoteAddress": "http://localhost:4444/wd/hub"
}
],
"tests": [
{
"name": "IceConnectionTest",
"tupleSize": 2,
"description": "This test check the ICEConnection state between two browsers communicating via appr.tc",
"testImpl": "org.webrtc.kite.IceConnectionTest"
}
],
"browsers": [
{
"browserName": "chrome",
"version": "57.0",
"platform": "MAC"
},
{
"browserName": "firefox",
"version": "45.0",
"platform": "LINUX"
},
{
"browserName": "MicrosoftEdge",
"version": "14.0",
"platform": "WINDOWS"
}
]
}
46 changes: 24 additions & 22 deletions KITE-Engine/pom.xml
@@ -1,24 +1,26 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.webrtc.kite</groupId>
<artifactId>kite</artifactId>
<version>1.0</version>
<parent>
<groupId>org.webrtc.kite</groupId>
<artifactId>kite-base</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>kite-engine</artifactId>
<name>kite-engine</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<version>${kite.mvn.compiler.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>${kite.java.version}</source>
<target>${kite.java.version}</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -54,50 +56,50 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.7.1</version>
<version>${kite.selenium.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
<version>${kite.json.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<version>${kite.log4j.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.16.1</version>
<version>${kite.sqlite.jdbc.version}</version>
</dependency>
<dependency>
<groupId>eu.bitwalker</groupId>
<artifactId>UserAgentUtils</artifactId>
<version>1.20</version>
<version>1.21</version>
</dependency>
<!-- https://mvnrepository.com/artifact/is.tagomor.woothee/woothee-java -->
<dependency>
<groupId>is.tagomor.woothee</groupId>
<artifactId>woothee-java</artifactId>
<version>1.5.1</version>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>org.webrtc.kite</groupId>
<artifactId>kite-if</artifactId>
<version>1.0</version>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<version>${kite.junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.1</version>
<version>2.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
<dependency>
Expand Down
35 changes: 15 additions & 20 deletions KITE-Engine/src/main/java/org/webrtc/kite/CallbackThread.java
@@ -1,12 +1,12 @@
/*
* Copyright 2017 Google Inc.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* https://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -16,23 +16,22 @@

package org.webrtc.kite;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.log4j.Logger;

import javax.json.JsonObject;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

/**
* A thread to post the result in json format to the callback URL.
*/
public class CallbackThread extends Thread {

private final static Logger logger = Logger.getLogger(CallbackThread.class.getName());
private static final Logger logger = Logger.getLogger(CallbackThread.class.getName());

private String callbackURL;
private JsonObject jsonObject;
Expand All @@ -41,15 +40,14 @@ public class CallbackThread extends Thread {
* Constructs a new CallBackThread object with the given callbackURL and JsonObject.
*
* @param callbackURL a string representation of the callback URL.
* @param jsonObject JsonObject
* @param jsonObject JsonObject
*/
public CallbackThread(String callbackURL, JsonObject jsonObject) {
this.callbackURL = callbackURL;
this.jsonObject = jsonObject;
}

@Override
public void run() {
@Override public void run() {
this.postResult();
}

Expand All @@ -61,9 +59,8 @@ public void postResult() {
CloseableHttpClient client = null;
CloseableHttpResponse response = null;

if (logger.isTraceEnabled()) {
logger.trace("Posting to " + callbackURL + ":" + jsonObject.toString());
}
if (logger.isDebugEnabled())
logger.debug("Posting to '" + callbackURL + "' with body '" + jsonObject.toString() + "'");

try {
client = HttpClients.createDefault();
Expand All @@ -73,28 +70,26 @@ public void postResult() {
StringEntity entity = new StringEntity(jsonObject.toString());
httpPost.setEntity(entity);
response = client.execute(httpPost);
} catch (UnsupportedEncodingException e) {
logger.warn("Error with post body", e);
} catch (ClientProtocolException e) {
logger.warn("Error executing post", e);
} catch (IOException e) {
logger.warn("Error executing post", e);
logger.error("Exception while posting the result", e);
} finally {
if (response != null) {
logger.info("response->" + response);
if (logger.isDebugEnabled())
logger.debug("response->" + response);
try {
response.close();
} catch (IOException e) {
e.printStackTrace();
logger.warn("Exception while closing the CloseableHttpResponse", e);
}
}
if (client != null)
try {
client.close();
} catch (IOException e) {
e.printStackTrace();
logger.warn("Exception while closing the CloseableHttpClient", e);
}
}

}

}

0 comments on commit c33d066

Please sign in to comment.