Skip to content

Commit 7d2f827

Browse files
committed
Refactor AppConfig feature flags.
Moving supported features to an enum will make it easier to extend config.json with additional features.
1 parent 35e7e0e commit 7d2f827

15 files changed

+91
-66
lines changed

.ci/config/config.buffer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"ConnectionString": "server=127.0.0.1;user id=mysqltest;password='test;key=\"val';port=3306;database=mysqltest;ssl mode=none;Use Affected Rows=true;BufferResultSets=true",
44
"PasswordlessUser": "no_password",
55
"SecondaryDatabase": "testdb2",
6-
"SupportsCachedProcedures": true,
7-
"SupportsJson": true,
6+
"SupportedFeatures": "Json,StoredProcedures",
87
"MySqlBulkLoaderLocalCsvFile": "%TESTDATA%/LoadData_UTF8_BOM_Unix.CSV",
98
"MySqlBulkLoaderLocalTsvFile": "%TESTDATA%/LoadData_UTF8_BOM_Unix.TSV"
109
}

.ci/config/config.compression+ssl.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"ConnectionString": "server=127.0.0.1;user id=ssltest;password=test;port=3306;database=mysqltest;ssl mode=required;use compression=true;Use Affected Rows=true",
44
"PasswordlessUser": "no_password",
55
"SecondaryDatabase": "testdb2",
6-
"SupportsCachedProcedures": true,
7-
"SupportsJson": true,
6+
"SupportedFeatures": "Json,StoredProcedures",
87
"MySqlBulkLoaderLocalCsvFile": "%TESTDATA%/LoadData_UTF8_BOM_Unix.CSV",
98
"MySqlBulkLoaderLocalTsvFile": "%TESTDATA%/LoadData_UTF8_BOM_Unix.TSV"
109
}

.ci/config/config.compression.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"ConnectionString": "server=127.0.0.1;user id=mysqltest;password='test;key=\"val';port=3306;database=mysqltest;ssl mode=none;UseCompression=true;Use Affected Rows=true",
44
"PasswordlessUser": "no_password",
55
"SecondaryDatabase": "testdb2",
6-
"SupportsCachedProcedures": true,
7-
"SupportsJson": true,
6+
"SupportedFeatures": "Json,StoredProcedures",
87
"MySqlBulkLoaderLocalCsvFile": "%TESTDATA%/LoadData_UTF8_BOM_Unix.CSV",
98
"MySqlBulkLoaderLocalTsvFile": "%TESTDATA%/LoadData_UTF8_BOM_Unix.TSV"
109
}

.ci/config/config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"ConnectionString": "server=127.0.0.1;user id=mysqltest;password='test;key=\"val';port=3306;database=mysqltest;ssl mode=none;Use Affected Rows=true",
44
"PasswordlessUser": "no_password",
55
"SecondaryDatabase": "testdb2",
6-
"SupportsCachedProcedures": true,
7-
"SupportsJson": true,
6+
"SupportedFeatures": "Json,StoredProcedures",
87
"MySqlBulkLoaderLocalCsvFile": "%TESTDATA%/LoadData_UTF8_BOM_Unix.CSV",
98
"MySqlBulkLoaderLocalTsvFile": "%TESTDATA%/LoadData_UTF8_BOM_Unix.TSV"
109
}

.ci/config/config.ssl.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"ConnectionString": "server=127.0.0.1;user id=ssltest;password=test;port=3306;database=mysqltest;ssl mode=required;certificate file=../../../../../.ci/server/certs/ssl-client.pfx;Use Affected Rows=true",
44
"PasswordlessUser": "no_password",
55
"SecondaryDatabase": "testdb2",
6-
"SupportsCachedProcedures": true,
7-
"SupportsJson": true,
6+
"SupportedFeatures": "Json,StoredProcedures",
87
"MySqlBulkLoaderLocalCsvFile": "%TESTDATA%/LoadData_UTF8_BOM_Unix.CSV",
98
"MySqlBulkLoaderLocalTsvFile": "%TESTDATA%/LoadData_UTF8_BOM_Unix.TSV"
109
}

.ci/config/config.uds+ssl.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"ConnectionString": "server=./../../../../../.ci/mysqld/mysqld.sock;user id=ssltest;password=test;database=mysqltest;ssl mode=required;Use Affected Rows=true",
44
"PasswordlessUser": "no_password",
55
"SecondaryDatabase": "testdb2",
6-
"SupportsCachedProcedures": true,
7-
"SupportsJson": true,
6+
"SupportedFeatures": "Json,StoredProcedures",
87
"MySqlBulkLoaderLocalCsvFile": "%TESTDATA%/LoadData_UTF8_BOM_Unix.CSV",
98
"MySqlBulkLoaderLocalTsvFile": "%TESTDATA%/LoadData_UTF8_BOM_Unix.TSV"
109
}

.ci/config/config.uds.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"ConnectionString": "server=./../../../../../.ci/run/mysql/mysqld.sock;user id=mysqltest;password='test;key=\"val';database=mysqltest;ssl mode=none;Use Affected Rows=true",
44
"PasswordlessUser": "no_password",
55
"SecondaryDatabase": "testdb2",
6-
"SupportsCachedProcedures": true,
7-
"SupportsJson": true,
6+
"SupportedFeatures": "Json,StoredProcedures",
87
"MySqlBulkLoaderLocalCsvFile": "%TESTDATA%/LoadData_UTF8_BOM_Unix.CSV",
98
"MySqlBulkLoaderLocalTsvFile": "%TESTDATA%/LoadData_UTF8_BOM_Unix.TSV"
109
}

.ci/use-config.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
cd $(dirname $0)/config
33

44
display_usage() {
5-
echo -e "\nUsage:\n$0 [config.json script] [host] [port] [name] [supports json]\n"
5+
echo -e "\nUsage:\n$0 [config.json script] [host] [port] [name] [features]\n"
66
}
77

88
# check whether user had supplied -h or --help . If yes display usage
@@ -45,5 +45,5 @@ fi
4545

4646
if [ $# -ge 5 ]
4747
then
48-
sed -i "s/\"SupportsJson\": true/\"SupportsJson\": $5/g" ../../tests/SideBySide/config.json
48+
sed -i "s/\"SupportedFeatures\": \".*\"/\"SupportedFeatures\": \"$5\"/g" ../../tests/SideBySide/config.json
4949
fi

.travis.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ services: docker
55
env:
66
- IMAGE=mysql:5.7
77
NAME=mysql
8-
SUPPORTS_JSON=true
8+
FEATURES=Json,StoredProcedures
99
- IMAGE=percona:5.7
1010
NAME=percona
11-
SUPPORTS_JSON=true
11+
FEATURES=Json,StoredProcedures
1212
- IMAGE=mariadb:10.3
1313
NAME=mariadb
14-
SUPPORTS_JSON=false
14+
FEATURES=StoredProcedures
1515

1616
before_install:
1717
- .ci/docker-run.sh $IMAGE $NAME 3307
@@ -24,13 +24,13 @@ script:
2424
- dotnet restore
2525
- dotnet test tests/MySqlConnector.Tests/MySqlConnector.Tests.csproj -c Release -f netcoreapp1.1.1
2626
- dotnet build tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp1.1.1
27-
- echo 'Executing tests with No Compression, No SSL' && ./.ci/use-config.sh config.json 172.17.0.1 3307 $NAME $SUPPORTS_JSON && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp1.1.1
27+
- echo 'Executing tests with No Compression, No SSL' && ./.ci/use-config.sh config.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp1.1.1
2828
- echo 'Executing Debug Only tests' && time dotnet test tests/SideBySide/SideBySide.csproj -c Debug -f netcoreapp1.1.1 --filter "FullyQualifiedName~SideBySide.DebugOnlyTests"
29-
- echo 'Executing tests with Compression, No SSL' && ./.ci/use-config.sh config.compression.json 172.17.0.1 3307 $NAME $SUPPORTS_JSON && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp1.1.1
30-
- echo 'Executing tests with No Compression, SSL' && ./.ci/use-config.sh config.ssl.json 172.17.0.1 3307 $NAME $SUPPORTS_JSON && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp1.1.1
31-
- echo 'Executing tests with Compression, SSL' && ./.ci/use-config.sh config.compression+ssl.json 172.17.0.1 3307 $NAME $SUPPORTS_JSON && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp1.1.1
32-
- echo 'Executing tests with Unix Domain Socket, No Compression, No SSL' && ./.ci/use-config.sh config.uds.json 172.17.0.1 3307 $NAME $SUPPORTS_JSON && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp1.1.1
33-
- echo 'Executing tests with Buffering, No Compression, No SSL' && ./.ci/use-config.sh config.buffer.json 172.17.0.1 3307 $NAME $SUPPORTS_JSON && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp1.1.1
29+
- echo 'Executing tests with Compression, No SSL' && ./.ci/use-config.sh config.compression.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp1.1.1
30+
- echo 'Executing tests with No Compression, SSL' && ./.ci/use-config.sh config.ssl.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp1.1.1
31+
- echo 'Executing tests with Compression, SSL' && ./.ci/use-config.sh config.compression+ssl.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp1.1.1
32+
- echo 'Executing tests with Unix Domain Socket, No Compression, No SSL' && ./.ci/use-config.sh config.uds.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp1.1.1
33+
- echo 'Executing tests with Buffering, No Compression, No SSL' && ./.ci/use-config.sh config.buffer.json 172.17.0.1 3307 $NAME $FEATURES && time dotnet test tests/SideBySide/SideBySide.csproj -c Release -f netcoreapp1.1.1
3434

3535
after_script:
3636
- chmod +x .ci/build-docs.sh && ./.ci/build-docs.sh

tests/SideBySide/AppConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public static IConfiguration Config
5151

5252
public static string SecondaryDatabase => Config.GetValue<string>("Data:SecondaryDatabase");
5353

54-
public static bool SupportsCachedProcedures => Config.GetValue<bool>("Data:SupportsCachedProcedures");
54+
public static ServerFeatures SupportedFeatures => (ServerFeatures) Enum.Parse(typeof(ServerFeatures), Config.GetValue<string>("Data:SupportedFeatures"));
5555

56-
public static bool SupportsJson => Config.GetValue<bool>("Data:SupportsJson");
56+
public static bool SupportsJson => SupportedFeatures.HasFlag(ServerFeatures.Json);
5757

5858
public static string MySqlBulkLoaderCsvFile => ExpandVariables(Config.GetValue<string>("Data:MySqlBulkLoaderCsvFile"));
5959
public static string MySqlBulkLoaderLocalCsvFile => ExpandVariables(Config.GetValue<string>("Data:MySqlBulkLoaderLocalCsvFile"));

0 commit comments

Comments
 (0)