Running the code as given, the confusionMatrix returns an error:
Error: data and reference should be factors with the same levels.
A bit of digging turns up that the function is expecting the second argument to be a factor. It can be fixed by amending the line to:
confusionMatrix(test_pred, as.factor(testing$V7))