Spain started off their Pacific Tour with a hard-fought match against Samoa - the home side scraping by with a 34-30 win.