For small n, trial division works; the limit there is probably somewhere around 10 ^ 12. For somewhat large n there are various studies (see Works by Gerhard Jeshke and Zhou Zhang) that calculate the smallest pseudo-primitive for different collections of Miller-Rabin bases; it will take about 10 ^ 25. After that, things get complicated.
The "big guns" of proving primitiveness are the APRCL method (it can be called Jacobi sums or Gaussian sums) and the ECPP method (based on elliptic curves). Both are complex, so you'll want to find an implementation, don't write your own. These methods can handle several hundred digits.
The AKS method is a proven polynomial time and is easy to implement, but the proportionality constant is very high, so in practice this is not useful.
If you can define n-1 or even partially define it, the Pocklington method can determine the primitivity of n. The Pocklington method itself is fast, but factoring cannot be.
For all these purposes, you want to be sure that the number is prime before trying to prove it. If your number is not prime, all of these methods will correctly determine this, but at first they will spend a lot of time trying to prove that the compound number is prime.
I have implementations of AKS and Pocklington on my blog.
source share