re-structured replication tests a little to mimic initial load and replica registration process better; added failing test for bug 3249

This commit is contained in:
Axel Uhl committed 2015-08-20 16:53:57 +02:00
1 parent 43b4d37eae
commit 97aeb5efa1
2 files changed
+30 -4

No files matched your search

@@ -22,10 +22,12 @@ import com.sap.sailing.domain.base.Regatta;
import com.sap.sailing.domain.base.Waypoint;
import com.sap.sailing.domain.base.impl.BoatImpl;
import com.sap.sailing.domain.base.impl.CourseImpl;
import com.sap.sailing.domain.base.impl.MarkImpl;
import com.sap.sailing.domain.base.impl.PersonImpl;
import com.sap.sailing.domain.base.impl.RaceDefinitionImpl;
import com.sap.sailing.domain.base.impl.RegattaImpl;
import com.sap.sailing.domain.base.impl.TeamImpl;
import com.sap.sailing.domain.base.impl.WaypointImpl;
import com.sap.sailing.domain.common.RegattaName;
import com.sap.sailing.domain.common.RegattaNameAndRaceName;
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
@@ -124,14 +126,35 @@ public class TrackedRaceWithGPSFixStoreContentsReplicationTest extends AbstractS
return trackedRegatta;
}
/**
* See bugs 3249 and 3006. The hypothesis for these two bugs is that the TrackedRace, when replicated through the initial load,
* loses its listener relationship with the CourseImpl object because the course's listener collection is transient.
*/
@Test
public void testReplicatedTrackedRaceIsRegisteredAsCourseListener() throws InterruptedException {
final String HUMBA = "Humba";
final TrackedRace replicaTrackedRace = replica.getTrackedRace(raceIdentifier);
final Waypoint newMasterWaypoint = new WaypointImpl(new MarkImpl(HUMBA));
trackedRace.getRace().getCourse().addWaypoint(/* zeroBasedPosition */ 0, newMasterWaypoint);
assertEquals(newMasterWaypoint, trackedRace.getRace().getCourse().getWaypoints().iterator().next());
assertEquals(newMasterWaypoint, trackedRace.getRace().getCourse().getLegs().iterator().next().getFrom());
assertEquals(newMasterWaypoint, trackedRace.getTrackedLegs().iterator().next().getLeg().getFrom());
Thread.sleep(1000); // wait until course change has been replicated
assertEquals(HUMBA, replicaTrackedRace.getRace().getCourse().getWaypoints().iterator().next().getName());
assertEquals(HUMBA, replicaTrackedRace.getRace().getCourse().getLegs().iterator().next().getFrom().getName());
assertEquals(Util.size(trackedRace.getTrackedLegs()), Util.size(replicaTrackedRace.getTrackedLegs()));
}
@Test
public void testGPSFixReplication() throws InterruptedException {
final GPSFixMovingImpl fix = new GPSFixMovingImpl(new DegreePosition(1, 2), new MillisecondsTimePoint(12345),
new KnotSpeedWithBearingImpl(12, new DegreeBearingImpl(123)));
trackedRace.recordFix(competitor, fix);
Thread.sleep(1000);
TrackedRace replicaTrackedRace = replica.getTrackedRace(raceIdentifier);
Competitor replicaCompetitor = replicaTrackedRace.getRace().getCompetitors().iterator().next();
final TrackedRace replicaTrackedRace = replica.getTrackedRace(raceIdentifier);
final Competitor replicaCompetitor = replicaTrackedRace.getRace().getCompetitors().iterator().next();
assertNotNull(replicaCompetitor);
GPSFixTrack<Competitor, GPSFixMoving> competitorTrack = replicaTrackedRace.getTrack(replicaCompetitor);
competitorTrack.lockForRead();
@@ -115,7 +115,9 @@ public abstract class AbstractServerReplicationTestSetUp<ReplicableInterface ext
}
/**
* Calls {@link #persistenceSetUp(boolean)} first.
* Calls {@link #persistenceSetUp(boolean)} first. Doesn't {@link
* ReplicationServiceImpl#registerReplica(ReplicaDescriptor) register the replica} yet with the master.
*
* @param master
* if not <code>null</code>, the value will be used for {@link #master}; otherwise, a new racing event
* service will be created as master
@@ -146,7 +148,7 @@ public abstract class AbstractServerReplicationTestSetUp<ReplicableInterface ext
ReplicationInstancesManager rim = new ReplicationInstancesManager();
masterReplicator = new ReplicationServiceImpl(exchangeName, exchangeHost, 0, rim, new SingletonReplicablesProvider(this.master));
replicaDescriptor = new ReplicaDescriptor(InetAddress.getLocalHost(), serverUuid, "");
masterReplicator.registerReplica(replicaDescriptor);
// connect to exchange host and local server running as master
// master server and exchange host can be two different hosts
ReplicationServiceTestImpl<ReplicableInterface> replicaReplicator = new ReplicationServiceTestImpl<ReplicableInterface>(exchangeName, exchangeHost, rim, replicaDescriptor,
@@ -281,6 +283,7 @@ public abstract class AbstractServerReplicationTestSetUp<ReplicableInterface ext
} else if (request.contains("REGISTER")) {
final String uuid = UUID.randomUUID().toString();
registerReplicaUuidForMaster(uuid, masterDescriptor);
masterReplicationService.registerReplica(replicaDescriptor);
pw.print(uuid.getBytes());
} else if (request.contains("INITIAL_LOAD")) {
Channel channel = masterReplicationService.createMasterChannel();