Skip to content

Conversation

jdom
Copy link
Member

@jdom jdom commented Oct 23, 2016

This is so that we can eventually run the tests without the need to use AppDomains, as they are not available in .NET Core.

This PR is related to #2145

@jdom jdom added this to the CoreCLR milestone Oct 23, 2016
private static T CheckReturnBoundaryReference<T>(string what, T obj) where T : class
{
if (obj == null) return null;
if (obj is MarshalByRefObject || obj is ISerializable)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about ISerializable here. Should it be obj.GetType().IsSerializable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are probably right. Nevertheless this is old code that I just moved around and plan to deprecate it soon, not add more usages to it, since we want to get away from app domains for testing

if (obj == null) return null;
if (obj is MarshalByRefObject || obj is ISerializable)
{
// Referernce to the provider can safely be passed across app-domain boundary in unit test process
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: typo on Reference

public IDictionary<GrainId, IGrainInfo> GetDirectoryForTypeNamesContaining(string expr)
{
var x = new Dictionary<GrainId, IGrainInfo>();
foreach (var kvp in ((LocalGrainDirectory)silo.LocalGrainDirectory).DirectoryPartition.GetItems())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did Silo.LocalGrainDirectory change type recently? why the cast? Same goes for Silo.Catalog.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the original code before the move, it was using the private field that didn't need casting. Similarly these are test hooks that were just moved but not migrated yet, and should be migrated soon. Didn't make too much effort to make sure abstractions are kept in place, since they are going away.


simulatedMessageLoss[destination] = lossPercentage;

var mc = (MessageCenter)silo.LocalMessageCenter;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this class should take these dependencies explicitly so the casts can be avoided.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly, because the code is now moved to a non-nested class, it can no longer access private fields, so the casting would have to either be done in the constructor or here (or expose implementation details that we probably don't want to do for code that should eventually be removed).

return TaskDone.Done;
}

public Task<long> GetReportMetricsCallCount()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this a bit misleading if the count starts at -1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, was just migrating existing tests. Not sure what was the reasoning, but given this took so long, I decided not to stop and analyze every test. If you tell it's OK to just use 0, I can change it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a look, and I still can't make sense why it was ever -1, but still, it does seem that 0 is the right value also according to how the test which uses it is asserting, so fixed

Assert.Equal(0, primaryActivation + secondaryActivation);


if (doLazyDeregistration)
if (lazyDeregistrationDelay > TimeSpan.Zero)
{
// Wait a bit
TimeSpan pause = lazyDeregistrationDelay.Multiply(2);
logger.Info("Pausing for {0} because DoLazyDeregistration=True", pause);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: log line is misleading

@ReubenBond ReubenBond merged commit 56dd784 into dotnet:master Oct 24, 2016
@jdom jdom deleted the testhooks branch October 25, 2016 18:52
@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants