Repository: microsoft/garnet
File: test/Garnet.test/GarnetServerConfigTests.cs (C#)

Code before:
                ClassicAssert.IsTrue(parseSuccessful);
                ClassicAssert.AreEqual(invalidOptions.Count, 0);
                ClassicAssert.IsTrue(options.PageSize == "4m");
                ClassicAssert.IsTrue(options.MemorySize == "128m");

                args = ["--storage-string", AzureEmulatedStorageString, "--use-azure-storage-for-config-import", "true", "--config-import-path", configPath];
                parseSuccessful = ServerSettingsManager.TryParseCommandLineArguments(args, out options, out invalidOptions, out _, silentMode: true);
                ClassicAssert.IsTrue(parseSuccessful);
                ClassicAssert.AreEqual(invalidOptions.Count, 0);
                ClassicAssert.IsTrue(options.PageSize == "4m");
                ClassicAssert.IsTrue(options.MemorySize == "128m");

                // Delete blob
                deviceFactory.Delete(new FileDescriptor { directoryName = "" });
            }
        }

        [Test]
        public void AzureStorageConfiguration()
        {
            // missing both storage-string and storage-service-uri
            var args = new string[] { "--use-azure-storage", "true" };
            var parseSuccessful = ServerSettingsManager.TryParseCommandLineArguments(args, out var options, out var invalidOptions, out _, silentMode: true);
            ClassicAssert.IsTrue(parseSuccessful);
            ClassicAssert.AreEqual(invalidOptions.Count, 0);
            Assert.Throws<InvalidAzureConfiguration>(() => options.GetServerOptions());

            // valid storage-string
            args = ["--use-azure-storage", "--storage-string", "UseDevelopmentStorage=true;"];
            parseSuccessful = ServerSettingsManager.TryParseCommandLineArguments(args, out options, out invalidOptions, out _, silentMode: true);
            ClassicAssert.IsTrue(parseSuccessful);
            ClassicAssert.AreEqual(invalidOptions.Count, 0);
            Assert.DoesNotThrow(() => options.GetServerOptions());

            // secure service-uri with managed-identity
            args = ["--use-azure-storage", "--storage-service-uri", "https://demo.blob.core.windows.net", "--storage-managed-identity", "demo"];
            parseSuccessful = ServerSettingsManager.TryParseCommandLineArguments(args, out options, out invalidOptions, out _, silentMode: true);
            ClassicAssert.IsTrue(parseSuccessful);
            ClassicAssert.AreEqual(invalidOptions.Count, 0);
            Assert.DoesNotThrow(() => options.GetServerOptions());

            // secure service-uri with workload-identity and no managed-identity
            args = ["--use-azure-storage", "--storage-service-uri", "https://demo.blob.core.windows.net"];
            parseSuccessful = ServerSettingsManager.TryParseCommandLineArguments(args, out options, out invalidOptions, out _, silentMode: true);
            ClassicAssert.IsTrue(parseSuccessful);
            ClassicAssert.AreEqual(invalidOptions.Count, 0);
            Assert.DoesNotThrow(() => options.GetServerOptions());

            // insecure service-uri with managed-identity
            args = ["--use-azure-storage", "--storage-service-uri", "http://demo.blob.core.windows.net", "--storage-managed-identity", "demo"];
            parseSuccessful = ServerSettingsManager.TryParseCommandLineArguments(args, out options, out invalidOptions, out _, silentMode: true);

Review comment (suggestion):
Please also add testing logic for these new options in `ImportExportConfigAzure` - that will verify that serializing and deserializing the configuration to/from a `garnet.conf` file is also working.

Code after:

            var args = new[] { "--storage-string", AzureEmulatedStorageString, "--use-azure-storage-for-config-export", "true", "--config-export-path", configPath, "-p", "4m", "-m", "128m", "--storage-service-uri", "https://demo.blob.core.windows.net", "--storage-managed-identity", "demo" };
            parseSuccessful = ServerSettingsManager.TryParseCommandLineArguments(args, out options, out invalidOptions, out _, silentMode: true);
            ClassicAssert.IsTrue(parseSuccessful);
            ClassicAssert.AreEqual(invalidOptions.Count, 0);
            ClassicAssert.IsTrue(options.PageSize == "4m");
            ClassicAssert.IsTrue(options.MemorySize == "128m");
            ClassicAssert.IsTrue(options.AzureStorageServiceUri == "https://demo.blob.core.windows.net");
            ClassicAssert.IsTrue(options.AzureStorageManagedIdentity == "demo");

            args = ["--storage-string", AzureEmulatedStorageString, "--use-azure-storage-for-config-import", "true", "--config-import-path", configPath];
            parseSuccessful = ServerSettingsManager.TryParseCommandLineArguments(args, out options, out invalidOptions, out _, silentMode: true);
            ClassicAssert.IsTrue(parseSuccessful);
            ClassicAssert.AreEqual(invalidOptions.Count, 0);
            ClassicAssert.IsTrue(options.PageSize == "4m");
            ClassicAssert.IsTrue(options.MemorySize == "128m");
            ClassicAssert.IsTrue(options.AzureStorageServiceUri == "https://demo.blob.core.windows.net");
            ClassicAssert.IsTrue(options.AzureStorageManagedIdentity == "demo");

            // Delete blob
            deviceFactory.Delete(new FileDescriptor { directoryName = "" });
        }

        [Test]
        public void AzureStorageConfiguration()
        {
            // missing both storage-string and storage-service-uri
            var args = new string[] { "--use-azure-storage", "true" };
            var parseSuccessful = ServerSettingsManager.TryParseCommandLineArguments(args, out var options, out var invalidOptions, out _, silentMode: true);
            ClassicAssert.IsTrue(parseSuccessful);
            ClassicAssert.AreEqual(invalidOptions.Count, 0);
            Assert.Throws<InvalidAzureConfiguration>(() => options.GetServerOptions());

            // valid storage-string
            args = ["--use-azure-storage", "--storage-string", "UseDevelopmentStorage=true;"];
            parseSuccessful = ServerSettingsManager.TryParseCommandLineArguments(args, out options, out invalidOptions, out _, silentMode: true);
            ClassicAssert.IsTrue(parseSuccessful);
            ClassicAssert.AreEqual(invalidOptions.Count, 0);
            Assert.DoesNotThrow(() => options.GetServerOptions());

            // secure service-uri with managed-identity
            args = ["--use-azure-storage", "--storage-service-uri", "https://demo.blob.core.windows.net", "--storage-managed-identity", "demo"];
            parseSuccessful = ServerSettingsManager.TryParseCommandLineArguments(args, out options, out invalidOptions, out _, silentMode: true);
            ClassicAssert.IsTrue(parseSuccessful);
            ClassicAssert.AreEqual(invalidOptions.Count, 0);
            Assert.DoesNotThrow(() => options.GetServerOptions());

            // secure service-uri with workload-identity and no managed-identity
            args = ["--use-azure-storage", "--storage-service-uri", "https://demo.blob.core.windows.net"];
            parseSuccessful = ServerSettingsManager.TryParseCommandLineArguments(args, out options, out invalidOptions, out _, silentMode: true);
            ClassicAssert.IsTrue(parseSuccessful);