diff --git a/src/metrics_parse.go b/src/metrics_parse.go index cc46aa1..501f52a 100644 --- a/src/metrics_parse.go +++ b/src/metrics_parse.go @@ -62,7 +62,9 @@ func asValue(value string) interface{} { func getRawData(db dataSource) (map[string]interface{}, map[string]interface{}, string, error) { dbVersion, err := collectDBVersion(db) if err != nil { - return nil, nil, "", fmt.Errorf("metrics collection failed: error collecting version number: %w", err) + log.Warn(err.Error()) + log.Warn("Assuming the mysql version to be less than 8.0 and proceeding further") + dbVersion = "5.7.0" } inventory, err := db.query(inventoryQuery) diff --git a/src/metrics_parse_test.go b/src/metrics_parse_test.go index c401faf..01a17b7 100644 --- a/src/metrics_parse_test.go +++ b/src/metrics_parse_test.go @@ -77,3 +77,31 @@ func TestExtractSanitizedVersion(t *testing.T) { }) } } + +func TestGetRawDataWithoutDBVersion(t *testing.T) { + database := testdb{ + inventory: map[string]interface{}{ + "key_cache_block_size": 10, + "key_buffer_size": 10, + "version_comment": "mysql", + "version": "5.7.0", + }, + metrics: map[string]interface{}{}, + replica: map[string]interface{}{}, + version: map[string]interface{}{}, + } + inventory, metrics, dbVersion, err := getRawData(database) + assert.Equal(t, "5.7.0", dbVersion) + if err != nil { + t.Error() + } + if metrics == nil { + t.Error() + } + if inventory == nil { + t.Error() + } + if dbVersion == "" { + t.Error() + } +}