Skip to content

Commit b2fb8fc

Browse files
authored
Fix connection name in Multiserver configs in YAML-tests (#3301)
While testing in YAML framework, I realized that a multiserver config like `MultiServer (4.0.575.0 then Embedded)` is actually connecting to 4.0.575.0 external server and JDBC in-process !current_version (instead of Embedded). This PR fixes this naming so as to avoid ambiguity. Also, `MultiServerConnection`s, while alternating their connections, logs operations like `Sending operation createStatement to connection 0` meaning, it is sending the current request to first (default, index 0) connection which is not super clear when debugging issues related to compatibility. This PR changes that log to explicitly specify the connection name.
1 parent b9a705b commit b2fb8fc

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

yaml-tests/src/main/java/com/apple/foundationdb/relational/yamltests/SimpleYamlConnection.java

+12
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,17 @@ public class SimpleYamlConnection implements YamlConnection {
4141
private final RelationalConnection underlying;
4242
@Nonnull
4343
private final List<SemanticVersion> versions;
44+
@Nonnull
45+
private final String connectionLabel;
4446

4547
public SimpleYamlConnection(@Nonnull Connection connection, @Nonnull SemanticVersion version) throws SQLException {
48+
this(connection, version, version.toString());
49+
}
50+
51+
public SimpleYamlConnection(@Nonnull Connection connection, @Nonnull SemanticVersion version, @Nonnull String connectionLabel) throws SQLException {
4652
underlying = connection.unwrap(RelationalConnection.class);
4753
this.versions = List.of(version);
54+
this.connectionLabel = connectionLabel;
4855
}
4956

5057
@Override
@@ -94,4 +101,9 @@ public List<SemanticVersion> getVersions() {
94101
public SemanticVersion getInitialVersion() {
95102
return versions.get(0);
96103
}
104+
105+
@Override
106+
public String toString() {
107+
return connectionLabel;
108+
}
97109
}

yaml-tests/src/main/java/com/apple/foundationdb/relational/yamltests/configs/JDBCMultiServerConfig.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ public YamlConnectionFactory createConnectionFactory() {
6464
@Override
6565
public String toString() {
6666
if (initialConnection == 0) {
67-
return "MultiServer (Embedded then " + externalServer.getVersion() + ")";
67+
return "MultiServer (" + super.toString() + " then " + externalServer.getVersion() + ")";
6868
} else {
69-
return "MultiServer (" + externalServer.getVersion() + " then Embedded)";
69+
return "MultiServer (" + externalServer.getVersion() + " then " + super.toString() + ")";
7070
}
7171
}
7272
}

yaml-tests/src/main/java/com/apple/foundationdb/relational/yamltests/connectionfactory/EmbeddedYamlConnectionFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
public class EmbeddedYamlConnectionFactory implements YamlConnectionFactory {
3535
@Override
3636
public YamlConnection getNewConnection(@Nonnull URI connectPath) throws SQLException {
37-
return new SimpleYamlConnection(DriverManager.getConnection(connectPath.toString()), SemanticVersion.current());
37+
return new SimpleYamlConnection(DriverManager.getConnection(connectPath.toString()), SemanticVersion.current(), "Embedded");
3838
}
3939

4040
@Override

yaml-tests/src/main/java/com/apple/foundationdb/relational/yamltests/connectionfactory/JDBCInProcessYamlConnectionFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public YamlConnection getNewConnection(@Nonnull URI connectPath) throws SQLExcep
4949
URI connectPathPlusServerName = JDBCURI.addQueryParameter(connectPath, JDBCURI.INPROCESS_URI_QUERY_SERVERNAME_KEY, server.getServerName());
5050
String uriStr = connectPathPlusServerName.toString().replaceFirst("embed:", "relational://");
5151
LOG.info("Rewrote {} as {}", connectPath, uriStr);
52-
return new SimpleYamlConnection(DriverManager.getConnection(uriStr), SemanticVersion.current());
52+
return new SimpleYamlConnection(DriverManager.getConnection(uriStr), SemanticVersion.current(), "JDBC In-Process");
5353
}
5454

5555
@Override

yaml-tests/src/main/java/com/apple/foundationdb/relational/yamltests/connectionfactory/MultiServerConnectionFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ private YamlConnection getCurrentConnection(boolean advance, String op) {
227227
if (connectionSelectionPolicy == ConnectionSelectionPolicy.ALTERNATE) {
228228
YamlConnection result = underlyingConnections.get(currentConnectionSelector);
229229
if (logger.isInfoEnabled()) {
230-
logger.info("Sending operation {} to connection {}", op, currentConnectionSelector);
230+
logger.info("Sending operation {} to connection: {}", op, result.toString());
231231
}
232232
if (advance) {
233233
currentConnectionSelector = (currentConnectionSelector + 1) % underlyingConnections.size();

0 commit comments

Comments
 (0)