protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values)
		{
			foreach (var index in values.Values) client.CreateIndex(index, this.CreateIndexSettings).ShouldBeValid();
			var indices = Infer.Indices(values.Values.Select(i => (IndexName)i));
			client.ClusterHealth(f => f.WaitForStatus(WaitForStatus.Yellow).Index(indices))
				.ShouldBeValid();
		}
示例#2
0
        public static void Check(IElasticClient client, string index)
        {
            var indices  = Infer.Indices(index);
            var response = client.Indices.Refresh(indices);
            var search   = client.Search <Base>(c => c.Size(1).Index(index));

            Console.WriteLine($"The index has {search.Total} logs");
            Console.WriteLine($"Last indexed message: {search.Documents.Last().Message}");
        }
		protected IPutRoleRequest CreateFluent(string role, PutRoleDescriptor d) => d
			.Cluster("all")
			.Indices(i => i
				.Add<Project>(ii => ii
					.Fields(f => f
						.Field(p => p.Name)
						.Field(p => p.Description)
					)
					.Names(Infer.Indices<Project>())
					.Privileges("all")
					.Query(q => q.MatchAll())
				)
			);
		protected PutRoleRequest CreateInitializer(string role) => new PutRoleRequest(CreateRoleName(role))
		{
			Cluster = new[] { "all" },
			Indices = new List<IIndicesPrivileges>
			{
				new IndicesPrivileges
				{
					Fields = Infer.Fields<Project>(p=>p.Name).And<Project>(p=>p.Description),
					Names = Infer.Indices<Project>(),
					Privileges = new [] { "all" },
					Query = new MatchAllQuery()
				}
			}
		};
示例#5
0
 protected IPutRoleRequest UpdateFluent(string role, PutRoleDescriptor d) => d
 .RunAs("user")
 .Cluster("all")
 .Indices(i => i
          .Add <Project>(ii => ii
                         .FieldSecurity(fs => fs
                                        .Grant(f => f
                                               .Field(p => p.Name)
                                               .Field(p => p.Description)
                                               )
                                        )
                         .Names(Infer.Indices <Project>())
                         .Privileges("all")
                         .Query(q => q.MatchAll())
                         )
          );
		protected override void ExpectAfterUpdate(IGetRoleResponse response)
		{
			response.Roles.Should().NotBeEmpty();
			var role = response.Roles.First().Value;
			role.Cluster.Should().NotBeNullOrEmpty().And.Contain("all");
			role.RunAs.Should().NotBeNullOrEmpty();
			role.Indices.Should().NotBeNullOrEmpty().And.HaveCount(1);

			var indexPrivilege = role.Indices.First();
			indexPrivilege.Names.Should().NotBeNull().And.Be(Infer.Indices("project"));
			indexPrivilege.Fields.Should().NotBeNull().And.HaveCount(2);
			indexPrivilege.Privileges.Should().NotBeNull().And.Contain("all");
			indexPrivilege.Query.Should().NotBeNull();
			var q = indexPrivilege.Query as IQueryContainer;
			q.MatchAll.Should().NotBeNull();
		}
示例#7
0
 public void DeleteIndicesAndTemplates()
 {
     if (this.Client.IndexTemplateExists(TestsIndexTemplateName).Exists)
     {
         this.Client.DeleteIndexTemplate(TestsIndexTemplateName);
     }
     if (this.Client.IndexExists(Infer.Indices <Project>()).Exists)
     {
         this.Client.DeleteIndex(typeof(Project));
     }
     if (this.Client.IndexExists(Infer.Indices <Developer>()).Exists)
     {
         this.Client.DeleteIndex(typeof(Developer));
     }
     if (this.Client.IndexExists(Infer.Indices <PercolatedQuery>()).Exists)
     {
         this.Client.DeleteIndex(typeof(PercolatedQuery));
     }
 }