-
Notifications
You must be signed in to change notification settings - Fork 828
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
convert instrument jdbc test from groovy to java #12132
base: main
Are you sure you want to change the base?
Conversation
...n/jdbc/testing/src/main/java/io/opentelemetry/instrumentation/jdbc/TestDatabaseMetaData.java
Outdated
Show resolved
Hide resolved
...ntation/jdbc/testing/src/main/java/io/opentelemetry/instrumentation/jdbc/TestConnection.java
Outdated
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Jay DeLuca <jaydeluca4@gmail.com>
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Show resolved
Hide resolved
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Jay DeLuca <jaydeluca4@gmail.com>
It is look like
failed by Address already in use. It is not break by jdbc test. the jdc case is all memory server |
dbName = "jdbcUnitTest"; | ||
dbNameLower = dbName.toLowerCase(Locale.ROOT); | ||
jdbcUrls = | ||
ImmutableMap.of( | ||
"h2", "jdbc:h2:mem:" + dbName, | ||
"derby", "jdbc:derby:memory:" + dbName, | ||
"hsqldb", "jdbc:hsqldb:mem:" + dbName); | ||
|
||
jdbcDriverClassNames = | ||
ImmutableMap.of( | ||
"h2", "org.h2.Driver", | ||
"derby", "org.apache.derby.jdbc.EmbeddedDriver", | ||
"hsqldb", "org.hsqldb.jdbc.JDBCDriver"); | ||
|
||
jdbcUserNames = new HashMap<>(); | ||
jdbcUserNames.put("derby", "APP"); | ||
jdbcUserNames.put("h2", null); | ||
jdbcUserNames.put("hsqldb", "SA"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could have initialized these in the field declaration as the groovy test did
@DisplayName( | ||
"basic statement with #connection.getClass().getCanonicalName() on #system generates spans") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the value of this. Spock is able to replace #connection.getClass().getCanonicalName()
and #system
with actual parameter values so you'd have a test named prepared statement execute on h2 with org.h2.jdbc.JdbcConnection generates a span
with junit this does not happen
satisfies( | ||
DbIncubatingAttributes.DB_USER, | ||
val -> | ||
val.satisfiesAnyOf( | ||
v -> assertThat(v).isEqualTo(username), | ||
v -> assertThat(v).isNull())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the original groovy test uses
if (username != null) {
"$DbIncubatingAttributes.DB_USER" username
}
If username is given verify that this attribute exists, your assertion just makes user name optional.
statement.close(); | ||
connection.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other tests use
cleanup.deferCleanup(statement);
cleanup.deferCleanup(connection);
@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation | ||
AttributeKey<String> getDbConnectionStringKey() { | ||
return DbIncubatingAttributes.DB_CONNECTION_STRING; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps instead of a method it would be better to define this as a field
relate to #7195