Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
prepare 1.2.2 release (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-darkly authored Apr 6, 2021
1 parent 699e3cb commit 127140e
Show file tree
Hide file tree
Showing 17 changed files with 980 additions and 320 deletions.
14 changes: 13 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ jobs:
name: Build SDK
command: msbuild /restore /p:Configuration=Debug /p:TargetFramework=Xamarin.iOS10 src/LaunchDarkly.XamarinSdk/LaunchDarkly.XamarinSdk.csproj

- run:
name: Pre-build storyboard
command: >-
/Applications/Xcode.app/Contents/Developer/usr/bin/ibtool --errors --warnings --notices --output-format xml1 --minimum-deployment-target 10.0
--target-device iphone --target-device ipad --auto-activate-custom-fonts
--sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk
--compilation-directory /Users/distiller/project/tests/LaunchDarkly.XamarinSdk.iOS.Tests/obj/iPhoneSimulator/Debug/xamarin.ios10/ibtool
/Users/distiller/project/tests/LaunchDarkly.XamarinSdk.iOS.Tests/LaunchScreen.storyboard
# This is the exact ibtool command that msbuild runs to build the first storyboard. The difference is that msbuild sets some environment variables
# which cause this command to fail. By pre-running this command, some unknown state gets set up that allows future calls to ibtool to succeed.
# It is unclear where this state resides or how this works...

- run:
name: Build test project
command: msbuild /restore /p:Configuration=Debug /p:Platform=iPhoneSimulator tests/LaunchDarkly.XamarinSdk.iOS.Tests/LaunchDarkly.XamarinSdk.iOS.Tests.csproj
Expand All @@ -121,7 +133,7 @@ jobs:
- run:
name: Start simulator
command: |
xcrun simctl create xm-ios com.apple.CoreSimulator.SimDeviceType.iPhone-X com.apple.CoreSimulator.SimRuntime.iOS-12-2
xcrun simctl create xm-ios com.apple.CoreSimulator.SimDeviceType.iPhone-12 com.apple.CoreSimulator.SimRuntime.iOS-14-4
xcrun simctl boot xm-ios
- run:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to the LaunchDarkly Client-Side SDK for Xamarin will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org).

## [1.2.2] - 2021-04-06
### Fixed:
- The SDK was failing to get flags in streaming mode when connecting to a LaunchDarkly Relay Proxy instance.

## [1.2.1] - 2021-03-30
### Fixed:
- Removed unnecessary dependencies on `Xamarin.Android.Support.Core.Utils` and `Xamarin.Android.Support.CustomTabs`. (Thanks, [Vladimir-Mischenchuk](https://github.com/launchdarkly/xamarin-client-sdk/pull/25)!)
Expand Down
4 changes: 2 additions & 2 deletions src/LaunchDarkly.XamarinSdk/Factory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ internal static Func<IMobileUpdateProcessor> CreateUpdateProcessorFactory(Config
return configuration._updateProcessorFactory(configuration, flagCacheManager, user);
}

var featureFlagRequestor = new FeatureFlagRequestor(configuration, user);
if (configuration.IsStreamingEnabled && !inBackground)
{
return new MobileStreamingProcessor(configuration, flagCacheManager, user, null);
return new MobileStreamingProcessor(configuration, flagCacheManager, featureFlagRequestor, user, null);
}
else
{
var featureFlagRequestor = new FeatureFlagRequestor(configuration, user);
return new MobilePollingProcessor(featureFlagRequestor,
flagCacheManager,
user,
Expand Down
3 changes: 2 additions & 1 deletion src/LaunchDarkly.XamarinSdk/LaunchDarkly.XamarinSdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' and '$(LD_TARGET_FRAMEWORKS)' == '' ">netstandard1.6;netstandard2.0;net45;Xamarin.iOS10;MonoAndroid71;MonoAndroid80;MonoAndroid81;</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' and '$(LD_TARGET_FRAMEWORKS)' == '' ">netstandard1.6;netstandard2.0;Xamarin.iOS10;MonoAndroid71;MonoAndroid80;MonoAndroid81;</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' and '$(LD_TARGET_FRAMEWORKS)' != '' ">$(LD_TARGET_FRAMEWORKS)</TargetFrameworks>
<Version>1.2.1</Version>
<Version>1.2.2</Version>
<OutputType>Library</OutputType>
<AssemblyName>LaunchDarkly.XamarinSdk</AssemblyName>
<PackageId>LaunchDarkly.XamarinSdk</PackageId>
Expand All @@ -15,6 +15,7 @@
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<DesignTimeBuild>False</DesignTimeBuild>
<DisableExtraReferences>True</DisableExtraReferences>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

Expand Down
23 changes: 22 additions & 1 deletion src/LaunchDarkly.XamarinSdk/MobileStreamingProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ internal sealed class MobileStreamingProcessor : IMobileUpdateProcessor, IStream
private readonly IFlagCacheManager _cacheManager;
private readonly User _user;
private readonly StreamManager _streamManager;
private readonly IFeatureFlagRequestor _requestor;

internal MobileStreamingProcessor(Configuration configuration,
IFlagCacheManager cacheManager,
IFeatureFlagRequestor requestor,
User user,
StreamManager.EventSourceCreator eventSourceCreator)
{
this._configuration = configuration;
this._cacheManager = cacheManager;
this._requestor = requestor;
this._user = user;

var streamProperties = _configuration.UseReport ? MakeStreamPropertiesForReport() : MakeStreamPropertiesForGet();
Expand Down Expand Up @@ -116,7 +119,21 @@ Task IStreamProcessor.HandleMessage(StreamManager streamManager, string messageT
}
case Constants.PING:
{
streamManager.Initialized = true;
try
{
Task.Run(async () =>
{
var response = await _requestor.FeatureFlagsAsync();
var flagsAsJsonString = response.jsonResponse;
var flagsDictionary = JsonUtil.DecodeJson<ImmutableDictionary<string, FeatureFlag>>(flagsAsJsonString);
_cacheManager.CacheFlagsFromService(flagsDictionary, _user);
streamManager.Initialized = true;
});
}
catch (Exception ex)
{
Log.ErrorFormat("Error in handling PING message: {1}", Util.ExceptionMessage(ex));
}
break;
}
default:
Expand Down Expand Up @@ -166,6 +183,10 @@ private void Dispose(bool disposing)
if (disposing)
{
((IDisposable)_streamManager).Dispose();
if (_requestor != null)
{
_requestor.Dispose();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
<Compile Include="..\LaunchDarkly.XamarinSdk.Tests\FlagChangedEventTests.cs">
<Link>SharedTestCode\FlagChangedEventTests.cs</Link>
</Compile>
<Compile Include="..\LaunchDarkly.XamarinSdk.Tests\HttpHelpers.cs">
<Link>SharedTestCode\HttpHelpers.cs</Link>
</Compile>
<Compile Include="..\LaunchDarkly.XamarinSdk.Tests\LDClientEndToEndTests.cs">
<Link>SharedTestCode\LDClientEndToEndTests.cs</Link>
</Compile>
Expand Down Expand Up @@ -112,9 +115,6 @@
<Compile Include="..\LaunchDarkly.XamarinSdk.Tests\UserFlagCacheTests.cs">
<Link>SharedTestCode\UserFlagCacheTests.cs</Link>
</Compile>
<Compile Include="..\LaunchDarkly.XamarinSdk.Tests\WireMockExtensions.cs">
<Link>SharedTestCode\WireMockExtensions.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="Properties\AndroidManifest.xml" />
Expand Down Expand Up @@ -148,16 +148,12 @@
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.1" />
<PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="28.0.0.1" />
<PackageReference Include="Xamarin.Android.Support.CustomTabs" Version="28.0.0.1" />
<PackageReference Include="Common.Logging" Version="3.4.1">
</PackageReference>
<PackageReference Include="WireMock.Net" Version="1.0.22">
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1">
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.0.0.497661">
</PackageReference>
<PackageReference Include="xunit.runner.devices" Version="2.5.25">
</PackageReference>
<PackageReference Include="Common.Logging" Version="3.4.1" />
<PackageReference Include="EmbedIO" Version="3.4.3" />
<PackageReference Include="LaunchDarkly.CommonSdk" Version="4.3.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Xamarin.Forms" Version="4.0.0.497661" />
<PackageReference Include="xunit.runner.devices" Version="2.5.25" />
</ItemGroup>
<ItemGroup>
<Folder Include="SharedTestCode\" />
Expand Down
54 changes: 7 additions & 47 deletions tests/LaunchDarkly.XamarinSdk.Tests/BaseTest.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Common.Logging;
using LaunchDarkly.Client;
using WireMock.Logging;
using WireMock.Server;
using WireMock.Settings;
using Xunit;
using Xunit.Abstractions;

namespace LaunchDarkly.Xamarin.Tests
{
Expand All @@ -19,56 +15,20 @@ public BaseTest()
TestUtil.ClearClient();
}

public void Dispose()
public BaseTest(ITestOutputHelper testOutput)
{
LogManager.Adapter = new LogSinkFactoryAdapter(testOutput.WriteLine);
TestUtil.ClearClient();
}

protected void ClearCachedFlags(User user)
{
PlatformSpecific.Preferences.Clear(Constants.FLAGS_KEY_PREFIX + user.Key);
}

protected void WithServer(Action<FluentMockServer> a)
{
var s = MakeServer();
try
{
a(s);
}
finally
{
s.Stop();
}
}

protected async Task WithServerAsync(Func<FluentMockServer, Task> a)
public void Dispose()
{
var s = MakeServer();
try
{
await a(s);
}
finally
{
s.Stop();
}
TestUtil.ClearClient();
}

protected FluentMockServer MakeServer()
protected void ClearCachedFlags(User user)
{
// currently we don't need to customize any server settings
var server = FluentMockServer.Start();

// Perform an initial request to make sure the server has warmed up. On Android in particular, startup
// of the very first server instance in the test run seems to be very slow, which may cause the first
// request made by unit tests to time out.
using (var client = new HttpClient())
{
AsyncUtils.WaitSafely(() => client.GetAsync(server.Urls[0]));
}
server.ResetLogEntries(); // so the initial request doesn't interfere with test postconditions
return server;
PlatformSpecific.Preferences.Clear(Constants.FLAGS_KEY_PREFIX + user.Key);
}
}
}
21 changes: 10 additions & 11 deletions tests/LaunchDarkly.XamarinSdk.Tests/FeatureFlagRequestorTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Threading.Tasks;
using LaunchDarkly.Client;
using LaunchDarkly.Xamarin.Tests.HttpHelpers;
using Xunit;

namespace LaunchDarkly.Xamarin.Tests
Expand All @@ -27,19 +28,17 @@ public class FeatureFlagRequestorTests : BaseTest
[InlineData("/basepath", true, "/basepath/msdk/evalx/users/", "?withReasons=true")]
[InlineData("/basepath/", false, "/basepath/msdk/evalx/users/", "")]
[InlineData("/basepath/", true, "/basepath/msdk/evalx/users/", "?withReasons=true")]
public async Task GetFlagsUsesCorrectUriAndMethodInGetModexAsync(
public async Task GetFlagsUsesCorrectUriAndMethodInGetModeAsync(
string baseUriExtraPath,
bool withReasons,
string expectedPathWithoutUser,
string expectedQuery
)
{
await WithServerAsync(async server =>
using (var server = TestHttpServer.Start(Handlers.JsonResponse("{}")))
{
server.ForAllRequests(r => r.WithJsonBody(_allDataJson));

var config = Configuration.Builder(_mobileKey)
.BaseUri(new Uri(server.GetUrl() + baseUriExtraPath))
.BaseUri(new Uri(server.Uri.ToString() + baseUriExtraPath))
.EvaluationReasons(withReasons)
.Build();

Expand All @@ -49,14 +48,14 @@ await WithServerAsync(async server =>
Assert.Equal(200, resp.statusCode);
Assert.Equal(_allDataJson, resp.jsonResponse);

var req = server.GetLastRequest();
var req = server.Recorder.RequireRequest();
Assert.Equal("GET", req.Method);
Assert.Equal(expectedPathWithoutUser + _encodedUser, req.Path);
Assert.Equal(expectedQuery, req.RawQuery);
Assert.Equal(_mobileKey, req.Headers["Authorization"][0]);
Assert.Equal(expectedQuery, req.Query);
Assert.Equal(_mobileKey, req.Headers["Authorization"]);
Assert.Null(req.Body);
}
});
}
}

// Report mode is currently disabled - ch47341
Expand All @@ -81,7 +80,7 @@ await WithServerAsync(async server =>
// Assert.Equal($"/msdk/evalx/user", req.Path);
// Assert.Equal("", req.RawQuery);
// Assert.Equal(_mobileKey, req.Headers["Authorization"][0]);
// TestUtil.AssertJsonEquals(JToken.Parse(_userJson), TestUtil.NormalizeJsonUser(JToken.Parse(req.Body)));
// TestUtil.AssertJsonEquals(LdValue.Parse(_userJson), TestUtil.NormalizeJsonUser(LdValue.Parse(req.Body)));
// }
// });
//}
Expand All @@ -107,7 +106,7 @@ await WithServerAsync(async server =>
// Assert.Equal($"/msdk/evalx/user", req.Path);
// Assert.Equal("?withReasons=true", req.RawQuery);
// Assert.Equal(_mobileKey, req.Headers["Authorization"][0]);
// TestUtil.AssertJsonEquals(JToken.Parse(_userJson), TestUtil.NormalizeJsonUser(JToken.Parse(req.Body)));
// TestUtil.AssertJsonEquals(LdValue.Parse(_userJson), TestUtil.NormalizeJsonUser(LdValue.Parse(req.Body)));
// }
// });
//}
Expand Down
Loading

0 comments on commit 127140e

Please sign in to comment.