// writeMutation writes the mutation to the table descriptor. If the
// State or the Direction is undefined, these values are populated via
// picking random values before the mutation is written.
func (mt mutationTest) writeMutation(m csql.DescriptorMutation) {
	if m.Direction == csql.DescriptorMutation_NONE {
		// randomly pick ADD/DROP mutation.
		r := rand.Intn(2)
		if r == 0 {
			m.Direction = csql.DescriptorMutation_ADD
		} else {
			m.Direction = csql.DescriptorMutation_DROP
		}
	}
	if m.State == csql.DescriptorMutation_UNKNOWN {
		// randomly pick DELETE_ONLY/WRITE_ONLY state.
		r := rand.Intn(2)
		if r == 0 {
			m.State = csql.DescriptorMutation_DELETE_ONLY
		} else {
			m.State = csql.DescriptorMutation_WRITE_ONLY
		}
	}
	tableDesc := mt.desc.GetTable()
	tableDesc.Mutations = append(tableDesc.Mutations, m)
	if err := tableDesc.Validate(); err != nil {
		mt.Fatal(err)
	}
	if err := mt.kvDB.Put(mt.descKey, mt.desc); err != nil {
		mt.Fatal(err)
	}
}