Select Git revision
-
Jan Kiszka authored
Derived from kvm-tool patch http://thread.gmane.org/gmane.comp.emulators.kvm.devel/74309 Ingo Molnar pointed out that sending the timer signal to the whole process, just blocking it everywhere, is suboptimal with an increasing number of threads. QEMU is also using this pattern so far. Linux provides a (non-portable) way to restrict the signal to a single thread: We can use SIGEV_THREAD_ID unless we are forced to emulate signalfd via an additional thread. That case could theoretically be optimized as well, but it doesn't look worth bothering. Reviewed-by:
Richard Henderson <rth@twiddle.net> Signed-off-by:
Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by:
Anthony Liguori <aliguori@us.ibm.com>
Jan Kiszka authoredDerived from kvm-tool patch http://thread.gmane.org/gmane.comp.emulators.kvm.devel/74309 Ingo Molnar pointed out that sending the timer signal to the whole process, just blocking it everywhere, is suboptimal with an increasing number of threads. QEMU is also using this pattern so far. Linux provides a (non-portable) way to restrict the signal to a single thread: We can use SIGEV_THREAD_ID unless we are forced to emulate signalfd via an additional thread. That case could theoretically be optimized as well, but it doesn't look worth bothering. Reviewed-by:
Richard Henderson <rth@twiddle.net> Signed-off-by:
Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by:
Anthony Liguori <aliguori@us.ibm.com>
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
compatfd.h 1.51 KiB
using Coscine.Api.Project.Controllers;
using Coscine.Api.Project.Exceptions;
using Coscine.Api.Project.Factories;
using Coscine.Api.Project.Models;
using Coscine.Api.Project.ReturnObjects;
using Microsoft.AspNetCore.Mvc;
using NUnit.Framework;
using System;
using System.IO;
namespace Coscine.Api.Project.Tests
{
[TestFixture]
public class ResourceControllerTests : DefaultControllerTests<ResourceController>
{
public ResourceControllerTests() : base(new ResourceController())
{
}
[Test]
public void TestControllerIndex()
{
var actionResult = Controller.Index();
Assert.IsTrue(actionResult.GetType() == typeof(OkObjectResult));
}
[Test]
public void TestControllerGet()
{
var actionResult = Controller.Get(resources[0].Id.ToString());
Assert.IsTrue(actionResult.GetType() == typeof(OkObjectResult));
OkObjectResult okObjectResult = (OkObjectResult)actionResult;
Assert.IsTrue(okObjectResult.Value.GetType() == typeof(ResourceObject));
ResourceObject projectObject = (ResourceObject)okObjectResult.Value;
Assert.IsTrue(projectObject.Id == resources[0].Id);
Assert.IsTrue(projectObject.ExternalId == resources[0].ExternalId);
Assert.IsTrue(projectObject.Type.Id == resources[0].Type.Id);
Assert.IsTrue(projectObject.Type.DisplayName == resources[0].Type.DisplayName);
Assert.IsTrue(projectObject.Url == resources[0].Url);
}
[Test]
public void TestControllerUpdate()
{
var actionResult = Controller.Get(resources[0].Id.ToString());
OkObjectResult okObjectResult = (OkObjectResult)actionResult;
ResourceObject resourceObject = (ResourceObject)okObjectResult.Value;
resourceObject.ExternalId = "ChangedExternalId";
Stream stream = ObjectFactory<ResourceObject>.SerializeToStream(resourceObject);
FakeControllerContext(users[0], stream);
actionResult = Controller.Update(resources[0].Id.ToString());
Assert.IsTrue(actionResult.GetType() == typeof(OkObjectResult));
// Cleanup
stream.Close();
stream = ObjectFactory<ResourceObject>.SerializeToStream(resourceObject);
FakeControllerContext(users[0], stream);
try
{
actionResult = Controller.Update(resources[1].Id.ToString());
Assert.Fail();
}
catch (Exception e)
{
Assert.IsTrue(e.GetType() == typeof(NotAuthorizedException));
}
// Cleanup
stream.Close();
}
[Test]
public void TestControllerStoreToProject()
{
ResourceObject resourceObject = new ResourceObject(Guid.NewGuid(), "externalId", "http://rwth-aachen.de/newTest", new ResourceTypeObject(resourceTypes[0].Id, resourceTypes[0].DisplayName));
Stream stream = ObjectFactory<ResourceObject>.SerializeToStream(resourceObject);
FakeControllerContext(users[0], stream);
var actionResult = Controller.StoreToProject(projects[0].Id.ToString());
Assert.IsTrue(actionResult.GetType() == typeof(OkObjectResult));
OkObjectResult okObjectResult = (OkObjectResult)actionResult;
resourceObject = (ResourceObject)okObjectResult.Value;
// Cleanup
stream.Close();
ResourceModel resourceModel = new ResourceModel();
var resource = resourceModel.GetById(resourceObject.Id);
ProjectResourceModel projectResourceModel = new ProjectResourceModel();
foreach(var projectResource in projectResourceModel.GetAllWhere((projectResource) => projectResource.ProjectId == projects[0].Id && projectResource.ResourceId == resource.Id))
{
projectResourceModel.Delete(projectResource);
}
resourceModel.Delete(resource);
}
}
}