You seem to have accidentially reversed which one is the listener and which one is not. I.e. you'll need to change the commands to the following:

Open the listener first:

nc -u -l 127.0.0.1 10000

Then the sender:

echo "test" | nc -u 127.0.0.1 10000

Then you'll see that the listener outputs "test" on the console.

You can stop the nc program by pressing Ctrl-c.