It was inevitable. Russian “mercenaries” attacked a forward base in Syria where they knew American advisors were stationed. It was a test. And our military passed.

Let’s hope the administration passes, too.

The most important thing about this attack on our troops is that it couldn’t have happened without Vladimir Putin’s personal approval. Nye vozmozhno.

The core of the attacking force came from the Wagner Group, Russia’s version of the American thugs who worked for the company formerly known as Blackwater. But while the media refers to the Russians as mercenaries, the Wagner Group functions as an auxiliary of the Russian military — it previously gave command performances in Crimea and eastern Ukraine. It exists to give Moscow (barely) plausible deniability.

It also allows the Kremlin to avoid reporting formal military casualties. Putin remembers the popular disaffection in the 1980s because of the “zinky boys,” the young Russian soldiers returning home in zinc coffins in large numbers.

But the bottom line is that these killers — primarily ethnic Russians, but also recruited regionally — work for Putin. Russian suggestions that this was a rogue operation are ludicrous: An armored task force including hundreds of Russian citizens doesn’t attack US troops and blindside Putin. Doesn’t work that way, comrade.

And somewhere between several dozen and 200 of these Kremlin auxiliaries were killed, with hundreds more of the attackers wounded. We may never know the precise number, but the interesting point is that the higher casualty figures come from unofficial Russian sources.

What happened? Last week, a Russian-directed task force with tanks and artillery crossed the agreed deconfliction line separating Assad’s turf and that liberated by the Syrian Democratic Forces — our guys. The Russians knew our advisors were there because we told them. After about 5 miles, the Russians, thinly cloaked as regime forces, attacked.

It was a very bad idea.

Our ground-attack aircraft and drones struck back promptly to protect our troops. And the crucial difference between our pilots and Russians jet-jockeys is that we hit our targets. It was not a banner day for Mother Russia.

But while the guided bombs struck, a charade continued, with US and Russian officers chatting on a hot line. We warned the Russians we were hitting the attackers. The Russians played dumb and didn’t interfere. (No plausible denial had they gotten openly involved.) And there would’ve been a lot of Russian aircraft strewn over the landscape.

What now? The Russians will try to take revenge, one way or another. President Trump will be tested. In a phone conversation with Putin on Monday, the president and the czar didn’t discuss the events in Syria, according to the Russian side. Hard to believe, but what really matters will be what happens next.

Nor did this event happen in a strategic vacuum. Almost simultaneously, Iran tested Israel by sending a drone into Israeli airspace. And Iran fared even worse than did those Russian yahoos with tanks.

After butchering Syrian civilians with impunity, it must have shocked the Kremlin’s gangsters-in-uniform to face US airpower, but the Iranians in Syria paid a still-higher price: The IDF tore apart Assad’s air defenses and hit Iranian command-and-control nodes. We killed sergeants, the Israelis killed colonels.

Iran wants Israel destroyed and all Jews dead. Putin wants the US out of Syria, but doesn’t really mind if Israel weakens Iran’s grip at this point — leaving Assad more reliant on Russia. Lot of moving parts in this scenario.

But what’s clear as vodka is that Putin was willing to risk a large number of his men in the hope they’d kill enough American advisers to make us flee Syria. It didn’t work, but Putin won’t give up. He’s paid a much higher price in Syria than he initially expected, and he wants a return on his investment. He’ll try other ways to drive us out, perhaps using terror attacks to kill Americans.

The Russians are at war with us, and we’re at war with them, but both sides would find an admission inconvenient. So we’ll continue deconflicting flight paths and coordinating boundaries . . . while Putin’s henchmen calculate how best to wound us, from attacking our elections to killing Americans in uniform.

We passed a test last week. But that was a pop quiz, not the final exam.