RavenDB4 Exception when batch running tests

83 views
Skip to first unread message

Lokesh

unread,
Apr 18, 2018, 2:21:21 PM4/18/18
to RavenDB - 2nd generation document database
Hi,
I am using RavenDB4 and RavenTestDriver. When running unit test cases as a batch or mostly run all, random test case(s) are randomly failing with the following exception:

1. Raven.Client.Exceptions.AllTopologyNodesDownException
There are no nodes in the topology at all
   at Raven.Client.Http.NodeSelector.UnlikelyEveryoneFaultedChoice(NodeSelectorState state)
   at Raven.Client.Http.NodeSelector.GetPreferredNode()
   at Raven.Client.Http.RequestExecutor.ChooseNodeForRequest[TResult](RavenCommand`1 cmd, SessionInfo sessionInfo)
   at Raven.Client.Http.RequestExecutor.<UnlikelyExecuteAsync>d__65`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Raven.Client.Util.AsyncHelpers.<>c__DisplayClass2_1.<<RunSync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Raven.Client.Util.AsyncHelpers.RunSync(Func`1 task)
   at Raven.Client.Http.RequestExecutor.Execute[TResult](RavenCommand`1 command, JsonOperationContext context, SessionInfo sessionInfo)
   at Raven.Client.Documents.Session.DocumentSession.Load[T](String id)
   at Flucticiel.Simetryk.Extensions.Common.Context.ExtensionContext.Set(IDocumentSession session, String tenantName) 

2. Raven.Client.Exceptions.Database.DatabaseDoesNotExistException
Database 'Create_[x]' does not exist.
   at Raven.Client.Exceptions.Database.DatabaseDoesNotExistException.Throw(String databaseName)
   at Raven.Client.Http.RequestExecutor.<ExecuteAsync>d__72`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Raven.Client.Http.RequestExecutor.<ExecuteAsync>d__72`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Raven.Client.Http.RequestExecutor.<UpdateTopologyAsync>d__60.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Raven.Client.Http.RequestExecutor.<FirstTopologyUpdate>d__67.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Raven.Client.Http.RequestExecutor.<UnlikelyExecuteAsync>d__65`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Raven.Client.Util.AsyncHelpers.<>c__DisplayClass2_1.<<RunSync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Raven.Client.Util.AsyncHelpers.RunSync(Func`1 task)
   at Raven.Client.Http.RequestExecutor.Execute[TResult](RavenCommand`1 command, JsonOperationContext context, SessionInfo sessionInfo)
   at Raven.Client.Documents.Session.DocumentSession.Load[T](String id)
   at Flucticiel.Simetryk.Extensions.Common.Context.ExtensionContext.Set(IDocumentSession session, String tenantName)

The above exceptions are actually inner exception that happen at the same place during bootstrapping (which is the 1st load statement from session object). What makes me even more curious is that it is able to open a session but when I try to load a document, it throws the above exceptions.

Is this something that is caused due to wrong initialization of the TestDriver? Do you have any suggestion on how to fix or work around this?

Thanks,
Lokesh

Arkadiusz Palinski

unread,
Apr 19, 2018, 3:19:45 AM4/19/18
to rav...@googlegroups.com
Hi,

1) What version of Raven.Client and Raven.Server are you using?
2) Can you show us your implementation of RavenServerLocator and a sample test?

Thanks,
Arek

--
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+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

oru malayali

unread,
Apr 19, 2018, 10:21:50 AM4/19/18
to rav...@googlegroups.com
Hi Arkadiusz,

Thanks for the reply.

1. The client I am using is 4.0.3-patch-40034 and the server is 4.0.3-patch-40034.

2. Following is the implementation of RavenServerLocator:

public class TestRavenDBLocator : RavenServerLocator
    {
        private string _serverPath;
        private string _command = "dotnet";
        private readonly string RavenServerName = "Raven.Server";
        private string _arguments;

        public override string ServerPath
        {
            get
            {
                if (!string.IsNullOrEmpty(_serverPath))
                {
                    return _serverPath;
                }

                var path = Environment.GetEnvironmentVariable("Raven_Server_Test_Path");
                if (!string.IsNullOrEmpty(path))
                {
                    if (InitializeFromPath(path))
                        return _serverPath;
                }
                
                //If we got here we didn't have ENV:RavenServerTestPath setup for us maybe this is a CI enviroement
                path = Environment.GetEnvironmentVariable("Raven_Server_CI_Path");
                if (!string.IsNullOrEmpty(path))
                {
                    if (InitializeFromPath(path))
                        return _serverPath;
                }

                //We couldn't find Raven.Server in either enviroment variables lets look for it in the current directory
                foreach (var file in Directory.GetFiles(Environment.CurrentDirectory, $"{RavenServerName}.exe; {RavenServerName}.dll"))
                {
                    if (InitializeFromPath(file))
                        return _serverPath;
                }
                //Lets try some brut force
                foreach (var file in Directory.GetFiles(Directory.GetDirectoryRoot(Environment.CurrentDirectory), $"{RavenServerName}.exe; {RavenServerName}.dll", SearchOption.AllDirectories))
                {
                    if (InitializeFromPath(file))
                    {
                        try
                        {
                            //We don't want to override the variable if defined
                            if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("Raven_Server_Test_Path")))
                                Environment.SetEnvironmentVariable("Raven_Server_Test_Path", file);
                        }
                        //We might not have permissions to set the enviroment variable
                        catch
                        {

                        }
                        return _serverPath;
                    }
                }
                throw new FileNotFoundException($"Could not find {RavenServerName} anywhere on the device.");
            }
        }

        private bool InitializeFromPath(string path)
        {
            if (Path.GetFileNameWithoutExtension(path) != RavenServerName)
                return false;
            var ext = Path.GetExtension(path);
            if (ext == ".dll")
            {
                _serverPath = path;
                _arguments = _serverPath;
                return true;
            }
            if (ext == ".exe")
            {
                _serverPath = path;
                _command = _serverPath;
                _arguments = string.Empty;
                return true;
            }
            return false;
        }

        public override string Command => _command;
        public override string CommandArguments => _arguments;
    }

I have the environment variable set up to point to RavenDB4 server dll. I don't really have a sample test for this as it fails randomly when all tests are run in a batch.
I am wondering if there is a way to wait and ensure that the database is created after the CreateDatabaseOperation?

Thanks,
 Lokesh


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.

--
You received this message because you are subscribed to a topic in the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ravendb/_IPr4yRseVY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ravendb+unsubscribe@googlegroups.com.

Arkadiusz Palinski

unread,
Apr 19, 2018, 10:30:37 AM4/19/18
to rav...@googlegroups.com
Can you show us any sample test you have? It seems something deletes your db behind your back. Are you creating a db per test case?
store.Maintenance.Server.Send(new CreateDatabaseOperation(new DatabaseRecord("MyNewDatabase")));
is sync operation. Once the following command returns the db is created.

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

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ravendb/_IPr4yRseVY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ravendb+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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+u...@googlegroups.com.

oru malayali

unread,
Apr 19, 2018, 11:44:43 AM4/19/18
to rav...@googlegroups.com
Hi Arkadiusz,
I am sorry, but I think its an issue on our part. Some static property.
Thanks a lot. Sorry again for the trouble.

Regards,
Lokesh


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.

--
You received this message because you are subscribed to a topic in the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ravendb/_IPr4yRseVY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ravendb+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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.

--
You received this message because you are subscribed to a topic in the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ravendb/_IPr4yRseVY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ravendb+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages