Here is the procedure for testing the Recoil Spring Assembly (RSA);
1. Unload the pistol and remove the magazine.
2. Point the pistol up at a 45-degree angle, and pull the trigger (HOLD the trigger back).
3. Pull the slide back fully and release it slowly.
4. The RSA should be able to push the slide forward into battery.
If the RSA won't push the slide into battery, assuming that the pistol is clean, then the RSA should be replaced. In older pistols with a separate guide rod and spring, replace the spring. In newer pistol, the entire RSA should be replaced. If you don't know if you have a standard Glock RSA, please post a couple of detailed photos of it.
I will add that if this is a new Glock, you should contact Glock service (770 - 432 1202) and ask for help. They will solve your problem, although it may involve sending the pistol to them. Alternatively, they might just send you a new RSA, so be prepared to describe the RSA (stamping on the base) to them on the phone. It's possible that the wrong RSA was installed in the pistol at the factory.
One other thing I'll suggest: if you know a Glock Armorer (or if your dealer knows one) you might have the Armorer inspect the pistol first.
Good luck, I know this is disappointing but the problem can be solved, and it's not representative of overall Glock quality.
Chris