  The \emph{Gowers uniformity norms} $\|f\|_{U^k(G)}$ of a function $f: G \to
\C$ on a finite additive group $G$, together with the slight variant
$\|f\|_{U^k([N])}$ defined for functions on a discrete interval $[N] :=
\{1,...,N\}$, are of importance in the modern theory of counting additive
patterns (such as arithmetic progressions) inside large sets. Closely related
to these norms are the \emph{Gowers-Host-Kra seminorms} $\|f\|_{U^k(X)}$ of a
measurable function $f: X \to \C$ on a measure-preserving system $X = (X,
{\mathcal X}, \mu, T)$. Much recent effort has been devoted to the question of
obtaining necessary and sufficient conditions for these Gowers norms to have
non-trivial size (e.g. at least $\eta$ for some small $\eta > 0$), leading in
particular to the inverse conjecture for the Gowers norms, and to the Host-Kra
classification of characteristic factors for the Gowers-Host-Kra seminorms.
  In this paper we investigate the near-extremal (or "property testing")
version of this question, when the Gowers norm or Gowers-Host-Kra seminorm of a
function is almost as large as it can be subject to an $L^\infty$ or $L^p$
bound on its magnitude. Our main results assert, roughly speaking, that this
occurs if and only if $f$ behaves like a polynomial phase, possibly localised
to a subgroup of the domain; this can be viewed as a higher-order analogue of
classical results of Russo and Fournier, and are also related to the
polynomiality testing results over finite fields of Blum-Luby-Rubinfeld and
Alon-Kaufman-Krivelevich-Litsyn-Ron. We investigate the situation further for
the $U^3$ norms, which are associated to 2-step nilsequences, and find that
there is a threshold behaviour, in that non-trivial 2-step nilsequences (not
associated with linear or quadratic phases) only emerge once the $U^3$ norm is
at most $2^{-1/8}$ of the $L^\infty$ norm.
