Anti-doping is an international game of "the mouse and the cat," says Henrique Pereira. In Brazil, he's in charge of the cats.

"There's no end to this kind of job, but that's what motivates us," Pereira says as he gives the CBC a tour of Brazil's anti-doping lab. He's proud of the new $25-million facility in Rio, of which he's vice-director. It was built to analyze more than 6,000 samples during the Olympics. But the political chaos in Brazil came dangerously close to derailing a key Olympic milestone, which could have rendered all the technology on display useless during the Games. 

Brazil had years to set up an independent doping tribunal, mandatory for any Olympic host country. The government finally got around to it Thursday — just one day before the Friday, March 18, deadline — thanks to a decree from President Dilma Rouseff. Brazil's anti-doping system has been lurching from crisis to crisis.

Anti-Doping Lab-16

A look inside Brazil's Olympic anti-doping lab. (Kim Brunhuber/CBC)

Just across the street from Brazil's new anti-doping lab is the old lab. In 2013, the World Anti Doping Agency (WADA) stripped its certification for being too old and not having enough qualified staff. During the 2014 World Cup in Brazil, they had to send each sample to Europe for testing, incurring enormous costs and lengthy delays.

"It's one thing to do this kind of management of samples in the World Cup," Pereira says. "It's very important, but a small number of samples. For the Olympic Games, from my perspective, it would be impossible."

So Brazil was forced to build a new facility.

Anti-Doping Lab-11

A worker demonstrates the first phase of testing for a controlled substance. (Kim Brunhuber/CBC)

"Now we are living a new reality," Pereira says. "After the investment of the federal government, we have a new building, new staff, new machines, so it's almost a new life." 

On this day, dozens of young trainees in lab coats gather around a table laden with beakers and vials. They're some of the hundred or so volunteers who will join close to 200 drug-testing experts from Brazil and around the world at this facility.

Anti-Doping Lab-24

Some of the close to 100 trainees who will join the experienced anti-doping testers during the Games. (Kim Brunhuber/CBC)

Right now, doping tests are done in one room. During the Olympics, it will take over the entire building. Testers will operate in three shifts, 24 hours a day, testing not just for 700 known banned substances but also for things that athletes might use in the future, like "gene doping."

"The clever strategy from WADA is to prohibit a substance or strategy even when it doesn't exist yet," Pereira says. "So that motivates the scientists — not only our lab, all the WADA labs, all the scientists in the world — to try to develop a strategy to be able to face this kind of challenge."

Anti-Doping Lab-22

Brazil's new $25-million lab, built to replace one that didn't meet international standards. (Kim Brunhuber/CBC)

Brazil's scientists are aware that no Olympic anti-doping program will work if the system around it is broken or, as was recently the case in Russia, found to be corrupt. Brazil is currently in chaos due to a multibillion-dollar corruption scandal that has implicated the former president, and another financial scandal involving the current president. 

Pereira's confident that despite all this, the world can have confidence in Brazil's beefed-up anti-doping program.

Anti-Doping Lab-20

The lab will run 24 hours a day to analyze more than 6,000 samples. (Kim Brunhuber/CBC)

"If someone does something wrong, sooner or later that will be exposed," Pereira says. "Because there's so many stakeholders around the project that it's impossible to keep a bad thing quiet and in the shadow for a long time."