@@ -29,6 +29,7 @@ import (
29
29
30
30
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
31
31
"go.etcd.io/etcd/api/v3/version"
32
+ "go.etcd.io/etcd/server/v3/etcdserver"
32
33
"go.etcd.io/etcd/tests/v3/framework/testutils"
33
34
)
34
35
@@ -127,14 +128,14 @@ func ValidateDowngradeInfo(t *testing.T, clus *EtcdProcessCluster, expected *pb.
127
128
}
128
129
}
129
130
130
- func DowngradeUpgradeMembers (t * testing.T , lg * zap.Logger , clus * EtcdProcessCluster , numberOfMembersToChange int , currentVersion , targetVersion * semver.Version ) error {
131
+ func DowngradeUpgradeMembers (t * testing.T , lg * zap.Logger , clus * EtcdProcessCluster , numberOfMembersToChange int , downgradeEnabled bool , currentVersion , targetVersion * semver.Version ) error {
131
132
membersToChange := rand .Perm (len (clus .Procs ))[:numberOfMembersToChange ]
132
133
t .Logf ("Elect members for operations on members: %v" , membersToChange )
133
134
134
- return DowngradeUpgradeMembersByID (t , lg , clus , membersToChange , currentVersion , targetVersion )
135
+ return DowngradeUpgradeMembersByID (t , lg , clus , membersToChange , downgradeEnabled , currentVersion , targetVersion )
135
136
}
136
137
137
- func DowngradeUpgradeMembersByID (t * testing.T , lg * zap.Logger , clus * EtcdProcessCluster , membersToChange []int , currentVersion , targetVersion * semver.Version ) error {
138
+ func DowngradeUpgradeMembersByID (t * testing.T , lg * zap.Logger , clus * EtcdProcessCluster , membersToChange []int , downgradeEnabled bool , currentVersion , targetVersion * semver.Version ) error {
138
139
if lg == nil {
139
140
lg = clus .lg
140
141
}
@@ -162,15 +163,32 @@ func DowngradeUpgradeMembersByID(t *testing.T, lg *zap.Logger, clus *EtcdProcess
162
163
}
163
164
}
164
165
165
- clusterVersion := targetVersion .String ()
166
- if ! isDowngrade && len (membersToChange ) != len (clus .Procs ) {
167
- clusterVersion = currentVersion .String ()
168
- }
166
+ t .Log ("Waiting health interval to make sure the leader propagates version to new processes" )
167
+ time .Sleep (etcdserver .HealthInterval )
168
+
169
169
lg .Info ("Validating versions" )
170
+ clusterVersion := targetVersion
171
+ if ! isDowngrade {
172
+ if downgradeEnabled {
173
+ // If the downgrade isn't cancelled yet, then the cluster
174
+ // version will always stay at the lower version, no matter
175
+ // what's the binary version of each member.
176
+ clusterVersion = currentVersion
177
+ } else {
178
+ // If the downgrade has already been cancelled, then the
179
+ // cluster version is the minimal server version.
180
+ minVer , err := clus .MinServerVersion ()
181
+ if err != nil {
182
+ return fmt .Errorf ("failed to get min server version: %w" , err )
183
+ }
184
+ clusterVersion = minVer
185
+ }
186
+ }
187
+
170
188
for _ , memberID := range membersToChange {
171
189
member := clus .Procs [memberID ]
172
190
ValidateVersion (t , clus .Cfg , member , version.Versions {
173
- Cluster : clusterVersion ,
191
+ Cluster : clusterVersion . String () ,
174
192
Server : targetVersion .String (),
175
193
})
176
194
}
0 commit comments