Skip to content
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

SAT: add threshold_days incremental test option #12715

Merged
merged 9 commits into from
May 11, 2022

Conversation

pedroslopez
Copy link
Contributor

@pedroslopez pedroslopez commented May 9, 2022

What

Support running incremental source acceptance tests for sources that use a lookback window to include records older than the requested state cursor.

close #12467

How

  • Adds threshold_days option for incremental tests to control the amount of days to allow before the state cursor
    • If the option is used for cursor values that are not dates or strings parseable by dateutil.parser.parse, a ParserError will be raised.
  • Adds tests for the two sequential reads SAT case

This has been confirmed to allow enabling the incremental tests for the Google Analytics connector.

Recommended reading order

  1. source_acceptance_test/config.py
  2. source_acceptance_test/test_incremental.py
  3. unit_tests/test_incremental.py

Tests

Unit
 unit_tests/test_asserts.py::test_verify_records_schema ✓                                                                                                                                                                       1% ▏         
 unit_tests/test_asserts.py::test_validate_records_format[record0-configured_catalog0-False] ✓                                                                                                                                  1% ▎         
 unit_tests/test_asserts.py::test_validate_records_format[record1-configured_catalog1-False] ✓                                                                                                                                  2% ▎         
 unit_tests/test_asserts.py::test_validate_records_format[record2-configured_catalog2-False] ✓                                                                                                                                  2% ▎         
 unit_tests/test_asserts.py::test_validate_records_format[record3-configured_catalog3-False] ✓                                                                                                                                  3% ▍         
 unit_tests/test_asserts.py::test_validate_records_format[record4-configured_catalog4-True] ✓                                                                                                                                   3% ▍         
 unit_tests/test_asserts.py::test_validate_records_format[record5-configured_catalog5-False] ✓                                                                                                                                  4% ▌         
 unit_tests/test_asserts.py::test_validate_records_format[record6-configured_catalog6-True] ✓                                                                                                                                   5% ▌         
 unit_tests/test_asserts.py::test_validate_records_format[record7-configured_catalog7-False] ✓                                                                                                                                  5% ▌         
 unit_tests/test_asserts.py::test_validate_records_format[record8-configured_catalog8-False] ✓                                                                                                                                  6% ▋         
 unit_tests/test_asserts.py::test_validate_records_format[record9-configured_catalog9-True] ✓                                                                                                                                   6% ▋         
 unit_tests/test_asserts.py::test_validate_records_format[record10-configured_catalog10-True] ✓                                                                                                                                 7% ▋         
 unit_tests/test_asserts.py::test_validate_records_format[record11-configured_catalog11-True] ✓                                                                                                                                 7% ▊         
 unit_tests/test_asserts.py::test_validate_records_format[record12-configured_catalog12-True] ✓                                                                                                                                 8% ▊         
 unit_tests/test_asserts.py::test_validate_records_format[record13-configured_catalog13-False] ✓                                                                                                                                8% ▉         
 unit_tests/test_asserts.py::test_validate_records_format[record14-configured_catalog14-False] ✓                                                                                                                                9% ▉         
 unit_tests/test_asserts.py::test_validate_records_format[record15-configured_catalog15-False] ✓                                                                                                                               10% ▉         
 unit_tests/test_asserts.py::test_validate_records_format[record16-configured_catalog16-True] ✓                                                                                                                                10% █         
 unit_tests/test_asserts.py::test_validate_records_format[record17-configured_catalog17-False] ✓                                                                                                                               11% █▏        
 unit_tests/test_asserts.py::test_validate_records_format[record18-configured_catalog18-True] ✓                                                                                                                                11% █▎        
 unit_tests/test_asserts.py::test_validate_records_format[record19-configured_catalog19-True] ✓                                                                                                                                12% █▎        
 unit_tests/test_asserts.py::test_validate_records_format[record20-configured_catalog20-True] ✓                                                                                                                                12% █▎        
 unit_tests/test_asserts.py::test_validate_records_format[record21-configured_catalog21-False] ✓                                                                                                                               13% █▍        
 unit_tests/test_asserts.py::test_validate_records_format[record22-configured_catalog22-False] ✓                                                                                                                               14% █▍        
 unit_tests/test_asserts.py::test_validate_records_format[record23-configured_catalog23-True] ✓                                                                                                                                14% █▌        
 unit_tests/test_asserts.py::test_validate_records_format[record24-configured_catalog24-True] ✓                                                                                                                                15% █▌        
 unit_tests/test_asserts.py::test_validate_records_format[record25-configured_catalog25-False] ✓                                                                                                                               15% █▌        
 unit_tests/test_asserts.py::test_validate_records_format[record26-configured_catalog26-False] ✓                                                                                                                               16% █▋        
 unit_tests/test_asserts.py::test_validate_records_format[record27-configured_catalog27-True] ✓                                                                                                                                16% █▋        
 unit_tests/test_asserts.py::test_validate_records_format[record28-configured_catalog28-False] ✓                                                                                                                               17% █▊        
 unit_tests/test_asserts.py::test_validate_records_format[record29-configured_catalog29-True] ✓                                                                                                                                18% █▊        
 unit_tests/test_asserts.py::test_validate_records_format[record30-configured_catalog30-True] ✓                                                                                                                                18% █▊        
 unit_tests/test_asserts.py::test_validate_records_format[record31-configured_catalog31-True] ✓                                                                                                                                19% █▉        
 unit_tests/test_core.py::test_discovery[schema0-cursors0-True] ✓                                                                                                                                                              19% █▉        
 unit_tests/test_core.py::test_discovery[schema1-cursors1-False] ✓                                                                                                                                                             20% ██        
 unit_tests/test_core.py::test_discovery[schema2-cursors2-True] ✓                                                                                                                                                              20% ██        
 unit_tests/test_core.py::test_discovery[schema3-cursors3-True] ✓                                                                                                                                                              21% ██▏       
 unit_tests/test_core.py::test_discovery[schema4-cursors4-False] ✓                                                                                                                                                             21% ██▎       
 unit_tests/test_core.py::test_discovery[schema5-cursors5-True] ✓                                                                                                                                                              22% ██▎       
 unit_tests/test_core.py::test_ref_in_discovery_schemas[schema0-False] ✓                                                                                                                                                       23% ██▍       
 unit_tests/test_core.py::test_ref_in_discovery_schemas[schema1-True] ✓                                                                                                                                                        23% ██▍       
 unit_tests/test_core.py::test_ref_in_discovery_schemas[schema2-True] ✓                                                                                                                                                        24% ██▍       
 unit_tests/test_core.py::test_ref_in_discovery_schemas[schema3-True] ✓                                                                                                                                                        24% ██▌       
 unit_tests/test_core.py::test_ref_in_discovery_schemas[schema4-False] ✓                                                                                                                                                       25% ██▌       
 unit_tests/test_core.py::test_ref_in_discovery_schemas[schema5-True] ✓                                                                                                                                                        25% ██▋       
 unit_tests/test_core.py::test_ref_in_discovery_schemas[schema6-True] ✓                                                                                                                                                        26% ██▋       
 unit_tests/test_core.py::test_keyword_in_discovery_schemas[schema0-allOf-False] ✓                                                                                                                                             27% ██▋       
 unit_tests/test_core.py::test_keyword_in_discovery_schemas[schema1-allOf-True] ✓                                                                                                                                              27% ██▊       
 unit_tests/test_core.py::test_keyword_in_discovery_schemas[schema2-allOf-False] ✓                                                                                                                                             28% ██▊       
 unit_tests/test_core.py::test_keyword_in_discovery_schemas[schema3-allOf-True] ✓                                                                                                                                              28% ██▉       
 unit_tests/test_core.py::test_keyword_in_discovery_schemas[schema4-allOf-True] ✓                                                                                                                                              29% ██▉       
 unit_tests/test_core.py::test_keyword_in_discovery_schemas[schema5-allOf-True] ✓                                                                                                                                              29% ██▉       
 unit_tests/test_core.py::test_keyword_in_discovery_schemas[schema6-not-True] ✓                                                                                                                                                30% ███       
 unit_tests/test_core.py::test_keyword_in_discovery_schemas[schema7-not-False] ✓                                                                                                                                               31% ███▏      
 unit_tests/test_core.py::test_keyword_in_discovery_schemas[schema8-not-True] ✓                                                                                                                                                31% ███▎      
 unit_tests/test_core.py::test_read[schema0-record0-False] ✓                                                                                                                                                                   32% ███▎      
 unit_tests/test_core.py::test_read[schema1-record1-False] ✓                                                                                                                                                                   32% ███▎      
 unit_tests/test_core.py::test_read[schema2-record2-True] ✓                                                                                                                                                                    33% ███▍      
 unit_tests/test_core.py::test_read[schema3-record3-False] ✓                                                                                                                                                                   33% ███▍      
 unit_tests/test_core.py::test_read[schema4-record4-True] ✓                                                                                                                                                                    34% ███▍      
 unit_tests/test_core.py::test_read[schema5-record5-False] ✓                                                                                                                                                                   34% ███▌      
 unit_tests/test_core.py::test_validate_field_appears_at_least_once[records0-configured_catalog0-] ✓                                                                                                                           35% ███▌      
 unit_tests/test_core.py::test_validate_field_appears_at_least_once[records1-configured_catalog1-`test1` stream has `\\['/f2'\\]`] ✓                                                                                           36% ███▋      
 unit_tests/test_core.py::test_validate_field_appears_at_least_once[records2-configured_catalog2-] ✓                                                                                                                           36% ███▋      
 unit_tests/test_core.py::test_validate_field_appears_at_least_once[records3-configured_catalog3-] ✓                                                                                                                           37% ███▋      
 unit_tests/test_core.py::test_validate_field_appears_at_least_once[records4-configured_catalog4-`test1` stream has `\\['/f3/\\[\\]'\\]`] ✓                                                                                    37% ███▊      
 unit_tests/test_core.py::test_validate_field_appears_at_least_once[records5-configured_catalog5-] ✓                                                                                                                           38% ███▊      
 unit_tests/test_core.py::test_validate_field_appears_at_least_once[records6-configured_catalog6-`test1` stream has `\\['/f3/f5/\\[\\]'\\]`] ✓                                                                                 38% ███▉      
 unit_tests/test_core.py::test_validate_field_appears_at_least_once[records7-configured_catalog7-`test1` stream has `\\['/f3/f5/\\[\\]/f6', '/f3/f5/\\[\\]/f7/\\[\\]'\\]`] ✓                                                   39% ███▉      
 unit_tests/test_core.py::test_validate_field_appears_at_least_once[records8-configured_catalog8-] ✓                                                                                                                           40% ███▉      
 unit_tests/test_core.py::test_validate_field_appears_at_least_once[records9-configured_catalog9-(`test1` stream has `\\['/f3/f5/\\[\\]/f7/\\[\\]']`)|(`test2` `\\['/f8'\\]`)] ✓                                               40% ████      
 unit_tests/test_core.py::test_validate_field_appears_at_least_once[records10-configured_catalog10-] ✓                                                                                                                         41% ████▏     
 unit_tests/test_core.py::test_validate_field_appears_at_least_once[records11-configured_catalog11-] ✓                                                                                                                         41% ████▎     
 unit_tests/test_core.py::test_validate_field_appears_at_least_once[records12-configured_catalog12-`test1` stream has `\\['/f3\\(0\\)/f4', '/f3\\(1\\)/f5\\(0\\)/f6', '/f3\\(1\\)/f5\\(1\\)/f7'\\]`] ✓                         42% ████▎     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[record_value0-state_value0-0-True] ✓                                                                                                                       42% ████▎     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[record_value1-state_value1-0-False] ✓                                                                                                                      43% ████▍     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[record_value2-state_value2-1-True] ✓                                                                                                                       44% ████▍     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[record_value3-state_value3-0-True] ✓                                                                                                                       44% ████▌     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[record_value4-state_value4-0-False] ✓                                                                                                                      45% ████▌     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[record_value5-state_value5-1-True] ✓                                                                                                                       45% ████▌     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[2020-10-10-2020-10-09-0-True] ✓                                                                                                                            46% ████▋     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[2020-10-10-2020-10-11-0-False] ✓                                                                                                                           46% ████▋     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[2020-10-10-2020-10-11-1-True] ✓                                                                                                                            47% ████▊     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[1602288000000-1602201600000-0-True] ✓                                                                                                                      47% ████▊     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[1602288000000-1602374400000-0-False] ✓                                                                                                                     48% ████▊     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[1602288000000-1602374400000-1-True] ✓                                                                                                                      49% ████▉     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[1602288000-1602201600-0-True] ✓                                                                                                                            49% ████▉     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[1602288000-1602374400-0-False] ✓                                                                                                                           50% █████     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[1602288000-1602374400-1-True] ✓                                                                                                                            50% █████     
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[aaa-bbb-0-False] ✓                                                                                                                                         51% █████▏    
 unit_tests/test_incremental.py::test_compare_cursor_with_threshold[bbb-aaa-0-True] ✓                                                                                                                                          51% █████▎    
 unit_tests/test_incremental.py::test_incremental_two_sequential_reads[records10-records20-2020-01-02-0-None-date] ✓                                                                                                           52% █████▎    
 unit_tests/test_incremental.py::test_incremental_two_sequential_reads[records10-records20-2020-01-02-0-None-string] ✓                                                                                                         53% █████▍    
 unit_tests/test_incremental.py::test_incremental_two_sequential_reads[records11-records21-2020-01-02-0-First incremental sync should produce records younger-date] ✓                                                          53% █████▍    
 unit_tests/test_incremental.py::test_incremental_two_sequential_reads[records11-records21-2020-01-02-0-First incremental sync should produce records younger-string] ✓                                                        54% █████▍    
 unit_tests/test_incremental.py::test_incremental_two_sequential_reads[records12-records22-2020-01-02-0-None-date] ✓                                                                                                           54% █████▌    
 unit_tests/test_incremental.py::test_incremental_two_sequential_reads[records12-records22-2020-01-02-0-None-string] ✓                                                                                                         55% █████▌    
 unit_tests/test_incremental.py::test_incremental_two_sequential_reads[records13-records23-2020-01-02-0-Second incremental sync should produce records older-date] ✓                                                           55% █████▋    
 unit_tests/test_incremental.py::test_incremental_two_sequential_reads[records13-records23-2020-01-02-0-Second incremental sync should produce records older-string] ✓                                                         56% █████▋    
 unit_tests/test_incremental.py::test_incremental_two_sequential_reads[records14-records24-2020-01-03-2-None-date] ✓                                                                                                           56% █████▋    
 unit_tests/test_incremental.py::test_incremental_two_sequential_reads[records14-records24-2020-01-03-2-None-string] ✓                                                                                                         57% █████▊    
 unit_tests/test_incremental.py::test_incremental_two_sequential_reads[records15-records25-2020-01-02-2-First incremental sync should produce records younger-date] ✓                                                          58% █████▊    
 unit_tests/test_incremental.py::test_incremental_two_sequential_reads[records15-records25-2020-01-02-2-First incremental sync should produce records younger-string] ✓                                                        58% █████▊    
 unit_tests/test_incremental.py::test_incremental_two_sequential_reads[records16-records26-2020-01-06-3-Second incremental sync should produce records older-date] ✓                                                           59% █████▉    
 unit_tests/test_incremental.py::test_incremental_two_sequential_reads[records16-records26-2020-01-06-3-Second incremental sync should produce records older-string] ✓                                                         59% █████▉    
 unit_tests/test_json_schema_helper.py::test_simple_path ✓                                                                                                                                                                     60% ██████    
 unit_tests/test_json_schema_helper.py::test_nested_path ✓                                                                                                                                                                     60% ██████▏   
 unit_tests/test_json_schema_helper.py::test_nested_path_unknown ✓                                                                                                                                                             61% ██████▏   
 unit_tests/test_json_schema_helper.py::test_absolute_path ✓                                                                                                                                                                   62% ██████▎   
 unit_tests/test_json_schema_helper.py::test_json_schema_helper_pydantic_generated ✓                                                                                                                                           62% ██████▎   
 unit_tests/test_json_schema_helper.py::test_get_object_strucutre[object0-pathes0] ✓                                                                                                                                           63% ██████▍   
 unit_tests/test_json_schema_helper.py::test_get_object_strucutre[object1-pathes1] ✓                                                                                                                                           63% ██████▍   
 unit_tests/test_json_schema_helper.py::test_get_object_strucutre[object2-pathes2] ✓                                                                                                                                           64% ██████▍   
 unit_tests/test_json_schema_helper.py::test_get_object_strucutre[object3-pathes3] ✓                                                                                                                                           64% ██████▌   
 unit_tests/test_json_schema_helper.py::test_get_object_strucutre[object4-pathes4] ✓                                                                                                                                           65% ██████▌   
 unit_tests/test_json_schema_helper.py::test_get_object_strucutre[object5-pathes5] ✓                                                                                                                                           66% ██████▋   
 unit_tests/test_json_schema_helper.py::test_get_object_strucutre[object6-pathes6] ✓                                                                                                                                           66% ██████▋   
 unit_tests/test_json_schema_helper.py::test_get_expected_schema_structure[schema0-pathes0] ✓                                                                                                                                  67% ██████▋   
 unit_tests/test_json_schema_helper.py::test_get_expected_schema_structure[schema1-pathes1] ✓                                                                                                                                  67% ██████▊   
 unit_tests/test_json_schema_helper.py::test_get_expected_schema_structure[schema2-pathes2] ✓                                                                                                                                  68% ██████▊   
 unit_tests/test_json_schema_helper.py::test_get_expected_schema_structure[schema3-pathes3] ✓                                                                                                                                  68% ██████▉   
 unit_tests/test_json_schema_helper.py::test_get_expected_schema_structure[schema4-pathes4] ✓                                                                                                                                  69% ██████▉   
 unit_tests/test_json_schema_helper.py::test_get_expected_schema_structure[schema5-pathes5] ✓                                                                                                                                  69% ██████▉   
 unit_tests/test_json_schema_helper.py::test_get_expected_schema_structure[schema6-pathes6] ✓                                                                                                                                  70% ███████   
 unit_tests/test_json_schema_helper.py::test_get_expected_schema_structure[schema7-pathes7] ✓                                                                                                                                  71% ███████▏  
 unit_tests/test_json_schema_helper.py::test_get_expected_schema_structure[schema8-pathes8] ✓                                                                                                                                  71% ███████▎  
 unit_tests/test_json_schema_helper.py::test_get_expected_schema_structure[schema9-pathes9] ✓                                                                                                                                  72% ███████▎  
 unit_tests/test_spec.py::test_ref_in_spec_schemas[connector_spec0-True] ✓                                                                                                                                                     72% ███████▎  
 unit_tests/test_spec.py::test_ref_in_spec_schemas[connector_spec1-True] ✓                                                                                                                                                     73% ███████▍  
 unit_tests/test_spec.py::test_ref_in_spec_schemas[connector_spec2-True] ✓                                                                                                                                                     73% ███████▍  
 unit_tests/test_spec.py::test_ref_in_spec_schemas[connector_spec3-True] ✓                                                                                                                                                     74% ███████▌  
 unit_tests/test_spec.py::test_ref_in_spec_schemas[connector_spec4-False] ✓                                                                                                                                                    75% ███████▌  
 unit_tests/test_spec.py::test_ref_in_spec_schemas[connector_spec5-False] ✓                                                                                                                                                    75% ███████▌  
 unit_tests/test_spec.py::test_ref_in_spec_schemas[connector_spec6-True] ✓                                                                                                                                                     76% ███████▋  
 unit_tests/test_spec.py::test_ref_in_spec_schemas[connector_spec7-True] ✓                                                                                                                                                     76% ███████▋  
 unit_tests/test_spec.py::test_ref_in_spec_schemas[connector_spec8-True] ✓                                                                                                                                                     77% ███████▊  
 unit_tests/test_spec.py::test_ref_in_spec_schemas[connector_spec9-False] ✓                                                                                                                                                    77% ███████▊  
 unit_tests/test_spec.py::test_ref_in_spec_schemas[connector_spec10-True] ✓                                                                                                                                                    78% ███████▊  
 unit_tests/test_spec.py::test_oneof_usage[all_good] ✓                                                                                                                                                                         79% ███████▉  
 unit_tests/test_spec.py::test_oneof_usage[top_level_node_is_not_of_object_type] ✓                                                                                                                                             79% ███████▉  
 unit_tests/test_spec.py::test_oneof_usage[all_oneof_options_should_have_same_constant_attribute] ✓                                                                                                                            80% ████████  
 unit_tests/test_spec.py::test_oneof_usage[one_of_item_is_not_of_type_object] ✓                                                                                                                                                80% ████████  
 unit_tests/test_spec.py::test_oneof_usage[no_common_property_for_all_oneof_subobjects] ✓                                                                                                                                      81% ████████▏ 
 unit_tests/test_spec.py::test_oneof_usage[two_common_properties_with_const_keyword] ✓                                                                                                                                         81% ████████▎ 
 unit_tests/test_spec.py::test_oneof_usage[default_keyword_in_common_property] ✓                                                                                                                                               82% ████████▎ 
 unit_tests/test_spec.py::test_validate_oauth_flow[connector_spec0-] ✓                                                                                                                                                         82% ████████▎ 
 unit_tests/test_spec.py::test_validate_oauth_flow[connector_spec1-Specified oauth fields are missed from spec schema:] ✓                                                                                                      83% ████████▍ 
 unit_tests/test_spec.py::test_validate_oauth_flow[connector_spec2-] ✓                                                                                                                                                         84% ████████▍ 
 unit_tests/test_spec.py::test_validate_oauth_flow[connector_spec3-Specified oauth fields are missed from spec schema:] ✓                                                                                                      84% ████████▌ 
 unit_tests/test_spec.py::test_validate_oauth_flow[connector_spec4-] ✓                                                                                                                                                         85% ████████▌ 
 unit_tests/test_spec.py::test_validate_oauth_flow[connector_spec5-] ✓                                                                                                                                                         85% ████████▌ 
 unit_tests/test_spec.py::test_validate_oauth_flow[connector_spec6-Specified oauth fields are missed from spec schema:] ✓                                                                                                      86% ████████▋ 
 unit_tests/test_spec.py::test_validate_oauth_flow[connector_spec7-] ✓                                                                                                                                                         86% ████████▋ 
 unit_tests/test_spec_unit.py::TestEnvAttributes.test_correct_connector_image ✓                                                                                                                                                87% ████████▊ 
 unit_tests/test_spec_unit.py::TestEnvAttributes.test_connector_image_without_env ✓                                                                                                                                            88% ████████▊ 
 unit_tests/test_spec_unit.py::TestEnvAttributes.test_docker_image_env_ne_entrypoint ✓                                                                                                                                         88% ████████▊ 
 unit_tests/test_test_full_refresh.py::test_read_with_ignore_fields[no_ignored_fields_present] ✓                                                                                                                               89% ████████▉ 
 unit_tests/test_test_full_refresh.py::test_read_with_ignore_fields[with_ignored_field] ✓                                                                                                                                      89% ████████▉ 
 unit_tests/test_test_full_refresh.py::test_read_with_ignore_fields[ignore_field_present_but_a_required_is_not] ✓                                                                                                              90% █████████ 
 unit_tests/test_utils.py::test_compare_two_records_nested_with_different_orders[obj10-obj20-True] ✓                                                                                                                           90% █████████▏
 unit_tests/test_utils.py::test_compare_two_records_nested_with_different_orders[obj11-obj21-True] ✓                                                                                                                           91% █████████▏
 unit_tests/test_utils.py::test_compare_two_records_nested_with_different_orders[obj12-obj22-False] ✓                                                                                                                          92% █████████▎
 unit_tests/test_utils.py::test_compare_two_records_nested_with_different_orders[obj13-obj23-False] ✓                                                                                                                          92% █████████▎
 unit_tests/test_utils.py::test_compare_two_records_nested_with_different_orders[obj14-obj24-True] ✓                                                                                                                           93% █████████▍
 unit_tests/test_utils.py::test_compare_two_records_nested_with_different_orders[obj15-obj25-True] ✓                                                                                                                           93% █████████▍
 unit_tests/test_utils.py::test_compare_two_records_nested_with_different_orders[obj16-obj26-False] ✓                                                                                                                          94% █████████▍
 unit_tests/test_utils.py::test_exclude_fields ✓                                                                                                                                                                               94% █████████▌
 unit_tests/test_utils.py::test_successful_logs_reading ✓                                                                                                                                                                      95% █████████▌{"type": "LOG", "log": {"level": "ERROR", "message": "Docker container was failed, code 1, error:\nSome Container Error"}}

 unit_tests/test_utils.py::test_failed_reading[interal_error] ✓                                                                                                                                                                95% █████████▋{"type": "LOG", "log": {"level": "ERROR", "message": "Docker container was failed, code 1, error:\nTraceback (most recent call last):\n  File \"<stdin>\", line 1, in <module>\nKeyError: 'bbbb'"}}

 unit_tests/test_utils.py::test_failed_reading[traceback] ✓                                                                                                                                                                    96% █████████▋{"type": "LOG", "log": {"level": "ERROR", "message": "Docker container was failed, code 1, error:\nLast Container Logs Line"}}

 unit_tests/test_utils.py::test_failed_reading[last_line] ✓                                                                                                                                                                    97% █████████▋
 unit_tests/test_utils.py::test_docker_runner[standard] ✓                                                                                                                                                                      97% █████████▊
 unit_tests/test_utils.py::test_docker_runner[waiting] ✓                                                                                                                                                                       98% █████████▊
 unit_tests/test_utils.py::test_not_found_container ✓                                                                                                                                                                          98% █████████▉
 unit_tests/test_utils.py::TestLoadYamlOrJsonPath.test_load_json ✓                                                                                                                                                             99% █████████▉
 unit_tests/test_utils.py::TestLoadYamlOrJsonPath.test_load_yaml ✓                                                                                                                                                             99% █████████▉
 unit_tests/test_utils.py::TestLoadYamlOrJsonPath.test_load_other ✓                                                                                                                                                           100% ██████████

Results (4.99s):
     177 passed

@pedroslopez pedroslopez requested a review from brianjlai May 9, 2022 22:13
@pedroslopez pedroslopez marked this pull request as ready for review May 10, 2022 20:28
@pedroslopez pedroslopez requested a review from Phlair May 10, 2022 20:29
Comment on lines 81 to 94
def compare_cursor_with_threshold(record_value, state_value, threshold_days) -> bool:
"""
Checks if the record's cursor value is older or equal to the state cursor value.

If the threshold_days option is set, the values will be converted to dates so that the time-based offset can be applied.
:raises dateutil.parser._parser.ParserError: if threshold_days is passed with non-date cursor values.
"""
if threshold_days:
record_date_value = record_value if isinstance(record_value, datetime) else dateutil.parser.parse(record_value)
state_date_value = state_value if isinstance(state_value, datetime) else dateutil.parser.parse(state_value)

return record_date_value >= (state_date_value - timedelta(days=threshold_days))

return record_value >= state_value
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only considering the threshold_days option to be valid for date-based cursors. An offset may be desired for other types of cursors (maybe ints?), but I couldn't think of a good use case and it would make the parsing and comparison more difficult.

@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label May 10, 2022
Copy link
Contributor

@brianjlai brianjlai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me! But have you tested on different connectors that send dates in different formats or just a plain integers for epoch time? Off the top of my head, I believe Hubspot sends some of their times as integers so probably worth confirming that dateutil.parse() still works with that as well.

Copy link
Contributor

@Phlair Phlair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Main open comment is around using Pendulum for datetime ops, I'm not super bent on it so consider it an optional request for change.

Do we have issues already for implementing this in the connectors that needed it? (if not, we should make them)

@pedroslopez
Copy link
Contributor Author

have you tested on different connectors that send dates in different formats or just a plain integers for epoch time? Off the top of my head, I believe Hubspot sends some of their times as integers so probably worth confirming that dateutil.parse() still works with that as well.

@brianjlai Good call-out! Hubspot itself does some converting to return ISO strings, but there are some other connectors that do return unix timestamps. Added support for that in 9cf16cc

Do we have issues already for implementing this in the connectors that needed it? (if not, we should make them)

@Phlair From what I've seen the only connectors affected are google ads (#12668) and google analytics (#12662), which do have issues created.

@pedroslopez
Copy link
Contributor Author

pedroslopez commented May 11, 2022

/test connector=bases/source-acceptance-test

🕑 bases/source-acceptance-test https://github.com/airbytehq/airbyte/actions/runs/2309324198
✅ bases/source-acceptance-test https://github.com/airbytehq/airbyte/actions/runs/2309324198
No Python unittests run

@pedroslopez
Copy link
Contributor Author

pedroslopez commented May 11, 2022

/publish connector=bases/source-acceptance-test

🕑 bases/source-acceptance-test https://github.com/airbytehq/airbyte/actions/runs/2309373862
🚀 Successfully published bases/source-acceptance-test
❌ Couldn't auto-bump version for bases/source-acceptance-test

@pedroslopez pedroslopez merged commit 9126ebc into master May 11, 2022
@pedroslopez pedroslopez deleted the pedroslopez/sat-lookback-window branch May 11, 2022 20:05
suhomud pushed a commit that referenced this pull request May 23, 2022
* SAT: add `threshold_days` incremental test option

* fix: support cursor values that are already dates

* dont use constant value

* update docs

* use pendulum for date parsing

* bump cdk version

* use pendulum for duration

* add support for unix timestamps

* bump version, update changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source acceptance tests: allow a connector to sync data whose date is less than the supplied cursor field
3 participants