Skip to content

feat(dfm): Integrate DFM with optimizely #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 48 commits into from
Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
5cbd740
Initial structure
msohailhussain Apr 9, 2019
f6487ae
cleanup
msohailhussain Apr 9, 2019
e385a95
added builder class
msohailhussain Apr 10, 2019
4eb4104
Extracted ProjectConfig into its own interface and updated HttpProjec…
mfahadahmed Apr 10, 2019
33cc9fa
Added polling unit tests.
mfahadahmed Apr 10, 2019
16729e9
Working on Config manager.
mfahadahmed Apr 11, 2019
43c1175
Extacted ProjectConfig into a separate interface and create DatafileP…
mfahadahmed Apr 12, 2019
904072e
Removed old ProjectConfig references.
mfahadahmed Apr 12, 2019
9586f2c
Merge remote-tracking branch 'origin/master' into sohail/dfm
mfahadahmed Apr 12, 2019
cadf4ee
Fixed missing file references.
mfahadahmed Apr 12, 2019
f49e833
Update ConfigManager classes to block execution until ProjectConfig r…
mfahadahmed Apr 23, 2019
6189f26
Added config manager unit tests and fix failing tests.
mfahadahmed Apr 24, 2019
5f9a371
Updated fm
msohailhussain May 23, 2019
e287ee7
Added unit tests and AtomicProjectConfigManager class.
mfahadahmed May 24, 2019
74a2833
Adding unit tests.
msohailhussain May 29, 2019
1d6b3d6
unit test added and 4.0 compat.
msohailhussain May 29, 2019
44d94c4
Resolved compatible issues.
msohailhussain May 29, 2019
2b220b0
Merge branch 'master' into sohail/dfm
msohailhussain May 29, 2019
dc20812
Removed DFM implementation in Optimizely from this PR. Mainly focus o…
msohailhussain May 30, 2019
b41e26b
optimizely changes.
msohailhussain May 30, 2019
a285f1e
Resolved datafile management namespace issue.
msohailhussain May 30, 2019
72869c7
Datafilemore cleanup
msohailhussain May 30, 2019
45cb133
Merge branch 'sohail/dfm' into sohail/optimizelydfm
msohailhussain May 30, 2019
783c479
integrated projectconfigmanagez
msohailhussain May 30, 2019
7f209a2
Moved ProjectConfig file
msohailhussain May 31, 2019
99e7a11
renamed to fallback project config manager
msohailhussain May 31, 2019
0c51253
Remover parse and added logger and error handler
msohailhussain May 31, 2019
8fdda5b
Merge branch 'sohail/dfm' into sohail/optimizelydfm
msohailhussain May 31, 2019
249b201
Changed namespace & removed SetConfig from interface.
msohailhussain Jun 3, 2019
6b69f7c
Merge branch 'sohail/dfm' into sohail/optimizelydfm
msohailhussain Jun 3, 2019
3cc9446
Added config in all methods.
msohailhussain Jun 3, 2019
3a1f0dc
rename issues resolved.
msohailhussain Jun 3, 2019
e76ceb7
Integrating dfm with optimizely
msohailhussain Jun 4, 2019
6297b83
comments addressed.
msohailhussain Jun 4, 2019
80a4014
matt’s feedback added.
msohailhussain Jun 4, 2019
aaac4e8
Nit fix
msohailhussain Jun 4, 2019
112937a
Merge branch 'sohail/dfm' into sohail/optimizelydfm
msohailhussain Jun 4, 2019
a904f2a
added optimizelyfactory and get variation private method to use config.
msohailhussain Jun 4, 2019
8787a14
corrected condition
msohailhussain Jun 11, 2019
3b2f4c7
Merge branch 'sohail/dfmcomplete' into sohail/optimizelydfm
msohailhussain Jun 12, 2019
2521a31
Added missing documentation.
msohailhussain Jun 12, 2019
8efa7a7
Move forced variation back to ProjectConfig.
mfahadahmed Jun 13, 2019
6441b00
refac(decisions): Move forced variations into DecisionService. (#162)
mfahadahmed Jun 14, 2019
221a81c
Revert "refac(decisions): Move forced variations into DecisionService…
msohailhussain Jun 14, 2019
4ed3b89
consolidated mike’s feedback
msohailhussain Jun 14, 2019
ce6e962
Resolved one left comment.
msohailhussain Jun 14, 2019
9b12d38
Logging issue fixed and fallback issue fixed.
msohailhussain Jun 15, 2019
d4a0476
Changed IsValid
msohailhussain Jun 17, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions OptimizelySDK.Net40/OptimizelySDK.Net40.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@
<Compile Include="..\OptimizelySDK\Config\FallbackProjectConfigManager.cs">
<Link>Config\FallbackProjectConfigManager.cs</Link>
</Compile>
<Compile Include="..\OptimizelySDK\OptimizelyFactory.cs">
<Link>OptimizelyFactory.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="..\OptimizelySDK\Utils\schema.json">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
<Compile Include="..\OptimizelySDK\Config\FallbackProjectConfigManager.cs">
<Link>AtomicProjectConfigManager.cs</Link>
</Compile>
<Compile Include="..\OptimizelySDK\OptimizelyFactory.cs">
<Link>OptimizelyFactory.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\OptimizelySDK\Utils\schema.json">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ namespace OptimizelySDK.Tests.DatafileManagement_Tests
[TestFixture]
public class AtomicProjectConfigManagerTest
{
private FallbackProjectConfigManager ConfigManager = new FallbackProjectConfigManager();
private FallbackProjectConfigManager ConfigManager;

[Test]
public void TestStaticProjectConfigManagerReturnsCorrectProjectConfig()
{
var expectedConfig = DatafileProjectConfig.Create(TestData.TypedAudienceDatafile, null, null);
ConfigManager.SetConfig(expectedConfig);
ConfigManager = new FallbackProjectConfigManager(expectedConfig);

Assert.True(TestData.CompareObjects(expectedConfig, ConfigManager.GetConfig()));
}
}
Expand Down
182 changes: 92 additions & 90 deletions OptimizelySDK.Tests/DecisionServiceTest.cs

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions OptimizelySDK.Tests/EntityTests/FeatureVariableTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using NUnit.Framework;
using OptimizelySDK.Entity;

namespace OptimizelySDK.Tests.EntityTests
{
[TestFixture]
public class FeatureVariableTest
{
[Test]
public void TestFeatureVariableTypeName()
{
Assert.AreEqual(FeatureVariable.GetFeatureVariableTypeName(FeatureVariable.VariableType.BOOLEAN), "GetFeatureVariableBoolean");
Assert.AreEqual(FeatureVariable.GetFeatureVariableTypeName(FeatureVariable.VariableType.DOUBLE), "GetFeatureVariableDouble");
Assert.AreEqual(FeatureVariable.GetFeatureVariableTypeName(FeatureVariable.VariableType.INTEGER), "GetFeatureVariableInteger");
Assert.AreEqual(FeatureVariable.GetFeatureVariableTypeName(FeatureVariable.VariableType.STRING), "GetFeatureVariableString");
}
}
}
9 changes: 5 additions & 4 deletions OptimizelySDK.Tests/OptimizelySDK.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
<ItemGroup>
<Compile Include="AudienceConditionsTests\ConditionEvaluationTest.cs" />
<Compile Include="AudienceConditionsTests\ConditionsTest.cs" />
<Compile Include="DatafileManagement Tests\HttpProjectConfigManagerTest.cs" />
<Compile Include="DatafileManagement Tests\PollingProjectConfigManagerTest.cs" />
<Compile Include="DatafileManagement Tests\AtomicProjectConfigManagerTest.cs" />
<Compile Include="ConfigTest\HttpProjectConfigManagerTest.cs" />
<Compile Include="ConfigTest\PollingProjectConfigManagerTest.cs" />
<Compile Include="ConfigTest\FallbackProjectConfigManagerTest.cs" />
<Compile Include="DecisionServiceTest.cs" />
<Compile Include="DefaultErrorHandlerTest.cs" />
<Compile Include="EventTests\DefaultEventDispatcherTest.cs" />
Expand All @@ -95,7 +95,8 @@
<Compile Include="UtilsTests\PrivateObject.cs" />
<Compile Include="UtilsTests\ValidatorTest.cs" />
<Compile Include="ValidEventDispatcher.cs" />
<Compile Include="DatafileManagement Tests\TestPollingProjectConfigManager.cs" />
<Compile Include="ConfigTest\TestPollingProjectConfigManager.cs" />
<Compile Include="EntityTests\FeatureVariableTest.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="App.config" />
Expand Down
203 changes: 140 additions & 63 deletions OptimizelySDK.Tests/OptimizelyTest.cs

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions OptimizelySDK.Tests/ProjectConfigTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -669,41 +669,41 @@ public void TestSetGetForcedVariation()
var optlyObject = new Optimizely(TestData.Datafile, new ValidEventDispatcher(), LoggerMock.Object);
optlyObject.Activate("test_experiment", "test_user", userAttributes);

// invalid experiment key should return a null variation
// invalid experiment key should return a null variation
Assert.False(Config.SetForcedVariation(invalidExperimentKey, userId, expectedVariationKey));
Assert.Null(Config.GetForcedVariation(invalidExperimentKey, userId));

// setting a null variation should return a null variation
// setting a null variation should return a null variation
Assert.True(Config.SetForcedVariation(experimentKey, userId, null));
Assert.Null(Config.GetForcedVariation(experimentKey, userId));

// setting an invalid variation should return a null variation
// setting an invalid variation should return a null variation
Assert.False(Config.SetForcedVariation(experimentKey, userId, invalidVariationKey));
Assert.Null(Config.GetForcedVariation(experimentKey, userId));

// confirm the forced variation is returned after a set
// confirm the forced variation is returned after a set
Assert.True(Config.SetForcedVariation(experimentKey, userId, expectedVariationKey));
var actualForcedVariation = Config.GetForcedVariation(experimentKey, userId);
Assert.AreEqual(expectedVariationKey, actualForcedVariation.Key);

// check multiple sets
// check multiple sets
Assert.True(Config.SetForcedVariation(experimentKey2, userId, expectedVariationKey2));
var actualForcedVariation2 = Config.GetForcedVariation(experimentKey2, userId);
Assert.AreEqual(expectedVariationKey2, actualForcedVariation2.Key);
// make sure the second set does not overwrite the first set
// make sure the second set does not overwrite the first set
actualForcedVariation = Config.GetForcedVariation(experimentKey, userId);
Assert.AreEqual(expectedVariationKey, actualForcedVariation.Key);
// make sure unsetting the second experiment-to-variation mapping does not unset the
// first experiment-to-variation mapping
// make sure unsetting the second experiment-to-variation mapping does not unset the
// first experiment-to-variation mapping
Assert.True(Config.SetForcedVariation(experimentKey2, userId, null));
actualForcedVariation = Config.GetForcedVariation(experimentKey, userId);
Assert.AreEqual(expectedVariationKey, actualForcedVariation.Key);

// an invalid user ID should return a null variation
// an invalid user ID should return a null variation
Assert.Null(Config.GetForcedVariation(experimentKey, invalidUserId));
}

// test that all the logs in setForcedVariation are getting called
// test that all the logs in setForcedVariation are getting called
[Test]
public void TestSetForcedVariationLogs()
{
Expand All @@ -714,7 +714,7 @@ public void TestSetForcedVariationLogs()
var variationKey = "control";
var variationId = "7722370027";
var invalidVariationKey = "invalid_variation";

Config.SetForcedVariation(invalidExperimentKey, userId, variationKey);
Config.SetForcedVariation(experimentKey, userId, null);
Config.SetForcedVariation(experimentKey, userId, invalidVariationKey);
Expand All @@ -727,7 +727,7 @@ public void TestSetForcedVariationLogs()
LoggerMock.Verify(l => l.Log(LogLevel.DEBUG, string.Format(@"Set variation ""{0}"" for experiment ""{1}"" and user ""{2}"" in the forced variation map.", variationId, experimentId, userId)));
}

// test that all the logs in getForcedVariation are getting called
// test that all the logs in getForcedVariation are getting called
[Test]
public void TestGetForcedVariationLogs()
{
Expand All @@ -753,30 +753,30 @@ public void TestGetForcedVariationLogs()
LoggerMock.Verify(l => l.Log(LogLevel.DEBUG, string.Format(@"No experiment ""{0}"" mapped to user ""{1}"" in the forced variation map.", pausedExperimentKey, userId)));
LoggerMock.Verify(l => l.Log(LogLevel.DEBUG, string.Format(@"Variation ""{0}"" is mapped to experiment ""{1}"" and user ""{2}"" in the forced variation map", variationKey, experimentKey, userId)));
}

[Test]
public void TestSetForcedVariationMultipleSets()
{
Assert.True(Config.SetForcedVariation("test_experiment", "test_user_1", "variation"));
Assert.AreEqual(Config.GetForcedVariation("test_experiment", "test_user_1").Key, "variation");
// same user, same experiment, different variation

// same user, same experiment, different variation
Assert.True(Config.SetForcedVariation("test_experiment", "test_user_1", "control"));
Assert.AreEqual(Config.GetForcedVariation("test_experiment", "test_user_1").Key, "control");
// same user, different experiment

// same user, different experiment
Assert.True(Config.SetForcedVariation("group_experiment_1", "test_user_1", "group_exp_1_var_1"));
Assert.AreEqual(Config.GetForcedVariation("group_experiment_1", "test_user_1").Key, "group_exp_1_var_1");

// different user
// different user
Assert.True(Config.SetForcedVariation("test_experiment", "test_user_2", "variation"));
Assert.AreEqual(Config.GetForcedVariation("test_experiment", "test_user_2").Key, "variation");
// different user, different experiment

// different user, different experiment
Assert.True(Config.SetForcedVariation("group_experiment_1", "test_user_2", "group_exp_1_var_1"));
Assert.AreEqual(Config.GetForcedVariation("group_experiment_1", "test_user_2").Key, "group_exp_1_var_1");

// make sure the first user forced variations are still valid
// make sure the first user forced variations are still valid
Assert.AreEqual(Config.GetForcedVariation("test_experiment", "test_user_1").Key, "control");
Assert.AreEqual(Config.GetForcedVariation("group_experiment_1", "test_user_1").Key, "group_exp_1_var_1");
}
Expand Down
Loading