Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor MySQLBinlogClientTest #32617

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,11 @@ class MySQLBinlogClientTest {

@SuppressWarnings("unchecked")
@BeforeEach
void setUp() throws InterruptedException {
void setUp() {
client = new MySQLBinlogClient(new ConnectInfo(1, "host", 3306, "username", "password"), false);
when(channel.pipeline()).thenReturn(pipeline);
when(channel.isOpen()).thenReturn(true);
when(channel.close()).thenReturn(channelFuture);
when(channelFuture.sync()).thenAnswer(invocation -> {
when(channel.isOpen()).thenReturn(false);
return null;
});
when(channel.localAddress()).thenReturn(new InetSocketAddress("host", 3306));
when(channel.attr(MySQLConstants.SEQUENCE_ID_ATTRIBUTE_KEY)).thenReturn(mock(Attribute.class));
when(channel.attr(MySQLConstants.SEQUENCE_ID_ATTRIBUTE_KEY).get()).thenReturn(new AtomicInteger());
Expand Down Expand Up @@ -152,7 +148,7 @@ private void mockChannelResponseInThread(final Object response) {
}

@Test
void assertPollFailed() throws ReflectiveOperationException {
void assertPollOnNotRunning() throws ReflectiveOperationException {
Plugins.getMemberAccessor().set(MySQLBinlogClient.class.getDeclaredField("channel"), client, channel);
Plugins.getMemberAccessor().set(MySQLBinlogClient.class.getDeclaredField("running"), client, false);
assertThat(client.poll(), is(Collections.emptyList()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ public interface MetaDataManagerPersistService {
*
* @param databaseName database name
* @param ruleName rule name
* @throws SQLException SQL exception
*/
void removeRuleConfiguration(String databaseName, String ruleName);
void removeRuleConfiguration(String databaseName, String ruleName) throws SQLException;

/**
* Alter global rule configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.github.dockerjava.api.model.ContainerNetwork;
import com.google.common.base.Strings;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.test.e2e.env.container.atomic.governance.GovernanceContainer;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.Network;
Expand All @@ -37,6 +38,7 @@
/**
* IT containers.
*/
@Slf4j
public final class ITContainers implements Startable {

private final String scenario;
Expand Down Expand Up @@ -101,6 +103,7 @@ public void start() {
}

private void start(final DockerITContainer dockerITContainer) {
log.info("Starting container {}...", dockerITContainer.getName());
dockerITContainer.start();
dockerITContainer.getNetworkAliases().forEach(each -> DnsCacheManipulator.setDnsCache(each,
dockerITContainer.getContainerInfo().getNetworkSettings().getNetworks().values().stream().map(ContainerNetwork::getIpAddress).collect(Collectors.toList()).toArray(new String[0])));
Expand Down