Skip to content

Commit 94e59e4

Browse files
codebrainrusscam
authored andcommitted
Increment count when serialising multiple lifecycle actions. (#4218)
This commit fixes a bug where the count was not incremented when serialising multiple lifecycle actions. Fixes #4186 (cherry picked from commit b8318e6)
1 parent 0a0954b commit 94e59e4

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

src/Nest/XPack/Ilm/LifecycleActions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ public void Serialize(ref JsonWriter writer, ILifecycleActions value, IJsonForma
166166
.Serialize(ref writer, action.Value, formatterResolver);
167167
break;
168168
}
169+
170+
count++;
169171
}
170172
writer.WriteEndObject();
171173
}

src/Tests/Tests/XPack/Ilm/IlmApiTests.cs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ public IlmApiTests(XPackCluster cluster, EndpointUsage usage) : base(new Coordin
6565
{
6666
Phases = new Phases
6767
{
68+
Cold = new Phase
69+
{
70+
Actions = new LifecycleActions
71+
{
72+
new FreezeLifecycleAction(),
73+
new SetPriorityLifecycleAction
74+
{
75+
Priority = 50
76+
}
77+
}
78+
},
6879
Warm = new Phase
6980
{
7081
MinimumAge = "10d",
@@ -88,10 +99,28 @@ public IlmApiTests(XPackCluster cluster, EndpointUsage usage) : base(new Coordin
8899
}
89100
},
90101
(v, d) => d
91-
.Policy(p => p.Phases(a => a.Warm(w => w.MinimumAge("10d")
92-
.Actions(ac => ac.ForceMerge(f => f.MaximumNumberOfSegments(1))))
93-
.Delete(w => w.MinimumAge("30d")
94-
.Actions(ac => ac.Delete(f => f)))))
102+
.Policy(p => p
103+
.Phases(a => a
104+
.Cold(w => w
105+
.Actions(ac => ac
106+
.Freeze(f => f)
107+
.SetPriority(f => f.Priority(50))
108+
)
109+
)
110+
.Warm(w => w
111+
.MinimumAge("10d")
112+
.Actions(ac => ac
113+
.ForceMerge(f => f.MaximumNumberOfSegments(1))
114+
)
115+
)
116+
.Delete(w => w
117+
.MinimumAge("30d")
118+
.Actions(ac => ac
119+
.Delete(f => f)
120+
)
121+
)
122+
)
123+
)
95124
,
96125
(v, c, f) => c.IndexLifecycleManagement.PutLifecycle("policy" + v, f),
97126
(v, c, f) => c.IndexLifecycleManagement.PutLifecycleAsync("policy" + v, f),

0 commit comments

Comments
 (0)