Skip to content

Commit

Permalink
addition of endtoend tests for enable system settings variable
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed Jan 19, 2021
1 parent bb76bbf commit ebf4d93
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions go/test/endtoend/vtgate/reservedconn/sysvar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,38 @@ func TestSetSystemVarInTxWithConnError(t *testing.T) {
// subsequent queries on 80- will pass
assertMatches(t, conn, "select id, @@sql_safe_updates from test where id = 4", "[[INT64(4) INT64(1)]]")
}

func TestEnableSystemSettings(t *testing.T) {
vtParams := mysql.ConnParams{
Host: "localhost",
Port: clusterInstance.VtgateMySQLPort,
}
conn, err := mysql.Connect(context.Background(), &vtParams)
require.NoError(t, err)
defer conn.Close()

// Insert a single row to correctly select @@enable_system_settings.
// See: https://github.com/vitessio/vitess/issues/7301
checkedExec(t, conn, "delete from test")
checkedExec(t, conn, "insert into test (id, val1, val2, val3) values (1, null, 0, 0)")

// test set @@enable_system_settings to false and true
checkedExec(t, conn, "set enable_system_settings = false")
assertMatches(t, conn, `select @@enable_system_settings from test`, `[[INT64(0)]]`)
checkedExec(t, conn, "set enable_system_settings = true")
assertMatches(t, conn, `select @@enable_system_settings from test`, `[[INT64(1)]]`)

// prepare the @@sql_mode variable
checkedExec(t, conn, "set sql_mode = 'NO_ZERO_DATE'")
assertMatches(t, conn, "select @@sql_mode", `[[VARCHAR("NO_ZERO_DATE")]]`)

// check disabling @@enable_system_settings
checkedExec(t, conn, "set enable_system_settings = false")
checkedExec(t, conn, "set sql_mode = ''") // attempting to set @@sql_mode to an empty string
assertMatches(t, conn, "select @@sql_mode", `[[VARCHAR("NO_ZERO_DATE")]]`) // @@sql_mode did not change

// check enabling @@enable_system_settings
checkedExec(t, conn, "set enable_system_settings = true")
checkedExec(t, conn, "set sql_mode = ''") // changing @@sql_mode to empty string
assertMatches(t, conn, "select @@sql_mode", `[[VARCHAR("")]]`) // @@sql_mode did change
}

0 comments on commit ebf4d93

Please sign in to comment.