Fix integration test flakiness (#351)

Ref https://github.com/summerwind/actions-runner-controller/pull/345#issuecomment-785015406
This commit is contained in:
Yusuke Kuoka 2021-02-25 09:30:32 +09:00 committed by GitHub
parent 4d4137aa28
commit 9da123ae5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 51 deletions

View File

@ -4,7 +4,6 @@ import (
"context"
"fmt"
"github.com/google/go-github/v33/github"
github3 "github.com/google/go-github/v33/github"
github2 "github.com/summerwind/actions-runner-controller/github"
"k8s.io/apimachinery/pkg/runtime"
"net/http"
@ -248,26 +247,7 @@ var _ = Context("INTEGRATION: Inside of a new namespace", func() {
}
{
var runnerList actionsv1alpha1.RunnerList
err := k8sClient.List(ctx, &runnerList, client.InNamespace(ns.Name))
if err != nil {
logf.Log.Error(err, "list runners")
}
for i, r := range runnerList.Items {
env.fakeRunnerList.Add(&github3.Runner{
ID: github.Int64(int64(i)),
Name: github.String(r.Name),
OS: github.String("linux"),
Status: github.String("online"),
Busy: github.Bool(false),
})
}
rs, err := env.ghClient.ListRunners(context.Background(), "", "", "test/valid")
Expect(err).NotTo(HaveOccurred(), "verifying list fake runners response")
Expect(len(rs)).To(Equal(3), "count of fake list runners")
env.ExpectRegisteredNumberCountEventuallyEquals(3, "count of fake runners after HRA creation")
}
// Scale-down to 1 replica
@ -478,26 +458,7 @@ var _ = Context("INTEGRATION: Inside of a new namespace", func() {
}
{
var runnerList actionsv1alpha1.RunnerList
err := k8sClient.List(ctx, &runnerList, client.InNamespace(ns.Name))
if err != nil {
logf.Log.Error(err, "list runners")
}
for i, r := range runnerList.Items {
env.fakeRunnerList.Add(&github3.Runner{
ID: github.Int64(int64(i)),
Name: github.String(r.Name),
OS: github.String("linux"),
Status: github.String("online"),
Busy: github.Bool(false),
})
}
rs, err := env.ghClient.ListRunners(context.Background(), "", "", "test/valid")
Expect(err).NotTo(HaveOccurred(), "verifying list fake runners response")
Expect(len(rs)).To(Equal(3), "count of fake list runners")
env.ExpectRegisteredNumberCountEventuallyEquals(3, "count of fake runners after HRA creation")
}
// Scale-down to 1 replica
@ -746,15 +707,7 @@ func (env *testEnvironment) SyncRunnerRegistrations() {
logf.Log.Error(err, "list runners")
}
for i, r := range runnerList.Items {
env.fakeRunnerList.Add(&github3.Runner{
ID: github.Int64(int64(i)),
Name: github.String(r.Name),
OS: github.String("linux"),
Status: github.String("online"),
Busy: github.Bool(false),
})
}
env.fakeRunnerList.Sync(runnerList.Items)
}
func ExpectCreate(ctx context.Context, rd runtime.Object, s string) {

View File

@ -204,7 +204,7 @@ func (r *RunnerReplicaSetReconciler) Reconcile(req ctrl.Request) (ctrl.Result, e
updated.Status.ReadyReplicas = ready
if err := r.Status().Update(ctx, updated); err != nil {
log.Error(err, "Failed to update status. Retrying immediately")
log.Info("Failed to update status. Retrying immediately", "error", err.Error())
return ctrl.Result{
Requeue: true,
}, nil

View File

@ -2,6 +2,7 @@ package fake
import (
"encoding/json"
"github.com/summerwind/actions-runner-controller/api/v1alpha1"
"net/http"
"net/http/httptest"
"strconv"
@ -64,6 +65,20 @@ func (r *RunnersList) handleRemove() http.HandlerFunc {
}
}
func (r *RunnersList) Sync(runners []v1alpha1.Runner) {
r.runners = nil
for i, want := range runners {
r.Add(&github.Runner{
ID: github.Int64(int64(i)),
Name: github.String(want.Name),
OS: github.String("linux"),
Status: github.String("online"),
Busy: github.Bool(false),
})
}
}
func exists(runners []*github.Runner, runner *github.Runner) bool {
for _, r := range runners {
if *r.Name == *runner.Name {