diff --git a/MySQLDockerfile b/MySQLDockerfile index 86f1a9b2bb..a74f67a517 100644 --- a/MySQLDockerfile +++ b/MySQLDockerfile @@ -18,6 +18,7 @@ RUN apt install -y \ python3.8 \ python3-pip \ curl \ + wget \ pkg-config \ mysql-client \ libmysqlclient-dev \ @@ -26,6 +27,14 @@ RUN apt install -y \ ca-certificates-java \ bats +# install dotnet +RUN wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb +RUN dpkg -i packages-microsoft-prod.deb +RUN apt-get update; \ + apt-get install -y apt-transport-https && \ + apt-get update && \ + apt-get install -y dotnet-sdk-3.1 + # install node RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - RUN apt install -y nodejs diff --git a/mysql-client-tests/dotnet/.gitignore b/mysql-client-tests/dotnet/.gitignore new file mode 100644 index 0000000000..da19d74625 --- /dev/null +++ b/mysql-client-tests/dotnet/.gitignore @@ -0,0 +1,136 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +.vs + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +[Bb]in/ +[Oo]bj/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.svclog +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml +*.pubxml +*.azurePubxml + +# NuGet Packages Directory +## TODO: If you have NuGet Package Restore enabled, uncomment the next line +packages/ +## TODO: If the tool you use requires repositories.config, also uncomment the next line +!packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +![Ss]tyle[Cc]op.targets +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml + +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +_NCrunch* +ZZ \ No newline at end of file diff --git a/mysql-client-tests/dotnet/Program.cs b/mysql-client-tests/dotnet/Program.cs new file mode 100644 index 0000000000..6f5521caf1 --- /dev/null +++ b/mysql-client-tests/dotnet/Program.cs @@ -0,0 +1,81 @@ +using System; +using System.Data; + +using MySql.Data; +using MySql.Data.MySqlClient; + +class TestException : Exception +{ + public TestException(string message) + { + Console.WriteLine(message); + } +} + +public class DoltSQL +{ + public static int Main(string[] args) + { + if (args.Length != 3) + { + Console.WriteLine("Must supply $USER $PORT $REPO arguments."); + return 1; + } + + var user = args[0]; + var port = args[1]; + var db = args[2]; + + string connStr = $"server=127.0.0.1;user={user};database={db};port={port};CharSet=utf8;"; + MySqlConnection conn = new MySqlConnection(connStr); + + try + { + conn.Open(); + SetupTest(conn); + QueryTest(conn); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + + conn.Close(); + return 0; + } + + public static void SetupTest(MySqlConnection conn) + { + using var cmd = new MySqlCommand(); + cmd.Connection = conn; + + cmd.CommandText = @"CREATE TABLE test (pk int, value int, primary key(pk))"; + cmd.ExecuteNonQuery(); + + cmd.CommandText = "INSERT INTO test(pk, value) VALUES(0,0)"; + cmd.ExecuteNonQuery(); + } + + public static void QueryTest(MySqlConnection conn) + { + string sql = "SELECT count(*) as count FROM test"; + using (var cmd = new MySqlCommand(sql, conn)) + try + { + object result = cmd.ExecuteScalar(); + if (result != null) + { + int r = Convert.ToInt32(result); + if (r != 1) + { + TestException ex = new TestException($"Expected 1, Recieved {r}"); + throw ex; + } + } + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + } +} diff --git a/mysql-client-tests/dotnet/dotnet.csproj b/mysql-client-tests/dotnet/dotnet.csproj new file mode 100644 index 0000000000..fba6057574 --- /dev/null +++ b/mysql-client-tests/dotnet/dotnet.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp3.1 + + + + + + + diff --git a/mysql-client-tests/dotnet/dotnet.sln b/mysql-client-tests/dotnet/dotnet.sln new file mode 100644 index 0000000000..323b0b958d --- /dev/null +++ b/mysql-client-tests/dotnet/dotnet.sln @@ -0,0 +1,17 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet", "dotnet.csproj", "{E77B5EEB-5826-4C3A-BABC-337ACB3E2C47}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E77B5EEB-5826-4C3A-BABC-337ACB3E2C47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E77B5EEB-5826-4C3A-BABC-337ACB3E2C47}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E77B5EEB-5826-4C3A-BABC-337ACB3E2C47}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E77B5EEB-5826-4C3A-BABC-337ACB3E2C47}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/mysql-client-tests/mysql-client-tests.bats b/mysql-client-tests/mysql-client-tests.bats index a0ee3b1230..f4a05bc4bc 100644 --- a/mysql-client-tests/mysql-client-tests.bats +++ b/mysql-client-tests/mysql-client-tests.bats @@ -48,3 +48,9 @@ teardown() { (cd $BATS_TEST_DIRNAME/c; make clean; make) $BATS_TEST_DIRNAME/c/mysql-connector-c-test $USER $PORT $REPO_NAME } + +@test "dotnet mysql connector" { + cd $BATS_TEST_DIRNAME/dotnet/ + # dotnet run uses output channel 3 which conflicts with bats so we pipe it to null + dotnet run -- $USER $PORT $REPO_NAME 3>&- +}