You are right that they are in rebuilding phase which is tough for team with such high expectations. Xabi Alonso has to win games and he builds team because if they start losing he could quickly be fired. You are also right that real test will be how they perform against big rivals like Barcelona and Atletico Madrid as those matches will truly show how much team has improved. For now they are doing well enough to give them time they need to get better.
I don't believe he'll be fired immediately. Xabi is a very successful coach, and if his Real Madrid career progresses normally, it could last a few years. Spain is a place he knows well, and he's a coach who's attuned to young players. I still remember what he did at Leverkusen. They didn't lose a single Bundesliga loss for an entire season and reached the UEL final. I have full confidence they'll do the same with Real.
Real Madrid will not do something reckless like firing Xabi Alonso, not for now. Everyone is adapting well, both the players and the coach, and sooner or later we will see the results of Alonso coaching. Indeed, at Leverkusen, Alonso showed exceptional quality, building a team that was more confident and disciplined, which yielded good results. However, Real Madrid is a very different club, here expectations are higher and the pressure is undoubtedly greater.
Furthermore, Alonso success at Real Madrid cannot be determined solely by his strategy but also by his ability to manage the egos of star players like Mbappe & Vinicius. If he can bring his positive philosophy from Leverkusen, it is not impossible that he will stay for a long time.