Canadian Prime Minister Pierre Elliott Trudeau and Cuban Premier Fidel Castro stood side by side before 20,000 cheering workers at the Cuban porttown of Cienfuegos a year ago and declared their friendship.

"Long live Cuba and the Cuban people, long live Commander Fidel Castro," Trudeau shouted as his young wife Margaret, wearing a T-shirt emblazoned with the symbol of Canada's Liberal Party, darted among the crowd taking color photographs.

The workers, trucked in from sugar fields, waited five hours in the hot sun for the two leaders, but they still responded with cries of "Viva, viva!"

But now, after embarrassing disclosures last week that the Cubans have been using Canada as a training ground for spies, Trudean may well wish he had been more restrained on his trip a year ago.

Canada expelled five Cubans, including three diplomats, Wednesday after an American mercenary claiming to be an informer for the U.S. Central Intelligence Agency, said he received spy training at the Cuban consulate in Montreal.

Royal Canadian Mounted Police escorted four of the Cubans to a Havana-bound aircraft in Toronto, and the External Affairs Department warned that a fifth, already in Cuba, would not be allowed to return.

In a surprise admission from Havana, the Cuban government said it used the consulate in Montreal for "information-gathering" against its enemies and indicated that some of this activity was directed against the U.S. government and the CIA.

The Cubans said the activity was directed against the supporters of the CIA-civil was last year. But David Bufkin, a 40-year-old mercenary from California, said in Rhodesia that he and two others were trained at the Montreal consulate for spying against the white-minority government of Rhodesian Prime Minister Ian Smith.

Bufkin told a Salisbury newspaper that he was a double agent employed by the CIA to gain information about the Cubans in Montreal.

In Ottawa, the External Affairs Department refused to give detailed reasons for the expulsions except to say the five were guilty of illegal information-gathering.

The Havana statement said Cuba has every right to know who is working against its citizens and how. The statement indirectly acknowledged the involvement of the five, saying the worked to discover the names of those who supported the "bandits" who fought against Cuban soldiers in Angola.

The unofficial words from security and foregin-affairs authorities here is that the Cubans have been using their Canadian consular and trade offices for questionable activities for several years.

In 1972, a bomb exploded in the Cuban trade mission in Montreal, killing one guard. City police and firemen, who were met by armed Cuban guards when they arrived to investigate, said that microphones were planted all over the building.

No explanation for the bombing was offered, although suggestions were made that it was the work of anti-Castro Cubans from Florida or a CIA attempt to put an abrupt end to the spy school.

The Canadian government intended to take no action on the spying but was forced to do something after Bufkin publicly confirmed the existence of the school. The police have been watching the consulate almost continuously since the 1972 bombing.

Canada has been under U.S. pressure to restrict its relations with Cuba ever since Castro took power in 1959. Although the United States imposed a trade boycott, Canadian trade with Cuba last year totaled more than $300 million, about $220 million of it in Canadian exports of food and farming equipment.

Canada has objected to several U.S. attempts to block the sale of goods to Cuba by Canadian-based subsidiaries of American companies. The United States loosened its restrictions on such sales in 1975, and now permits foreign subsidiaries of American companies to trade with Cuba.

Trudeau has been under strong criticism at home for "cuddling up to Fidel," as one critic put it in Parliament.

Even as he was escorted around Cuba by Castro last year, Cuban military aircraft were secretly using a Canadian airfield in Newfoundland as a refueling stop in flights carrying wounded soldiers from the Angolan civil war. The flights were stopped only after the U.S. government protested to Canada.