-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
MySQL source: Add comprehensive data type test #3810
Conversation
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.
@DoNotPanicUA great work! Needs a bit of tuning.
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class DataTypeTest { |
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.
@DoNotPanicUA I suggest to change the name of the class. Basically it is not a test it self. Maybe something like test data wrapper, or smth like this would be better.
private static final String DEFAULT_INSERT_SQL = "INSERT INTO %1$s VALUES (%2$s, %3$s);"; | ||
|
||
private final String sourceType; | ||
private final Field.JsonSchemaPrimitive airbyteType; |
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.
@DoNotPanicUA please move jsonSchema to a separate class.
return airbyteType; | ||
} | ||
|
||
public String getName() { |
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.
@DoNotPanicUA please rename the method to getNameWithTestPrefix
return "test_" + testNumber + "_" + sourceType; | ||
} | ||
|
||
public String getCreateSQL() { |
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.
@DoNotPanicUA getCreateSQL-> getCreateSqlQuery
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.
same for others
* @param insertValue test value | ||
* @return builder | ||
*/ | ||
public DataTypeTestBuilder addInsertValue(String... insertValue) { |
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.
@DoNotPanicUA addInsertValue->addInsertValues
* @param createTablePatternSQL creation table sql pattern | ||
* @return builder | ||
*/ | ||
public DataTypeTestBuilder createTablePatternSQL(String createTablePatternSQL) { |
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.
@DoNotPanicUA due to JCC createTablePatternSQL->createTablePatternSql
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 everywhere
* @param testEnv - information about the test environment. | ||
* @throws Exception - can throw any exception, test framework will handle. | ||
*/ | ||
protected abstract void setup(TestDestinationEnv testEnv) throws Exception; |
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.
@DoNotPanicUA setup-> setupEnvironment , testEnv-> environment
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.
same for others
* | ||
* @param test comprehensive data type test | ||
*/ | ||
public void addDataTypeTest(DataTypeTest test) { |
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.
@DoNotPanicUA addDataTypeTest -> addDataTypeTestData
|
||
@Override | ||
protected void initTests() { | ||
addDataTypeTest( |
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.
@DoNotPanicUA in case of datasets are equal please move them to parent class
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.
they are slight different.
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.
Few changes :
- We should split the tests. Each data type should have its own individual tests
- There should be individual assertion for each data type. We should check the value is correct and not just that the value is present.
- We should try to build the tests in such a way that they can be extensible for different JDBC connectors in the future
final List<AirbyteMessage> recordMessages = allMessages.stream().filter(m -> m.getType() == Type.RECORD).collect(Collectors.toList()); | ||
|
||
recordMessages.forEach(msg -> LOGGER.debug(msg.toString())); | ||
assertFalse(recordMessages.isEmpty(), "Expected records from source"); |
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 think we should assert proper values instead of just values being present
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
…t class SourceTest + add test comprehensive for MySQL CDC + add javadocs
+ rename SourceTest to SourceAbstractTest + clean autogenerated imports + proper builder implementation according to lombok style.
+ move up `JsonSchemaPrimitive` enum from inner class level
+ make test builder without mandatory params (simple builder)
562841f
to
29b4763
Compare
…idation of outcome data.
Hi, @subodh1810. About your third point. I realize that big difference between JDBC sources and I don't see common data tests for all JDBC sources. So, I decided to create the builder which allows you to describe your tests for any JDBC source. All common operations I moved to the abstract class. |
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.
@DoNotPanicUA can you run the tests for jdbc sources using /test connector=source-mysql
.airbyteType(JsonSchemaPrimitive.STRING) | ||
.addInsertValues("null", "1", "127", "-128") | ||
// @TODO returns number instead of boolean | ||
// .addExpectedValues(null, "true", "false", "false") |
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 should be fixed by the PR #3890
/test connector=source-mysql
|
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 you create a follow up task to fix the TODOs. Also please run the tests for all the JDBC source connectors using the github command /test connector
to make sure the change would not cause any problem. Rest looks good.
/test connector=source-jdbc
|
/test connector=source-mssql
|
/test connector=source-oracle
|
/test connector=source-postgres
|
/test connector=source-redshift
|
/test connector=source-clickhouse
|
Issue: #3562
What
We are creating comprehensive integration tests for the MySQL source connector. Such a test guarantees that connector implementation is infallible even in cases when the source contains unexpected/extreme values.
In addition, we provide an abstract implementation of the comprehensive test
SourceComprehensiveTest
in order to simplify test creation.How
SourceAbstractTest.java
.Pre-merge Checklist
Recommended reading order
MySqlSourceComprehensiveTest.java
,CdcMySqlSourceComprehensiveTest.java
SourceComprehensiveTest.java
,SourceAbstractTest.java