Add TCP to Websocket test and new coverage report script
This commit is contained in:
parent
b49a9767c7
commit
b91f89fea2
@ -1,36 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Export the library path for now
|
|
||||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/libnymea-remoteproxy:$(pwd)/libnymea-remoteproxyclient
|
|
||||||
|
|
||||||
# Build
|
|
||||||
qmake CONFIG+=coverage CONFIG+=ccache
|
|
||||||
make -j$(nproc)
|
|
||||||
#make test
|
|
||||||
make coverage-html
|
|
||||||
|
|
||||||
# Clean build
|
|
||||||
make clean
|
|
||||||
|
|
||||||
# Clean source directory
|
|
||||||
rm -v Makefile
|
|
||||||
|
|
||||||
rm -v libnymea-remoteproxy/libnymea-remoteproxy.so*
|
|
||||||
rm -v libnymea-remoteproxy/Makefile
|
|
||||||
|
|
||||||
rm -v libnymea-remoteproxyclient/libnymea-remoteproxyclient.so*
|
|
||||||
rm -v libnymea-remoteproxyclient/Makefile
|
|
||||||
|
|
||||||
rm -v server/nymea-remoteproxy
|
|
||||||
rm -v server/Makefile
|
|
||||||
|
|
||||||
rm -v tests/Makefile
|
|
||||||
|
|
||||||
rm -v tests/test-offline/nymea-remoteproxy-tests-offline
|
|
||||||
rm -v tests/test-offline/Makefile
|
|
||||||
|
|
||||||
#rm -v tests/test-online/nymea-remoteproxy-tests-online
|
|
||||||
#rm -v tests/test-online/Makefile
|
|
||||||
|
|
||||||
rm -v client/nymea-remoteproxy-client
|
|
||||||
rm -v client/Makefile
|
|
||||||
12
generate-coverage.sh
Executable file
12
generate-coverage.sh
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
SCRIPT_DIR=$(dirname $0)
|
||||||
|
SRC_DIR="$SCRIPT_DIR/../build-nymea-remoteproxy-Desktop-Debug/"
|
||||||
|
COV_DIR="$SRC_DIR/coverage"
|
||||||
|
HTML_RESULTS="${COV_DIR}/html"
|
||||||
|
|
||||||
|
# Build code coverage html report
|
||||||
|
mkdir -p ${HTML_RESULTS}
|
||||||
|
lcov -d "${SRC_DIR}" -c -o "${COV_DIR}/coverage.info"
|
||||||
|
lcov -r "${COV_DIR}/coverage.info" "*.h" "*/tests/*" "*.moc" "*moc_*.cpp" "*/test/*" "/usr/include/*" "*/build*/*" "*libnymea-remoteproxy/authentication/aws*" -o "${COV_DIR}/coverage-filtered.info"
|
||||||
|
genhtml -o "${HTML_RESULTS}" "${COV_DIR}/coverage-filtered.info"
|
||||||
|
lcov -d "${COV_DIR}" -z
|
||||||
@ -1306,4 +1306,98 @@ void RemoteProxyOfflineTests::tcpRemoteConnection()
|
|||||||
stopServer();
|
stopServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemoteProxyOfflineTests::tcpWebsocketRemoteConnection()
|
||||||
|
{
|
||||||
|
// Start the server
|
||||||
|
startServer();
|
||||||
|
|
||||||
|
// Configure mock authenticator
|
||||||
|
m_mockAuthenticator->setTimeoutDuration(100);
|
||||||
|
m_mockAuthenticator->setExpectedAuthenticationError();
|
||||||
|
|
||||||
|
QString nameConnectionOne = "Test client one";
|
||||||
|
QUuid uuidConnectionOne = QUuid::createUuid();
|
||||||
|
|
||||||
|
QString nameConnectionTwo = "Test client two";
|
||||||
|
QUuid uuidConnectionTwo = QUuid::createUuid();
|
||||||
|
|
||||||
|
QByteArray dataOne = "Hello from client one :-)";
|
||||||
|
QByteArray dataTwo = "Hello from client two :-)";
|
||||||
|
|
||||||
|
// Create two connection
|
||||||
|
RemoteProxyConnection *connectionOne = new RemoteProxyConnection(uuidConnectionOne, nameConnectionOne, RemoteProxyConnection::ConnectionTypeWebSocket, this);
|
||||||
|
connect(connectionOne, &RemoteProxyConnection::sslErrors, this, &BaseTest::ignoreConnectionSslError);
|
||||||
|
|
||||||
|
RemoteProxyConnection *connectionTwo = new RemoteProxyConnection(uuidConnectionTwo, nameConnectionTwo, RemoteProxyConnection::ConnectionTypeTcpSocket, this);
|
||||||
|
connect(connectionTwo, &RemoteProxyConnection::sslErrors, this, &BaseTest::ignoreConnectionSslError);
|
||||||
|
|
||||||
|
// Connect one
|
||||||
|
QSignalSpy connectionOneReadySpy(connectionOne, &RemoteProxyConnection::ready);
|
||||||
|
QVERIFY(connectionOne->connectServer(m_serverUrl));
|
||||||
|
connectionOneReadySpy.wait();
|
||||||
|
QVERIFY(connectionOneReadySpy.count() == 1);
|
||||||
|
QVERIFY(connectionOne->isConnected());
|
||||||
|
|
||||||
|
// Connect two
|
||||||
|
QSignalSpy connectionTwoReadySpy(connectionTwo, &RemoteProxyConnection::ready);
|
||||||
|
QVERIFY(connectionTwo->connectServer(m_serverUrlTcp));
|
||||||
|
connectionTwoReadySpy.wait();
|
||||||
|
QVERIFY(connectionTwoReadySpy.count() == 1);
|
||||||
|
QVERIFY(connectionTwo->isConnected());
|
||||||
|
|
||||||
|
// Authenticate one
|
||||||
|
QSignalSpy remoteConnectionEstablishedOne(connectionOne, &RemoteProxyConnection::remoteConnectionEstablished);
|
||||||
|
QSignalSpy connectionOneAuthenticatedSpy(connectionOne, &RemoteProxyConnection::authenticated);
|
||||||
|
QVERIFY(connectionOne->authenticate(m_testToken));
|
||||||
|
connectionOneAuthenticatedSpy.wait();
|
||||||
|
QVERIFY(connectionOneAuthenticatedSpy.count() == 1);
|
||||||
|
QVERIFY(connectionOne->isConnected());
|
||||||
|
QVERIFY(connectionOne->isAuthenticated());
|
||||||
|
QVERIFY(connectionOne->state() == RemoteProxyConnection::StateAuthenticated);
|
||||||
|
|
||||||
|
// Authenticate two
|
||||||
|
QSignalSpy remoteConnectionEstablishedTwo(connectionTwo, &RemoteProxyConnection::remoteConnectionEstablished);
|
||||||
|
QSignalSpy connectionTwoAuthenticatedSpy(connectionTwo, &RemoteProxyConnection::authenticated);
|
||||||
|
QVERIFY(connectionTwo->authenticate(m_testToken));
|
||||||
|
connectionTwoAuthenticatedSpy.wait();
|
||||||
|
qDebug() << connectionTwoAuthenticatedSpy.count();
|
||||||
|
QVERIFY(connectionTwoAuthenticatedSpy.count() == 1);
|
||||||
|
QVERIFY(connectionTwo->isConnected());
|
||||||
|
QVERIFY(connectionTwo->isAuthenticated());
|
||||||
|
|
||||||
|
// Wait for both to be connected
|
||||||
|
remoteConnectionEstablishedOne.wait(500);
|
||||||
|
remoteConnectionEstablishedTwo.wait(500);
|
||||||
|
|
||||||
|
QVERIFY(remoteConnectionEstablishedOne.count() == 1);
|
||||||
|
QVERIFY(remoteConnectionEstablishedTwo.count() == 1);
|
||||||
|
QVERIFY(connectionOne->state() == RemoteProxyConnection::StateRemoteConnected);
|
||||||
|
QVERIFY(connectionTwo->state() == RemoteProxyConnection::StateRemoteConnected);
|
||||||
|
|
||||||
|
QCOMPARE(connectionOne->tunnelPartnerName(), nameConnectionTwo);
|
||||||
|
QCOMPARE(connectionOne->tunnelPartnerUuid(), uuidConnectionTwo.toString());
|
||||||
|
QCOMPARE(connectionTwo->tunnelPartnerName(), nameConnectionOne);
|
||||||
|
QCOMPARE(connectionTwo->tunnelPartnerUuid(), uuidConnectionOne.toString());
|
||||||
|
|
||||||
|
// Pipe data trought the tunnel
|
||||||
|
QSignalSpy remoteConnectionDataOne(connectionOne, &RemoteProxyConnection::dataReady);
|
||||||
|
QSignalSpy remoteConnectionDataTwo(connectionTwo, &RemoteProxyConnection::dataReady);
|
||||||
|
|
||||||
|
connectionOne->sendData(dataOne);
|
||||||
|
remoteConnectionDataTwo.wait(500);
|
||||||
|
QVERIFY(remoteConnectionDataTwo.count() == 1);
|
||||||
|
QCOMPARE(remoteConnectionDataTwo.at(0).at(0).toByteArray().trimmed(), dataOne);
|
||||||
|
|
||||||
|
connectionTwo->sendData(dataTwo);
|
||||||
|
remoteConnectionDataOne.wait(500);
|
||||||
|
QVERIFY(remoteConnectionDataOne.count() == 1);
|
||||||
|
QCOMPARE(remoteConnectionDataOne.at(0).at(0).toByteArray().trimmed(), dataTwo);
|
||||||
|
|
||||||
|
connectionOne->deleteLater();
|
||||||
|
connectionTwo->deleteLater();
|
||||||
|
|
||||||
|
// Clean up
|
||||||
|
stopServer();
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(RemoteProxyOfflineTests)
|
QTEST_MAIN(RemoteProxyOfflineTests)
|
||||||
|
|||||||
@ -83,6 +83,7 @@ private slots:
|
|||||||
|
|
||||||
// TCP Websocket combinations
|
// TCP Websocket combinations
|
||||||
void tcpRemoteConnection();
|
void tcpRemoteConnection();
|
||||||
|
void tcpWebsocketRemoteConnection();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user