-
Notifications
You must be signed in to change notification settings - Fork 428
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
Fix for random JUnit failures in framework tests #762
Conversation
# Resolved Conflicts: # src/test/java/com/microsoft/sqlserver/testframework/DBColumn.java
Codecov Report
@@ Coverage Diff @@
## dev #762 +/- ##
===========================================
- Coverage 48.17% 48.1% -0.08%
+ Complexity 2776 2772 -4
===========================================
Files 116 116
Lines 27854 27854
Branches 4636 4636
===========================================
- Hits 13418 13398 -20
- Misses 12215 12236 +21
+ Partials 2221 2220 -1
Continue to review full report at Codecov.
|
@@ -96,7 +96,11 @@ public void testISQLServerBulkRecord() throws SQLException { | |||
if (JDBCType.BIT == sqlType.getJdbctype()) { | |||
CurrentRow[j] = ((0 == ThreadLocalRandom.current().nextInt(2)) ? Boolean.FALSE : Boolean.TRUE); | |||
} else { | |||
CurrentRow[j] = sqlType.createdata(); | |||
if(j==0) { | |||
CurrentRow[j] = i+1; |
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.
Can't we just use SQL Server's auto-increment instead?
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.
Tried that, but it requires IDENTITY_INSERT to be enabled in order to make TVP and Bulk Copy work, with lots of test changes. I don't think it's worth the effort if we have to eventually enable IDENTITY_INSERT.
columnValues.add(i+1); | ||
} | ||
|
||
} |
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.
New line here.
/** | ||
* @return Escaped "columnName" | ||
*/ | ||
public String getEscapedColumnName() { |
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.
This will fail if column name contains ]
or [
.
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.
Our table columns in tests don't contain either, so it has no impact in our tests.
* Updates rowIndexes to all rows | ||
* @param totalRows number of rows | ||
*/ | ||
public void populateRowId(int totalRows) { |
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.
How are the rest of the columns populated? Can't we just fetch id
from the table too?
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.
This function and populateValues
above in the same file, populate data in 'columnValues' which are inserted iteratively in the table creation process. This is first time data insertion, so can't be fetched from anywhere.
Fixes random test failures due to unordered Select Queries in framework tests.
Although there are similar implementations in other tests which need to be fixed, this PR focuses on the tests that have been observed failing and are designed using framework package.