Esempio n. 1
0
		public void CanProfileLazyRequests()
		{
			using (GetNewServer())
			using (var store = new DocumentStore { Url = "http://localhost:8079" })
			{
				store.Initialize();
				store.InitializeProfiling();
				using (var session = store.OpenSession())
				{
					// handle the initial request for replication information
				}
				Guid id;
				using (var session = store.OpenSession())
				{
					id = ((DocumentSession)session).DatabaseCommands.ProfilingInformation.Id;
					session.Advanced.Lazily.Load<User>("users/1");
					session.Advanced.Lazily.Load<User>("users/2");
					session.Advanced.Lazily.Load<User>("users/3");

					session.Advanced.Eagerly.ExecuteAllPendingLazyOperations();
				}

				var profilingInformation = store.GetProfilingInformationFor(id);
				Assert.Equal(1, profilingInformation.Requests.Count);

				var responses = JsonConvert.DeserializeObject<GetResponse[]>(profilingInformation.Requests[0].Result, Default.Converters);
				Assert.Equal(3, responses.Length);
				foreach (var response in responses)
				{
					Assert.Equal(404, response.Status);
				}

			}
		}
Esempio n. 2
0
		public void CanTrackPosts()
		{
			using (GetNewServer())
			using (var store = new DocumentStore { Url = "http://localhost:8079" })
			{
				store.Initialize();
				store.InitializeProfiling();
				
				// make hilo & replication checks here
				using (var session = store.OpenSession())
				{
					session.Store(new User());
					session.SaveChanges();
				}

				Guid id;
				using (var session = store.OpenSession())
				{
					session.Store(new User());
					session.SaveChanges();

					id = ((DocumentSession)session).DatabaseCommands.ProfilingInformation.Id;
				}

				var profilingInformation = store.GetProfilingInformationFor(id);

				
				Assert.Equal(1, profilingInformation.Requests.Count);
			}
		}
Esempio n. 3
0
		public void CanTrackQueries()
		{
			using (GetNewServer())
			using (var store = new DocumentStore {Url = "http://localhost:8079"})
			{
				store.Initialize();
				store.InitializeProfiling();
				// make the replication check here
				using (var session = store.OpenSession())
				{
					session.Load<User>("users/1");
				}

				Guid id;
				using (var session = store.OpenSession())
				{
					session.Query<User>().ToList();

					id = ((DocumentSession)session).DatabaseCommands.ProfilingInformation.Id;
				}

				var profilingInformation = store.GetProfilingInformationFor(id);

				Assert.Equal(1, profilingInformation.Requests.Count);
			}

		}
Esempio n. 4
0
		public EnableProfiling()
		{
			using (var documentStore = new DocumentStore())
			{
				#region initialize_profiling
				documentStore.InitializeProfiling();
				#endregion

				Guid id = Guid.Empty;

				#region get_profiling_info
				ProfilingInformation profilingInformation = documentStore.GetProfilingInformationFor(id);
				#endregion

				#region example
				Guid sesionId;
				using (IDocumentSession session = documentStore.OpenSession())
				{
					sesionId = ((DocumentSession)session).Id;

					session.Load<Employee>("employees/1");
				}

				ProfilingInformation sessionProfilingInfo = documentStore.GetProfilingInformationFor(sesionId);
				#endregion
			}
		}
Esempio n. 5
0
		public void CanProfilePartiallyCachedLazyRequest()
		{
			using (GetNewServer())
			using (var store = new DocumentStore { Url = "http://localhost:8079" })
			{
				store.Initialize();
				store.InitializeProfiling(); 
				using (var session = store.OpenSession())
				{
					session.Store(new User { Name = "oren" });
					session.Store(new User { Name = "ayende" });
					session.SaveChanges();
				}


				using (var session = store.OpenSession())
				{
					session.Query<User>().Where(x => x.Name == "oren")
						.Customize(x => x.WaitForNonStaleResults())
						.ToArray();
				}
				Guid id;

				using (var session = store.OpenSession())
				{
					id = ((DocumentSession)session).DatabaseCommands.ProfilingInformation.Id;
					session.Query<User>().Where(x => x.Name == "oren").Lazily();
					session.Query<User>().Where(x => x.Name == "ayende").Lazily();
					session.Advanced.Eagerly.ExecuteAllPendingLazyOperations();
				}

				var profilingInformation = store.GetProfilingInformationFor(id);
				Assert.Equal(1, profilingInformation.Requests.Count);

				var responses = JsonConvert.DeserializeObject<GetResponse[]>(profilingInformation.Requests[0].Result, Default.Converters);
				Assert.Equal(304, responses[0].Status);
				Assert.Contains("oren", responses[0].Result.ToString());

				Assert.Equal(200, responses[1].Status);
				Assert.Contains("ayende", responses[1].Result.ToString());
			}
		}
Esempio n. 6
0
		public void CanProfilePartiallyAggressivelyCached()
		{
			using (GetNewServer())
			using (var store = new DocumentStore { Url = "http://localhost:8079" })
			{
				store.Initialize();
				store.InitializeProfiling();
				using (var session = store.OpenSession())
				{
					session.Store(new User { Name = "oren" });
					session.Store(new User { Name = "ayende" });
					session.SaveChanges();
				}


				using (var session = store.OpenSession())
				{
					using (session.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromMinutes(5)))
					{
						session.Load<User>("users/1");
					}
				}
				Guid id;

				using (var session = store.OpenSession())
				{
					id = ((DocumentSession)session).DatabaseCommands.ProfilingInformation.Id;
					using (session.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromMinutes(5)))
					{
						session.Advanced.Lazily.Load<User>("users/1");
						session.Advanced.Lazily.Load<User>("users/2");

						session.Advanced.Eagerly.ExecuteAllPendingLazyOperations();
					}

				}
				var profilingInformation = store.GetProfilingInformationFor(id);
				Assert.Equal(1, profilingInformation.Requests.Count);

				var responses = JsonConvert.DeserializeObject<GetResponse[]>(profilingInformation.Requests[0].Result, Default.Converters);
				Assert.Equal(0, responses[0].Status);
				Assert.Contains("oren", responses[0].Result.ToString());

				Assert.Equal(200, responses[1].Status);
				Assert.Contains("ayende", responses[1].Result.ToString());
			}
		}
Esempio n. 7
0
		public void CanProfileErrors()
		{
			using (GetNewServer())
			using (var store = new DocumentStore { Url = "http://localhost:8079" })
			{
				store.Initialize();
				store.InitializeProfiling(); 
				using (var session = store.OpenSession())
				{
					session.Store(new User { Name = "oren" });
					session.Store(new User { Name = "ayende" });
					session.SaveChanges();
				}


				Guid id;

				using (var session = store.OpenSession())
				{
					id = ((DocumentSession)session).DatabaseCommands.ProfilingInformation.Id;
					session.Advanced.LuceneQuery<object, RavenDocumentsByEntityName>().WhereEquals("Not", "There").Lazily();
					Assert.Throws<InvalidOperationException>(() => session.Advanced.Eagerly.ExecuteAllPendingLazyOperations());
				}
				var profilingInformation = store.GetProfilingInformationFor(id);
				Assert.Equal(1, profilingInformation.Requests.Count);

				var responses = JsonConvert.DeserializeObject<GetResponse[]>(profilingInformation.Requests[0].Result, Default.Converters);
				Assert.Equal(500, responses[0].Status);
				Assert.Contains("The field 'Not' is not indexed, cannot query on fields that are not indexed", responses[0].Result.ToString());
			}
		}