using edu.jhu.Cas.Users;
using edu.jhu.Cas.Jobs;
using edu.jhu.Cas.Util;
using edu.jhu.Cas.Servers;
using NUnit.Framework;
using NUnit.Core;
using System;
using System.Threading;
using System.Configuration;

namespace edu.jhu.Cas.Test{
	[TestFixture]	
	public class VeryLongRunningImpracticalTests{
	
		public const string DEF_TARG = "DR1";
		private long wsid = 193424723;
		private string target = "DR1";

		[Test]
			/**
			 * there is no assertion for this test.  just watch service, from cl or webpage; make sure q limits are in place
			 */
		public void SeeCommentBeforeRunningThisTest(){
			string erg = @"
SELECT TOP 10000 g, run, rerun, camcol, field, objID
FROM
  Galaxy                           
WHERE (
  (g <= 22) and
  (u-g >= -0.27) and (u-g < 0.71) and
  (g-r >= -0.24) and (g-r < 0.35) and
  (r-i >= -0.27) and (r-i < 0.57) and
  (i-z >= -0.35) and (i-z < 0.70))
";
			CasJobs cJobs = new CasJobs();
			long lastjobid = -1;
			for(int x=0;x<19;x++){
				string qry = erg.Replace("FROM","INTO MYDB.ERGTEST_"+x+" FROM");
				Console.WriteLine(qry);
				lastjobid = cJobs.SubmitJob(wsid,qry,target,"TEST",500,0);
			}
			int status = -1;
			while((status = cJobs.StatusJob(wsid,lastjobid)) < 4){
				Console.Write(".");
				Thread.Sleep(3*1000);
			}
			for(int x=0;x<19;x++)
				cJobs.SubmitShortJob(wsid,"drop table ergtest_"+x,"mydb","asdf",0);
		}
	}
}