func TestUncache(t *testing.T) { // Verify rowcache is working vitess_cached2 err := verifyvitessCached2(t, "vitess_cached2") if err != nil { t.Error(err) return } // Disable rowcache for vitess_cached2 client := framework.NewClient() _, err = client.Execute("alter table vitess_cached2 comment 'vitess_nocache'", nil) if err != nil { t.Error(err) return } _, err = client.Execute("select * from vitess_cached2 where eid = 2 and bid = 'foo'", nil) if err != nil { t.Error(err) } if tstat, ok := framework.TableStats()["vitess_cached2"]; ok { t.Errorf("table stats was found: %v, want not found", tstat) } // Re-enable rowcache and verify it's working _, err = client.Execute("alter table vitess_cached2 comment ''", nil) if err != nil { t.Error(err) return } err = verifyvitessCached2(t, "vitess_cached2") if err != nil { t.Error(err) return } }
func verifyvitessCached2(t *testing.T, table string) error { client := framework.NewClient() query := fmt.Sprintf("select * from %s where eid = 2 and bid = 'foo'", table) _, err := client.Execute(query, nil) if err != nil { return err } tstart := framework.TableStats()[table] _, err = client.Execute(query, nil) if err != nil { return err } tend := framework.TableStats()[table] if tend.Hits != tstart.Hits+1 { return fmt.Errorf("Hits: %d, want %d", tend.Hits, tstart.Hits+1) } return nil }
func TestRename(t *testing.T) { // Verify rowcache is working vitess_cached2 err := verifyvitessCached2(t, "vitess_cached2") if err != nil { t.Error(err) return } // Rename & test client := framework.NewClient() _, err = client.Execute("alter table vitess_cached2 rename to vitess_renamed", nil) if err != nil { t.Error(err) return } if tstat, ok := framework.TableStats()["vitess_cached2"]; ok { t.Errorf("table stats was found: %v, want not found", tstat) } err = verifyvitessCached2(t, "vitess_renamed") if err != nil { t.Error(err) return } // Rename back & verify _, err = client.Execute("rename table vitess_renamed to vitess_cached2", nil) if err != nil { t.Error(err) return } err = verifyvitessCached2(t, "vitess_cached2") if err != nil { t.Error(err) return } }