How to set up and use RavenDB 4.0 Embedded

880 views
Skip to first unread message

jafar amiri

unread,
Apr 12, 2017, 6:04:13 AM4/12/17
to RavenDB - 2nd generation document database
Hi,
I am now using RavenDB 3.5.3 Embedded. I couldn't able to find a good document that shows how I can set up and use RavenDB 4.0.
For example in RavenDB 3.5.3 we can set up a embedded document store as this:

EmbeddableDocumentStore store = new EmbeddableDocumentStore { DataDirectory = "Data", UseEmbeddedHttpServer = true,
};
store.Initialize();


In RavenDB 4.0, How can we initialize a RavenDB 4.0 embedded document store?
How can we upgrade RavenDB 3.5.3 to 4.0?

Thank you

Oren Eini (Ayende Rahien)

unread,
Apr 12, 2017, 6:09:25 AM4/12/17
to ravendb
In RavenDB 4.0, all operations goes through the http pipeline.
That means that you setup a server and then connect to it.
You can see an exact of that here: 

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Piotr Brzezianski

unread,
Nov 2, 2017, 8:41:25 AM11/2/17
to RavenDB - 2nd generation document database
Hi,

Is there a NuGet package that includes RavenServer? I can't seem to find one, including in nightly build MyGet feed...
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.

Oren Eini (Ayende Rahien)

unread,
Nov 2, 2017, 8:46:48 AM11/2/17
to ravendb
Look at the `Raven.TestDriver` for an example on how to do that.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Jens Pettersson

unread,
Nov 3, 2017, 3:07:51 AM11/3/17
to RavenDB - 2nd generation document database
Hello. We've been using the EmbeddableDocumentStore for years in testing with great success and we're now looking into moving to RavenDB 4 and we're of course hoping to get the same great experience when the RTM is out.

I can get similar kind of tests using the TestDriver you mention, but I also have some problems with what server dll to use. I'm looking at https://github.com/ravendb/ravendb/blob/v4.0/test/SlowTests/TestDriver/TestDriverExampleTest.cs as an example but that one uses what looks like the compiled Raven.Server.dll from your builds.

The only way for me to make this work is to point the ServerPath directly to the Raven.Server.dll in the "installation" folder on my machine:

public class LocalRavenServerLocator : RavenServerLocator
{
    //The path to where I unzipped RavenDB
    public override string ServerPath => @"C:\RavenDB\RavenDB-4.0.0-rc-40019-windows-x64\Server\Raven.Server.dll";

    public override string Command => "dotnet";

    public override string CommandArguments => ServerPath;
}

[TestFixture]
public class LabTest : RavenTestDriver<LocalRavenServerLocator>
{
    [Test]
    public async Task SomeTest()
    {
        using (var store = GetDocumentStore())
        {
            using (var session = store.OpenAsyncSession())
            {
                await session.StoreAsync(new TestDocument{ Name = "Jens" });
                await session.SaveChangesAsync();
            }

            using (var session = store.OpenAsyncSession())
            {
                var testDocuments = await session.Query<TestDocument>().ToListAsync();
                Assert.AreEqual("Jens", testDocuments.First().Name);
            }
        }
    }
}

public class TestDocument
{
    public string Id { get; set; }
    public string Name { get; set; }
}

If I try to just copy the Raven.Server.dll to my project folder and git repository (to later include that one on our build server) and point the server path to that file it fails to start:

    public class LocalRavenServerLocator : RavenServerLocator
    {
        //The path to a copy of Raven.Server.dll (should be relative from project root later)
        public override string ServerPath => @"C:\dev\_Lab\RavenTestLab\tools\Raven.Server.dll";

        public override string Command => "dotnet";

        public override string CommandArguments => ServerPath;
    }

Exception (with quite a short exception message: ."Unable to start server, log is:\r\n"


System.InvalidOperationException : Unable to start server, log is: 


   at Raven.TestDriver.RavenTestDriver`1.RunServer()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Raven.TestDriver.RavenTestDriver`1.GetDocumentStore(String database, Nullable`1 waitForIndexingTimeout)
   at RavenTestLab.LabTest.<SomeTest>d__0.MoveNext() in c:\dev\_Lab\RavenTestLab\RavenTestLab\LabTest.cs:line 27

I'm not really sure what the best way of doing this is right now. It would of course be nice if the Raven.TestDriver could include the Raven.Server.dll (and a RavenServerLocator for that) but I understand that might be difficult to get working seamlessly for all platforms...

//J

Oren Eini (Ayende Rahien)

unread,
Nov 3, 2017, 3:29:15 AM11/3/17
to ravendb
The reason that this is a property instead of a simple string is that you can use logic to find the right path.
For example, during deploy use the local directory, during development you'll use one you have in a well defined location, etc. 

We really care about the embedded scenario, for testing and otherwise and we are working on making it possible. This is hard because of cross platform issues, as you mentioned.

To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Jens Pettersson

unread,
Nov 3, 2017, 4:06:36 AM11/3/17
to RavenDB - 2nd generation document database
But what is "the right path"? For now I have to use a path to the folder where I unzipped the full server and not only a path to a single dll (as the Raven.Server.dll has other dependencies) and that's totally fine for development.

But if I want to deploy a small application to a server somewhere (or run a test suite on a CI server) and that application wants to use the "embedded" scenario I have to make sure that the full Raven server package (i.e. zip file containing all the dll's) is deployed there as well?

Oren Eini (Ayende Rahien)

unread,
Nov 3, 2017, 6:15:58 AM11/3/17
to ravendb
Yes, you will need to take the bundle. It won't be the actual zip file, because that includes also our own copy of the CoreCLR, etc, but it will probably require the following:
  • libsodium.x64.dll
  • Raven.Client.dll
  • Raven.Server.dll
  • settings.json
  • Sparrow.dll
  • Voron.dll
The total size is about 10 MB or so. 

To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Jens Pettersson

unread,
Nov 3, 2017, 6:22:53 AM11/3/17
to RavenDB - 2nd generation document database
Thanks, a 10 mb bundle would be absolutely acceptable for us to be able to use the server in testing. 

Trying to run with the files you mentioned gave me the following error:

"A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in..."

Adding that one gives me another error when just trying to run dotnet .\Raven.Server.dll

"Could not resolve CoreCLR path."

Something is still missing (or I'm just doing it wrong)

//J

Oren Eini (Ayende Rahien)

unread,
Nov 3, 2017, 6:36:56 AM11/3/17
to ravendb
That was just a quick read ,I think you need hostfxr.dll as well, and anyway, that is something we'll look toward near to RTM or immediately after. 
The idea is to get a very small package size ( 10 - 15 MB, if we are successful ) that you can take with you.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Jens Pettersson

unread,
Nov 3, 2017, 6:48:08 AM11/3/17
to RavenDB - 2nd generation document database
Yeah I understand that this wasn't a complete list. Might test around a bit to find what's needed if I got some time... For now, I'm more than pleased to hear that you're working on some sort of a bundle.

Thanks for the info!

//J

Justin A

unread,
Nov 8, 2017, 4:51:44 PM11/8/17
to RavenDB - 2nd generation document database
I know this is frustrating also, especially coming from v1, v2 and v3's.

I've more or less stopped doing any code tests for my new greenfield project which uses an InMemory RavenDb server and waiting (and praying) for a better solution in RC2 or RC vNext.

I totally don't understand why we need to provide the path to the server when _previous_ versions of this, we didn't. As a option - sure. As a requirement, it's been pretty painful so far. I'm always thinking about:
- localhost
- CI (like appveyor, vsts, etc)

so many different places where my tests could run, etc.

So right now, i'm just manually testing my website against a localhost (in ram only) ravendb server that is running and keep resetting/clearing the data.

But yeah, waiting nervously for the next RC to see if the testingi story is ok/back to what it was before. If not, then I'll need to move on :(

-PK-

Oren Eini (Ayende Rahien)

unread,
Nov 8, 2017, 4:57:47 PM11/8/17
to ravendb
The underlying reasons is that we are running on CoreCLR.
If would be simple enough to do this if you are also running there.
Not so much is you are using net461 or ruby, etc.

The major problem for our purposes is that how to get the actual server binaries. We can't really use NuGet here, because that would blow up the size of the package by a LOT (we need to support multiple platforms, and you might also need to have the coreclr installed or to package that too, etc).

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Justin A

unread,
Nov 8, 2017, 5:07:43 PM11/8/17
to RavenDB - 2nd generation document database
I fully appreciate that this is not an easy solution, nor hating or trolling etc. If it was easier, then it would have been solved by now. I get it :(

I just expressing my feelings as a potential customer and just keeping the dialogue open and realistic, but hopefully polite and respectful.

Wish there were specific nugets instead of an uber nuget. So us CoreCLR peeps can just pull that one down.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages