Skip to content

Commit

Permalink
Disable TestMutateResponse and TestConvertJSON for now (#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamyeats authored Aug 30, 2024
1 parent 17761a5 commit c74618d
Showing 1 changed file with 92 additions and 90 deletions.
182 changes: 92 additions & 90 deletions pkg/plugin/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1026,33 +1026,33 @@ func TestConvertNullableUUID(t *testing.T) {
}
}

func TestConvertJSON(t *testing.T) {
conn := setupConnection(t, clickhouse_sql.Native, nil)
canTest, err := plugin.CheckMinServerVersion(conn, 22, 6, 1)
if err != nil {
t.Skip(err.Error())
return
}
if !canTest {
t.Skipf("Skipping JSON test as version is < 22.6.1")
return
}
for name, protocol := range Protocols {
t.Run(fmt.Sprintf("using %s", name), func(t *testing.T) {
conn, close := setupTest(t, "col1 JSON", protocol, clickhouse_sql.Settings{
"allow_experimental_object_type": 1,
})
defer close(t)
val := map[string]interface{}{
"test": map[string][]string{
"test": {"2", "3"},
},
}
insertData(t, conn, val)
checkRows(t, conn, 1, val)
})
}
}
// func TestConvertJSON(t *testing.T) {
// conn := setupConnection(t, clickhouse_sql.Native, nil)
// canTest, err := plugin.CheckMinServerVersion(conn, 22, 6, 1)
// if err != nil {
// t.Skip(err.Error())
// return
// }
// if !canTest {
// t.Skipf("Skipping JSON test as version is < 22.6.1")
// return
// }
// for name, protocol := range Protocols {
// t.Run(fmt.Sprintf("using %s", name), func(t *testing.T) {
// conn, close := setupTest(t, "col1 JSON", protocol, clickhouse_sql.Settings{
// "allow_experimental_object_type": 1,
// })
// defer close(t)
// val := map[string]interface{}{
// "test": map[string][]string{
// "test": {"2", "3"},
// },
// }
// insertData(t, conn, val)
// checkRows(t, conn, 1, val)
// })
// }
// }

func TestConvertIPv4(t *testing.T) {
for name, protocol := range Protocols {
Expand Down Expand Up @@ -1106,69 +1106,71 @@ func TestConvertNullableIPv6(t *testing.T) {
}
}

func TestMutateResponse(t *testing.T) {
conn := setupConnection(t, clickhouse_sql.Native, nil)
canTest, err := plugin.CheckMinServerVersion(conn, 22, 6, 1)
if err != nil {
t.Skip(err.Error())
return
}
if !canTest {
t.Skipf("Skipping Mutate Response as version is < 22.6.1")
return
}

clickhouse := plugin.Clickhouse{}
assert.Equal(t, nil, err)
conn, close := setupTest(t, "col1 JSON", clickhouse_sql.Native, clickhouse_sql.Settings{
"allow_experimental_object_type": 1,
})
defer close(t)
val := map[string]interface{}{
"test": map[string][]string{
"test": {"2", "3"},
},
}
insertData(t, conn, val)

t.Run("doesn't mutate traces", func(t *testing.T) {
rows, err := conn.Query("SELECT * FROM simple_table LIMIT 1")
require.NoError(t, err)
frame, err := sqlutil.FrameFromRows(rows, 1, converters.ClickhouseConverters...)
require.NoError(t, err)
frame.Meta = &data.FrameMeta{PreferredVisualization: data.VisType(data.VisTypeTrace)}
frames, err := clickhouse.MutateResponse(context.Background(), []*data.Frame{frame})
require.NoError(t, err)
require.NotNil(t, frames)
assert.Equal(t, frames[0].Fields[0].Type(), data.FieldTypeNullableJSON)
})

t.Run("doesn't mutate tables", func(t *testing.T) {
rows, err := conn.Query("SELECT * FROM simple_table LIMIT 1")
require.NoError(t, err)
frame, err := sqlutil.FrameFromRows(rows, 1, converters.ClickhouseConverters...)
require.NoError(t, err)
frame.Meta = &data.FrameMeta{PreferredVisualization: data.VisType(data.VisTypeTable)}
frames, err := clickhouse.MutateResponse(context.Background(), []*data.Frame{frame})
require.NoError(t, err)
require.NotNil(t, frames)
assert.Equal(t, frames[0].Fields[0].Type(), data.FieldTypeNullableJSON)
})

t.Run("mutates other types", func(t *testing.T) {
rows, err := conn.Query("SELECT * FROM simple_table LIMIT 1")
require.NoError(t, err)
frame, err := sqlutil.FrameFromRows(rows, 1, converters.ClickhouseConverters...)
require.NoError(t, err)
frame.Meta = &data.FrameMeta{PreferredVisualization: data.VisType(data.VisTypeLogs)}
frames, err := clickhouse.MutateResponse(context.Background(), []*data.Frame{frame})
require.NoError(t, err)
require.NotNil(t, frames)
assert.Equal(t, frames[0].Fields[0].Type(), data.FieldTypeNullableString)
assert.NoError(t, err)
assert.Equal(t, "{\"test\":{\"test\":[\"2\",\"3\"]}}", *frames[0].Fields[0].At(0).(*string))
})
}
// disabled due to new JSON type in latest ClickHouse versions
// func TestMutateResponse(t *testing.T) {
// conn := setupConnection(t, clickhouse_sql.Native, nil)

// canTest, err := plugin.CheckMinServerVersion(conn, 22, 6, 1)
// if err != nil {
// t.Skip(err.Error())
// return
// }
// if !canTest {
// t.Skipf("Skipping Mutate Response as version is < 22.6.1")
// return
// }

// clickhouse := plugin.Clickhouse{}
// assert.Equal(t, nil, err)
// conn, close := setupTest(t, "col1 JSON", clickhouse_sql.Native, clickhouse_sql.Settings{
// "allow_experimental_object_type": 1,
// })
// defer close(t)
// val := map[string]interface{}{
// "test": map[string][]string{
// "test": {"2", "3"},
// },
// }
// insertData(t, conn, val)

// t.Run("doesn't mutate traces", func(t *testing.T) {
// rows, err := conn.Query("SELECT * FROM simple_table LIMIT 1")
// require.NoError(t, err)
// frame, err := sqlutil.FrameFromRows(rows, 1, converters.ClickhouseConverters...)
// require.NoError(t, err)
// frame.Meta = &data.FrameMeta{PreferredVisualization: data.VisType(data.VisTypeTrace)}
// frames, err := clickhouse.MutateResponse(context.Background(), []*data.Frame{frame})
// require.NoError(t, err)
// require.NotNil(t, frames)
// assert.Equal(t, frames[0].Fields[0].Type(), data.FieldTypeNullableJSON)
// })

// t.Run("doesn't mutate tables", func(t *testing.T) {
// rows, err := conn.Query("SELECT * FROM simple_table LIMIT 1")
// require.NoError(t, err)
// frame, err := sqlutil.FrameFromRows(rows, 1, converters.ClickhouseConverters...)
// require.NoError(t, err)
// frame.Meta = &data.FrameMeta{PreferredVisualization: data.VisType(data.VisTypeTable)}
// frames, err := clickhouse.MutateResponse(context.Background(), []*data.Frame{frame})
// require.NoError(t, err)
// require.NotNil(t, frames)
// assert.Equal(t, frames[0].Fields[0].Type(), data.FieldTypeNullableJSON)
// })

// t.Run("mutates other types", func(t *testing.T) {
// rows, err := conn.Query("SELECT * FROM simple_table LIMIT 1")
// require.NoError(t, err)
// frame, err := sqlutil.FrameFromRows(rows, 1, converters.ClickhouseConverters...)
// require.NoError(t, err)
// frame.Meta = &data.FrameMeta{PreferredVisualization: data.VisType(data.VisTypeLogs)}
// frames, err := clickhouse.MutateResponse(context.Background(), []*data.Frame{frame})
// require.NoError(t, err)
// require.NotNil(t, frames)
// assert.Equal(t, frames[0].Fields[0].Type(), data.FieldTypeNullableString)
// assert.NoError(t, err)
// assert.Equal(t, "{\"test\":{\"test\":[\"2\",\"3\"]}}", *frames[0].Fields[0].At(0).(*string))
// })
// }

func TestHTTPConnectWithHeaders(t *testing.T) {
proxy := goproxy.NewProxyHttpServer()
Expand Down

0 comments on commit c74618d

Please sign in to comment.