The CMS barrel pixel detector is the innermost tracking device, reconstructing the interaction vertices and charged particle trajectories. At the LHC design luminosity, 1034 cm−2 s−1, there will be 1000 charged particles per bunch crossing every 25 ns. In the innermost layer the pixel sensors will be exposed to a fluence of 3×1014neq/cm2/yr with consequent degradation of the silicon lattice structure and particle detection performances. Beam tests of irradiated pixel sensors were performed at CERN with the final front end electronics in a 3T magnetic field. We present the measurements of charge collection and radiation hardness, as well as spatial resolution.