Q:

Use 'awk' on CLI to do a pre-check on file contents and perform an action

I have to process a input file, if it has more than 1 record (basically any row other than the header). 
Parse the 1st and 3rd columns to see if it has the string "Test" and exclude those rows. 
Then, write the output - preferably to the same file again.   
I searched on SE and Google and see this as very close option : Using `awk` to print number of lines in file in the BEGIN section
and the comments from Ed Morton on the same thread. 
I have it working in parts, but need to bring everything together.   
for test setup I created 15 rows in the input file.  
$awk 'NR==FNR {next} FNR==1 {x=NR-1} { print x}'  {filename.csv,filename.csv}
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15

Which is validation that x is able to hold the row count.   
I was hoping, the below would process all the 15 rows in my input file now that x is holding 15 - however it just seems to processes one row. 
$awk 'NR==FNR {next} FNR==1 {x=NR-1} { if(x>1){print x;exit 0;}}'  {filename.csv,filename.csv}
15

Here is the input file structure and the expected output. 
before the process 

filename.csv
col1,col2,col3,.....coln
test,xxx,test,.....
test,xxx,xxx,.....
xxx,xxx,test,.....
yyy,yyy,yyy,.....
zzz,zzz,zzz,.....

after the process

filename.csv
col1,col2,col3,.....coln
yyy,yyy,yyy,.....
zzz,zzz,zzz,.....

This part to perform my check on column1 and column3
if ($1 ! ~ /[Tt][Ee][Ss][Tt]/ && $3 ! ~ /[Tt][Ee][Ss][Tt]/) {print $0} else exit 0}

P.S.
-1 File will have atleast the header record. 
-2 getline is not available
-3 could not install sponge from moreutils to redirect to same file. 
-4 Planning to use tee for redirection to same file.   
all of the code | tee filename.csv

A:

From your first paragraph and the sample input/output it sounds like this is all you need if you want a complete string match:
$ awk -F, '(NR==1) || ((tolower($1) ! = "test") && (tolower($3) ! = "test"))' file.csv
col1,col2,col3,.....coln
yyy,yyy,yyy,.....
zzz,zzz,zzz,.....

If you want a partial string match then it'd be:
awk -F, '(NR==1) || (! index(tolower($1),"test") && ! index(tolower($3),"test"))' file.csv

If you want a partial regexp match:
awk -F, '(NR==1) || ((tolower($1) ! ~ /test/) && (tolower($3) ! ~ /test/))' file.csv

and finally if you want a complete regexp match:
awk -F, '(NR==1) || ((tolower($1) ! ~ /^test$/) && (tolower($3) ! ~ /^test$/))' file.csv

I'm sorry but I don't understand the intent of the script you posted or the rest of the text.  I think you may have a serious misunderstanding about how awk works.  Get the book Effective Awk Programming, 4th Edition, by Arnold Robbins. 
If you have GNU awk then to modify the input file is:
awk -i inplace -F, '...' file.csv

and with any awk:
awk -F, '...' file.csv > tmp && mv tmp file.csv

Don't try to redirect output to the input file (including via some other command in a pipe) as the shell could zap that file to prepare it for the output before opening it for reading as input. 
Given your new requirement to only modify the input file if there were matches, do this:
awk -F, '
    NR==1 {hdr=$0 ORS}
    ...$1/3 test... {printf "%s", hdr; hdr=""; print}
    END {exit (hdr=="" ?  0 : 1)}
' file.csv > tmp && mv tmp file.csv; rm -f tmp

