List:Commits« Previous MessageNext Message »
From:rburnett Date:December 14 2006 9:40pm
Subject:Connector/NET commit: r502 - branches/1.0/TestSuite
View as plain text  
Modified:
   branches/1.0/TestSuite/BaseTest.cs
   branches/1.0/TestSuite/BlobTests.cs
   branches/1.0/TestSuite/CommandBuilderTests.cs
   branches/1.0/TestSuite/ConnectionTests.cs
   branches/1.0/TestSuite/DataReaderTests.cs
   branches/1.0/TestSuite/EventTests.cs
   branches/1.0/TestSuite/LanguageTests.cs
   branches/1.0/TestSuite/MySqlHelperTests.cs
   branches/1.0/TestSuite/PoolingTests.cs
   branches/1.0/TestSuite/StressTests.cs
   branches/1.0/TestSuite/Syntax.cs
Log:
fixed several errors that were exposed by running the test suite under a non-privileged user on the CI machines.

Modified: branches/1.0/TestSuite/BaseTest.cs
===================================================================
--- branches/1.0/TestSuite/BaseTest.cs	2006-12-14 20:48:31 UTC (rev 501)
+++ branches/1.0/TestSuite/BaseTest.cs	2006-12-14 21:40:23 UTC (rev 502)
@@ -38,20 +38,27 @@
 		protected string user;
 		protected string password;
         protected int port;
-        protected string database;
         protected string pipeName;
         protected string memoryName;
+        protected string[] databases;
+        protected string rootUser;
+        protected string rootPassword;
 
 		public BaseTest()
 		{
+            databases = new string[2];
+
             csAdditions = ";pooling=false;";
 			user = "root";
 			password = "";
 			host = "localhost";
-            database = "test";
+            databases[0] = "test";
+            databases[1] = "root";
             port = 3306;
             pipeName = "MYSQL";
             memoryName = "MYSQL";
+            rootUser = "su";
+            rootPassword = "su";
 
 #if NET20
             string strPort = ConfigurationManager.AppSettings["port"];
@@ -71,7 +78,7 @@
             if (strPort != null)
                 port = Int32.Parse(strPort);
             if (strDatabase != null)
-                database = strDatabase;
+                databases[0] = strDatabase;
             if (strUserId != null)
                 user = strUserId;
             if (strPassword != null)
@@ -92,11 +99,23 @@
             string connStr = String.Format("server={0};user id={1};password={2};" +
                  "persist security info=true;{3}", host, user, password, csAdditions);
             if (includedb)
-                connStr += String.Format("database={0};", database);
+                connStr += String.Format("database={0};", databases[0]);
             connStr += GetConnectionInfo();
             return connStr;
         }
 
+        protected string GetConnectionStringEx(string user, string pw, bool includedb)
+        {
+            string connStr = String.Format("server={0};user id={1};" +
+                 "persist security info=true;{2}", host, user, csAdditions);
+            if (includedb)
+                connStr += String.Format("database={0};", databases[0]);
+            if (pw != null)
+                connStr += String.Format("password={0};", pw);
+            connStr += GetConnectionInfo();
+            return connStr;
+        }
+
 		protected void Open()
 		{
 			try
@@ -203,6 +222,19 @@
 			execSQL(sql);
 		}
 
+        protected void suExecSQL(string sql)
+        {
+			string connStr = String.Format("server={0};user id={1};password={2};" +
+				 "persist security info=true;{3}", host, rootUser, rootPassword, csAdditions);
+			connStr += GetConnectionInfo();
+
+            MySqlConnection c = new MySqlConnection(connStr);
+            c.Open();
+            MySqlCommand cmd = new MySqlCommand(sql, c);
+            cmd.ExecuteNonQuery();
+            c.Close();
+        }
+
 		protected void execSQL(string sql)
 		{
 			MySqlCommand cmd = new MySqlCommand(sql, conn);

Modified: branches/1.0/TestSuite/BlobTests.cs
===================================================================
--- branches/1.0/TestSuite/BlobTests.cs	2006-12-14 20:48:31 UTC (rev 501)
+++ branches/1.0/TestSuite/BlobTests.cs	2006-12-14 21:40:23 UTC (rev 502)
@@ -376,8 +376,6 @@
 		[Test]
 		public void BlobBiggerThanMaxPacket()
 		{
-			execSQL("set @@global.max_allowed_packet=500000");
-
 			execSQL("DROP TABLE IF EXISTS test");
 			execSQL("CREATE TABLE test (id INT(10), image BLOB)");
 
@@ -386,7 +384,11 @@
 			{
 				c.Open();
 				byte[] image = Utils.CreateBlob(1000000);
-				MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES(NULL, ?image)", c);
+
+                MySqlCommand cmd = new MySqlCommand("SET max_allowed_packet=500000", c);
+                cmd.ExecuteNonQuery();
+
+                cmd.CommandText = "INSERT INTO test VALUES(NULL, ?image)";
 				cmd.Parameters.Add("?image", image);
 				cmd.ExecuteNonQuery();
 				Assert.Fail("This should have thrown an exception");
@@ -399,7 +401,6 @@
 			{
 				if (c != null)
 					c.Close();
-				execSQL("set @@global.max_allowed_packet=2000000");
 			}
 		}
 	}

Modified: branches/1.0/TestSuite/CommandBuilderTests.cs
===================================================================
--- branches/1.0/TestSuite/CommandBuilderTests.cs	2006-12-14 20:48:31 UTC (rev 501)
+++ branches/1.0/TestSuite/CommandBuilderTests.cs	2006-12-14 21:40:23 UTC (rev 502)
@@ -184,12 +184,11 @@
 			execSQL("INSERT INTO test (id, name) VALUES (2,'test2')");
 			execSQL("INSERT INTO test (id, name) VALUES (3,'test3')");
 
-			conn.ChangeDatabase("mysql");
+            conn.ChangeDatabase(databases[1]);
 
 			MySqlDataAdapter da = new MySqlDataAdapter(
-                String.Format("SELECT id, name FROM {0}.test", database), conn);
+                String.Format("SELECT id, name FROM {0}.test", databases[0]), conn);
 			MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
-			cb.ToString();  // keep the compiler happy
 			DataSet ds = new DataSet();
 			da.Fill(ds);
 
@@ -199,7 +198,7 @@
 			ds.Merge(changes);
 			ds.AcceptChanges();
 
-			conn.ChangeDatabase("test");
+			conn.ChangeDatabase(databases[0]);
 		}
 
 		/// <summary>

Modified: branches/1.0/TestSuite/ConnectionTests.cs
===================================================================
--- branches/1.0/TestSuite/ConnectionTests.cs	2006-12-14 20:48:31 UTC (rev 501)
+++ branches/1.0/TestSuite/ConnectionTests.cs	2006-12-14 21:40:23 UTC (rev 502)
@@ -107,17 +107,15 @@
 		[Test]
 		public void TestPersistSecurityInfoCachingPasswords()
 		{
-			string connStr = String.Format("database=test;server={0};user id={1};Password={2}; pooling=false",
-				host, this.user, this.password);
+            string connStr = GetConnectionString(true);
 			MySqlConnection c = new MySqlConnection(connStr);
 			c.Open();
 			c.Close();
 
 			// this shouldn't work
-			connStr = String.Format("database=test;server={0};user id={1};Password={2}; pooling=false",
-				host, this.user, "bad_password");
-			c = new MySqlConnection(connStr);
-			try
+            connStr = GetConnectionStringEx(user, "bad_password", true);
+            c = new MySqlConnection(connStr);
+            try
 			{
 				c.Open();
 				Assert.Fail("Thn is should not work");
@@ -129,10 +127,9 @@
 			}
 
 			// this should work
-			connStr = String.Format("database=test;server={0};user id={1};Password={2}; pooling=false",
-				host, this.user, this.password);
-			c = new MySqlConnection(connStr);
-			c.Open();
+            connStr = GetConnectionString(true);
+            c = new MySqlConnection(connStr);
+            c.Open();
 			c.Close();
 		}
 
@@ -144,11 +141,11 @@
 			c.Open();
 			Assert.IsTrue(c.State == ConnectionState.Open);
 
-			Assert.AreEqual("test", c.Database.ToLower());
+			Assert.AreEqual(databases[0], c.Database.ToLower());
 
-			c.ChangeDatabase("mysql");
+			c.ChangeDatabase(databases[1]);
 
-			Assert.AreEqual("mysql", c.Database.ToLower());
+			Assert.AreEqual(databases[1], c.Database.ToLower());
 
 			c.Close();
 		}
@@ -185,7 +182,7 @@
 				c.Close();
 
 				// TODO: make anonymous login work
-				execSQL("GRANT ALL ON *.* to '' IDENTIFIED BY ''");
+				suExecSQL("GRANT ALL ON *.* to '' IDENTIFIED BY ''");
 
 				// connect with all defaults
 				if (connStr.IndexOf("localhost") != -1)
@@ -195,17 +192,17 @@
 					c.Close();
 				}
 
-				execSQL("GRANT ALL ON *.* to 'nopass'@'localhost'");
-				execSQL("FLUSH PRIVILEGES");
+				suExecSQL("GRANT ALL ON *.* to 'nopass'@'localhost'");
+				suExecSQL("FLUSH PRIVILEGES");
 
 				// connect with no password
-				connStr2 = "server=" + host + ";user id=nopass";
-				c = new MySqlConnection(connStr2);
+                connStr2 = GetConnectionStringEx("nopass", null, false);
+                c = new MySqlConnection(connStr2);
 				c.Open();
 				c.Close();
 
-				connStr2 += ";password=;";
-				c = new MySqlConnection(connStr2);
+                connStr2 = GetConnectionStringEx("nopass", "", false);
+                c = new MySqlConnection(connStr2);
 				c.Open();
 				c.Close();
 			}
@@ -215,9 +212,9 @@
 			}
 			finally
 			{
-				execSQL("DELETE FROM mysql.user WHERE length(user) = 0");
-				execSQL("DELETE FROM mysql.user WHERE user='nopass'");
-				execSQL("FLUSH PRIVILEGES");
+				suExecSQL("DELETE FROM mysql.user WHERE length(user) = 0");
+				suExecSQL("DELETE FROM mysql.user WHERE user='nopass'");
+				suExecSQL("FLUSH PRIVILEGES");
 			}
 		}
 
@@ -330,9 +327,11 @@
 		[Test]
 		public void ConnectWithQuotePassword()
 		{
-			execSQL("GRANT ALL ON *.* to 'test'@'localhost' IDENTIFIED BY '\"'");
-			execSQL("GRANT ALL ON *.* to 'test'@'%' IDENTIFIED BY '\"'");
-			MySqlConnection c = new MySqlConnection("server=" + host + ";uid=test;pwd='\"';pooling=false");
+			suExecSQL("GRANT ALL ON *.* to 'quotedUser'@'%' IDENTIFIED BY '\"'");
+			suExecSQL("GRANT ALL ON *.* to 'quotedUser'@'%' IDENTIFIED BY '\"'");
+            string connStr = GetConnectionStringEx("quotedUser", null, false);
+            connStr += ";pwd='\"'";
+			MySqlConnection c = new MySqlConnection(connStr);
 			try
 			{
 				c.Open();
@@ -342,7 +341,7 @@
 			{
 				Assert.Fail(ex.Message);
 			}
-			execSQL("DELETE FROM mysql.user WHERE user='test'");
+			suExecSQL("DELETE FROM mysql.user WHERE user='quotedUser'");
 		}
 	}
 }

Modified: branches/1.0/TestSuite/DataReaderTests.cs
===================================================================
--- branches/1.0/TestSuite/DataReaderTests.cs	2006-12-14 20:48:31 UTC (rev 501)
+++ branches/1.0/TestSuite/DataReaderTests.cs	2006-12-14 21:40:23 UTC (rev 502)
@@ -818,7 +818,8 @@
 		{
 			execSQL("DROP TABLE IF EXISTS test");
 			execSQL("CREATE TABLE test (id int, PRIMARY KEY(id))");
-			MySqlCommand cmd = new MySqlCommand("SHOW INDEX FROM test FROM test", conn);
+			MySqlCommand cmd = new MySqlCommand(
+                String.Format("SHOW INDEX FROM test FROM {0}", databases[0]), conn);
 			MySqlDataReader reader = null;
 			try
 			{
@@ -858,5 +859,21 @@
 				Assert.IsNull(dt);
 			}
 		}
+
+        /// <summary>
+        /// Bug #24765  	Retrieving empty fields results in check for isDBNull
+        /// </summary>
+        [Test]
+        public void IsDbNullOnNonNullFields()
+        {
+            execSQL("INSERT INTO test (id, name) VALUES (1, '')");
+
+            MySqlCommand cmd = new MySqlCommand("SELECT * FROM test", conn);
+            using (MySqlDataReader reader = cmd.ExecuteReader())
+            {
+                Assert.IsTrue(reader.Read());
+                Assert.IsFalse(reader.IsDBNull(1));
+            }
+        }
 	}
 }

Modified: branches/1.0/TestSuite/EventTests.cs
===================================================================
--- branches/1.0/TestSuite/EventTests.cs	2006-12-14 20:48:31 UTC (rev 501)
+++ branches/1.0/TestSuite/EventTests.cs	2006-12-14 21:40:23 UTC (rev 502)
@@ -51,7 +51,10 @@
 		{
 			conn.InfoMessage += new MySqlInfoMessageEventHandler(WarningsInfoMessage);
 
-			MySqlCommand cmd = new MySqlCommand("SELECT * FROM mysql.host WHERE TIME('2005/6/21')", conn);
+            execSQL("DROP TABLE IF EXISTS test");
+            execSQL("CREATE TABLE test (name VARCHAR(10))");
+
+			MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES ('12345678901')", conn);
 			MySqlDataReader reader = null;
 
 			try

Modified: branches/1.0/TestSuite/LanguageTests.cs
===================================================================
--- branches/1.0/TestSuite/LanguageTests.cs	2006-12-14 20:48:31 UTC (rev 501)
+++ branches/1.0/TestSuite/LanguageTests.cs	2006-12-14 21:40:23 UTC (rev 502)
@@ -342,9 +342,7 @@
 		[Category("4.1")]
 		public void VariousCollations()
 		{
-			execSQL("DROP DATABASE IF EXISTS dbtest");
 			execSQL("DROP TABLE IF EXISTS test_tbl");
-			execSQL("CREATE DATABASE `dbtest` DEFAULT CHARACTER SET utf8 COLLATE utf8_swedish_ci");
 			execSQL("CREATE TABLE `test_tbl` ( `test` VARCHAR( 255 ) NOT NULL) CHARACTER SET utf8 COLLATE utf8_swedish_ci TYPE = MYISAM");
 			execSQL("INSERT INTO test_tbl VALUES ('myval')");
 			try
@@ -357,7 +355,6 @@
 				Assert.Fail(ex.Message);
 			}
 			execSQL("DROP TABLE test_tbl");
-			execSQL("DROP DATABASE dbtest");
 		}
 	}
 }

Modified: branches/1.0/TestSuite/MySqlHelperTests.cs
===================================================================
--- branches/1.0/TestSuite/MySqlHelperTests.cs	2006-12-14 20:48:31 UTC (rev 501)
+++ branches/1.0/TestSuite/MySqlHelperTests.cs	2006-12-14 21:40:23 UTC (rev 502)
@@ -24,6 +24,7 @@
 using System.Globalization;
 using System.Threading;
 using NUnit.Framework;
+using System.Text;
 
 namespace MySql.Data.MySqlClient.Tests
 {
@@ -56,8 +57,11 @@
 
 			try
 			{
-				reader = MySqlHelper.ExecuteReader(this.GetConnectionString(true),
-					"SELECT * FROM mysql.host WHERE TIME('2005/6/21')");
+                StringBuilder sb = new StringBuilder();
+                for (int i=0; i < 254; i++)
+                    sb.Append('a');
+                string sql = "INSERT INTO test (name) VALUES ('" + sb.ToString() + "')";
+				reader = MySqlHelper.ExecuteReader(this.GetConnectionString(true), sql);
 			}
 			catch (Exception ex)
 			{

Modified: branches/1.0/TestSuite/PoolingTests.cs
===================================================================
--- branches/1.0/TestSuite/PoolingTests.cs	2006-12-14 20:48:31 UTC (rev 501)
+++ branches/1.0/TestSuite/PoolingTests.cs	2006-12-14 21:40:23 UTC (rev 502)
@@ -34,7 +34,7 @@
 		public PoolingTests()
 			: base()
 		{
-			csAdditions = ";pooling=true; connection reset=true";
+			csAdditions = ";pooling=true; connection reset=true;";
 		}
 
 		[TestFixtureSetUp]

Modified: branches/1.0/TestSuite/StressTests.cs
===================================================================
--- branches/1.0/TestSuite/StressTests.cs	2006-12-14 20:48:31 UTC (rev 501)
+++ branches/1.0/TestSuite/StressTests.cs	2006-12-14 21:40:23 UTC (rev 502)
@@ -56,15 +56,16 @@
 			// currently do not test this with compression
 			if (conn.UseCompression) return;
 
-			execSQL("set @@global.max_allowed_packet=35000000");
-
 			MySqlConnection c = new MySqlConnection(conn.ConnectionString + ";pooling=false");
 			c.Open();
 
 			byte[] dataIn = Utils.CreateBlob(len);
 			byte[] dataIn2 = Utils.CreateBlob(len);
 
-			MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?id, NULL, ?blob, NULL )", c);
+            MySqlCommand cmd = new MySqlCommand("SET max_allowed_packet=35000000", c);
+            cmd.ExecuteNonQuery();
+
+            cmd.CommandText = "INSERT INTO Test VALUES (?id, NULL, ?blob, NULL )";
 			cmd.Parameters.Add(new MySqlParameter("?id", 1));
 			cmd.Parameters.Add(new MySqlParameter("?blob", dataIn));
 			try
@@ -111,7 +112,6 @@
 				if (reader != null) reader.Close();
 				c.Close();
 			}
-			execSQL("set @@global.max_allowed_packet=1047552");
 		}
 	}
 

Modified: branches/1.0/TestSuite/Syntax.cs
===================================================================
--- branches/1.0/TestSuite/Syntax.cs	2006-12-14 20:48:31 UTC (rev 501)
+++ branches/1.0/TestSuite/Syntax.cs	2006-12-14 21:40:23 UTC (rev 502)
@@ -135,12 +135,13 @@
 		[Test]
 		public void LoadDataLocalInfile()
 		{
-			execSQL("set @@global.max_allowed_packet=250000000");
-
 			string connString = conn.ConnectionString + ";pooling=false";
 			MySqlConnection c = new MySqlConnection(connString);
 			c.Open();
 
+            MySqlCommand cmd = new MySqlCommand("SET max_allowed_packet=250000000", c);
+            cmd.ExecuteNonQuery();
+
 			string path = Path.GetTempFileName();
 			StreamWriter sw = new StreamWriter(path);
 			for (int i = 0; i < 2000000; i++)
@@ -149,7 +150,7 @@
 			sw.Close();
 
 			path = path.Replace(@"\", @"\\");
-			MySqlCommand cmd = new MySqlCommand("LOAD DATA LOCAL INFILE '" + path + "' INTO TABLE Test FIELDS TERMINATED BY ','", c);
+            cmd.CommandText = "LOAD DATA LOCAL INFILE '" + path + "' INTO TABLE Test FIELDS TERMINATED BY ','";
 
 			object cnt = 0;
 			try
@@ -167,7 +168,6 @@
 			Assert.AreEqual(2000000, cnt);
 
 			c.Close();
-			execSQL("set @@global.max_allowed_packet=1047256");
 		}
 
 		[Test]

Thread
Connector/NET commit: r502 - branches/1.0/TestSuiterburnett14 Dec