Skip to content

Commit

Permalink
Do not use SCTP in tests, add JingleOfferFactoryTest (#729)
Browse files Browse the repository at this point in the history
* test: Add JingleOfferFactoryTest.

* test: Remove BundleTest.

The test covers functions of jitsi-videobridge (which should be tested
in the project) and the Jingle offer that jicofo creates (now covered in
JingleOfferFactoryTest). The rest is just behavior specific to the
*test* code (e.g. that a GroupPacketExtension is present, which is only
ever added by MockParticipant itself).

* test: Do not use SCTP in tests (do not try to load usrsctp).

* ref: Simplift ColibriTest.

* test: Do not verify jvb intenals.

* test: Remove disabled test, do not verify jvb internals.
  • Loading branch information
bgrozev authored Apr 21, 2021
1 parent 5f4c5f8 commit ff32df2
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 488 deletions.
55 changes: 0 additions & 55 deletions src/test/java/mock/MockParticipant.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,58 +298,6 @@ private Map<String, IceUdpTransportPacketExtension> createTransportMap(
return transportMap;
}

public Map<String, IceUdpTransportPacketExtension> generateFakeCandidates()
{
for (ContentPacketExtension content : myContents)
{
IceUdpTransportPacketExtension iceTransport
= transportMap.get(content.getName());

CandidatePacketExtension fakeCandidate
= new CandidatePacketExtension();

fakeCandidate.setIP("127.0.0.1");
fakeCandidate.setPort(60000);
fakeCandidate.setType(CandidateType.host);

iceTransport.addCandidate(fakeCandidate);
}
return transportMap;
}

public JingleIQ sendTransportInfo()
{
List<ContentPacketExtension> contents = new ArrayList<>();

for (ContentPacketExtension myContent : myContents)
{
ContentPacketExtension content = new ContentPacketExtension();
content.setName(myContent.getName());

try
{
IceUdpTransportPacketExtension transportCopy
= IceUdpTransportPacketExtension
.cloneTransportAndCandidates(transportMap.get(content.getName()), true);

content.addChildExtension(transportCopy);

contents.add(content);
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}

JingleIQ transportInfoIq
= JinglePacketFactory.createTransportInfo(myJid, remoteJid, jingleSession.getSessionID(), contents);

UtilKt.tryToSendStanza(mockConnection, transportInfoIq);

return transportInfoIq;
}

private JingleIQ generateSessionAccept(
JingleIQ sessionInit,
Map<String, IceUdpTransportPacketExtension> transportMap)
Expand All @@ -361,9 +309,6 @@ private JingleIQ generateSessionAccept(
accept.setFrom(sessionInit.getTo());
accept.setTo(sessionInit.getFrom());

// Jingle BUNDLE extension
accept.addExtension(GroupPacketExtension.createBundleGroup( sessionInit.getContentList()));

for (ContentPacketExtension contentOffer : myContents)
{
ContentPacketExtension acceptContent = new ContentPacketExtension();
Expand Down
13 changes: 10 additions & 3 deletions src/test/java/mock/MockXmppProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
import org.jitsi.jicofo.jibri.*;
import org.jitsi.jicofo.xmpp.*;
import org.jitsi.protocol.xmpp.*;
import org.jivesoftware.smack.*;
import org.json.simple.*;
import org.jxmpp.jid.*;
import org.jxmpp.jid.impl.*;
import org.jxmpp.stringprep.*;

import java.util.*;
import java.util.stream.*;

/**
*
Expand All @@ -42,6 +42,13 @@ public class MockXmppProvider
{
private final MockXmppConnection connection;

/**
* The features returned for any JID. We use default client features, but disable SCTP.
*/
private final List<String> features
= DiscoveryUtil.getDefaultParticipantFeatureSet().stream()
.filter(f -> !f.equals(DiscoveryUtil.FEATURE_SCTP)).collect(Collectors.toList());

private final AbstractOperationSetJingle jingleOpSet;

private final MockMultiUserChatOpSet mucApi;
Expand Down Expand Up @@ -92,7 +99,7 @@ public XmppConnectionConfig getConfig()


@Override
public AbstractXMPPConnection getXmppConnection()
public MockXmppConnection getXmppConnection()
{
return connection;
}
Expand Down Expand Up @@ -134,7 +141,7 @@ public ChatRoom findOrCreateRoom(@NotNull EntityBareJid name) throws RoomExistsE
@Override
public List<String> discoverFeatures(@NotNull EntityFullJid jid)
{
return DiscoveryUtil.getDefaultParticipantFeatureSet();
return features;
}

@Override
Expand Down
23 changes: 1 addition & 22 deletions src/test/java/mock/jvb/MockVideobridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.jitsi.xmpp.extensions.colibri.*;
import org.jivesoftware.smack.iqrequest.*;
import org.jivesoftware.smack.packet.*;
import org.jxmpp.jid.*;

/**
*
Expand All @@ -40,18 +39,15 @@ public class MockVideobridge

private final MockXmppConnection connection;

private final Jid bridgeJid;

private Videobridge bridge;

private final ColibriConferenceIqHandler confIqGetHandler = new ColibriConferenceIqHandler(IQ.Type.get);

private final ColibriConferenceIqHandler confIqSetHandler = new ColibriConferenceIqHandler(IQ.Type.set);

public MockVideobridge(MockXmppConnection connection, Jid bridgeJid)
public MockVideobridge(MockXmppConnection connection)
{
this.connection = connection;
this.bridgeJid = bridgeJid;
}

public void start()
Expand Down Expand Up @@ -102,21 +98,4 @@ public IQ handleIQRequest(IQ iqRequest)
}
}
}

public int getEndpointCount()
{
return bridge.getConferences().stream()
.mapToInt(Conference::getEndpointCount)
.sum();
}

public Jid getBridgeJid()
{
return bridgeJid;
}

public int getConferenceCount()
{
return bridge.getConferences().size();
}
}
2 changes: 1 addition & 1 deletion src/test/java/mock/util/TestConference.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private void createJvbAndConference(String serverName, EntityBareJid roomName)
throw new RuntimeException(e);
}

mockBridge = new MockVideobridge(new MockXmppConnection(bridgeJid), bridgeJid);
mockBridge = new MockVideobridge(new MockXmppConnection(bridgeJid));
mockBridge.start();

harness.jicofoServices.getBridgeSelector().addJvbAddress(bridgeJid);
Expand Down
Loading

0 comments on commit ff32df2

Please sign in to comment.