-
Notifications
You must be signed in to change notification settings - Fork 858
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
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 <[email protected]>
.../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 <[email protected]>
It is look like
failed by Address already in use. It is not break by jdbc test. the jdc case is all memory server |
.../test/java/io/opentelemetry/javaagent/instrumentation/jdbc/test/JdbcInstrumentationTest.java
Outdated
Show resolved
Hide resolved
@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
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.
junit can not do the same ability,like getCannicalname。
Junit is a tree struct, DisplayName for the method, parametertest have each name。
I do not found the usage in other tests in the projects。
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 don't think you understood. When you run the groovy tests in intellij then the main test is named basic statement with #connection.getClass().getCanonicalName() on #system generates spans
when you expand it then you see the test with parameters. They are named basic statement with org.h2.jdbc.JdbcConnection on h2 generates spans
. When you run the junit test the main test name is what you set in display name and when you expand it you'll just see the parameters. That is why I believe that using the @DisplayName
they way you do does not make sense. There is no magic interpolation like in spock. You might either not add @DisplayName
at all or change it to @DisplayName("basic statement 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 will remove @DisplayName
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.
done
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.
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.
done
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.
as far as I can tell you only fixed it in some places
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.
let me see
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.
fixed
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);
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.
junit will autoclose connection on method parameter
I only add
cleanup.deferCleanup(statement);
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.
That is fine.
To me it feels a bit odd that there is a bunch of tests where connection is passes as parameter and still use cleanup.deferCleanup(connection);
and there is one test that does not do it. Perhaps remove it from other tests also where it is not needed?
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.
done
relate to #7195