Skip to content

Commit

Permalink
tests: Fix cluster version and downgrade request timeout
Browse files Browse the repository at this point in the history
Returning nil means that raft.Trigger was not called, causing member to
wait infinitly for response for response on raft request.
  • Loading branch information
serathius committed Feb 14, 2022
1 parent bcadd03 commit 3de5e22
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions server/etcdserver/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ func (a *applierV3backend) Apply(r *pb.InternalRaftRequest, shouldApplyV3 member
case r.ClusterVersionSet != nil: // Implemented in 3.5.x
op = "ClusterVersionSet"
a.s.applyV3Internal.ClusterVersionSet(r.ClusterVersionSet, shouldApplyV3)
return nil
return ar
case r.ClusterMemberAttrSet != nil:
op = "ClusterMemberAttrSet" // Implemented in 3.5.x
a.s.applyV3Internal.ClusterMemberAttrSet(r.ClusterMemberAttrSet, shouldApplyV3)
return nil
return ar
case r.DowngradeInfoSet != nil:
op = "DowngradeInfoSet" // Implemented in 3.5.x
a.s.applyV3Internal.DowngradeInfoSet(r.DowngradeInfoSet, shouldApplyV3)
return nil
return ar
}

if !shouldApplyV3 {
Expand Down
2 changes: 1 addition & 1 deletion server/etcdserver/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (m *Manager) DowngradeEnable(ctx context.Context, targetVersion *semver.Ver
if err != nil {
return err
}
return m.s.DowngradeEnable(context.Background(), targetVersion)
return m.s.DowngradeEnable(ctx, targetVersion)
}

// DowngradeCancel cancels ongoing downgrade process.
Expand Down
13 changes: 7 additions & 6 deletions tests/e2e/cluster_downgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ func TestDowngradeUpgrade(t *testing.T) {
validateVersion(t, epc, version.Versions{Cluster: currentVersionStr, Server: currentVersionStr})

downgradeEnable(t, epc, lastVersion)
expectLog(t, epc, "The server is ready to downgrade")
validateVersion(t, epc, version.Versions{Cluster: lastVersionStr, Server: currentVersionStr})

stopEtcd(t, epc)
epc = startEtcd(t, lastReleaseBinary, dataDirPath)
validateVersion(t, epc, version.Versions{Cluster: lastVersionStr, Server: lastVersionStr})
expectLog(t, epc, "the cluster has been downgraded")
validateVersion(t, epc, version.Versions{Cluster: lastVersionStr, Server: lastVersionStr})

stopEtcd(t, epc)
epc = startEtcd(t, currentEtcdBinary, dataDirPath)
// TODO: Verify cluster version after upgrade when we fix cluster version set timeout
validateVersion(t, epc, version.Versions{Server: currentVersionStr})
validateVersion(t, epc, version.Versions{Cluster: currentVersionStr, Server: currentVersionStr})
}

func startEtcd(t *testing.T, execPath, dataDirPath string) *e2e.EtcdProcessCluster {
Expand Down Expand Up @@ -100,11 +100,12 @@ func downgradeEnable(t *testing.T, epc *e2e.EtcdProcessCluster, ver semver.Versi
}
defer c.Close()
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
// TODO: Fix request always timing out even thou it succeeds
c.Downgrade(ctx, 1, ver.String())
_, err = c.Downgrade(ctx, 1, ver.String())
if err != nil {
t.Fatal(err)
}
cancel()

expectLog(t, epc, "The server is ready to downgrade")
}

func stopEtcd(t *testing.T, epc *e2e.EtcdProcessCluster) {
Expand Down

0 comments on commit 3de5e22

Please sign in to comment.