Node constantly restarting due to running out of memory... in test environment?

So my two node cluster is constantly restarting due to running out of memory, and its happening in a testing environment, with at most 10 users writing to and searching the database.

And now the error reads that all shards have failed, and I get an internal server error of 500 when trying to access Kibana from the console.

What version?

We are running 5.2.0, this was a 1 gb memory cluster with two nodes.

Upgrade to 5.2.1, there is a known issue with 5.2.0.

Is it okay to be using 5.1.2?

Yes, just run the latest of 5.1 or 5.2.