Skip to content

Commit

Permalink
Got the same IT twice. Removing one of them
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Needham committed Jun 29, 2016
1 parent ea8fd89 commit ce48cad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 87 deletions.
Expand Up @@ -47,26 +47,31 @@
public class ClusterOverviewIT public class ClusterOverviewIT
{ {
@Rule @Rule
public final ClusterRule clusterRule = new ClusterRule( getClass() ) public final ClusterRule clusterRule = new ClusterRule( getClass() ).withNumberOfCoreServers( 3 );
.withNumberOfCoreServers( 3 );


@Test @Test
public void shouldDiscoverCoreClusterMembers() throws Exception public void shouldDiscoverCoreClusterMembers() throws Exception
{ {
// when // when
Cluster cluster = clusterRule.withNumberOfEdgeServers( 0 ).startCluster(); Cluster cluster = clusterRule.withNumberOfEdgeServers( 1 ).startCluster();


// then // then

List<Object[]> overview; List<Object[]> overview;
for ( int i = 0; i < 3; i++ ) for ( int i = 0; i < 3; i++ )
{ {
overview = clusterOverview( cluster.getCoreServerById( i ) ); overview = clusterOverview( cluster.getCoreServerById( i ) );


assertThat( overview, containsLeader() ); assertThat( overview, containsRole( "leader", 1 ) );
assertThat( overview, containsRole( "follower", 2 ) );
assertThat( overview, containsRole( "read_replica", 1 ) );

// core
assertThat( overview, containsAddress( "127.0.0.1:8000" ) ); assertThat( overview, containsAddress( "127.0.0.1:8000" ) );
assertThat( overview, containsAddress( "127.0.0.1:8001" ) ); assertThat( overview, containsAddress( "127.0.0.1:8001" ) );
assertThat( overview, containsAddress( "127.0.0.1:8002" ) ); assertThat( overview, containsAddress( "127.0.0.1:8002" ) );

// read replicas
assertThat( overview, containsAddress( "127.0.0.1:9000" ) );
} }
} }


Expand Down Expand Up @@ -96,28 +101,30 @@ public void describeTo( Description description )
}; };
} }


private Matcher<? super List<Object[]>> containsLeader() private Matcher<? super List<Object[]>> containsRole(String role, int expectedRoleCount)
{ {
return new TypeSafeMatcher<List<Object[]>>() return new TypeSafeMatcher<List<Object[]>>()
{ {
@Override @Override
public boolean matchesSafely( List<Object[]> overview ) public boolean matchesSafely( List<Object[]> overview )
{ {
int numberOfMachinesForRole = 0;

for ( Object[] row : overview ) for ( Object[] row : overview )
{ {
if ( row[2].toString().equals( "leader" ) ) if ( row[2].toString().equals( role ) )
{ {
return true; numberOfMachinesForRole++;
} }
} }


return false; return numberOfMachinesForRole == expectedRoleCount;
} }


@Override @Override
public void describeTo( Description description ) public void describeTo( Description description )
{ {
description.appendText( "Expected to find leader in the cluster but didn't" ); description.appendText( "Expected to find " + role + " in the cluster but didn't" );
} }
}; };
} }
Expand Down

This file was deleted.

0 comments on commit ce48cad

Please sign in to comment.