@@ -27,17 +27,42 @@ func TestInstallCalico(t *testing.T) {
2727 return
2828 }
2929
30- out , err := TestHelper .Kubectl ("" , []string {"apply" , "-f" , "https://k3d.io/v5.1.0/usage/advanced/calico.yaml" }... )
31- if err != nil {
32- testutil .AnnotatedFatalf (t , "'kubectl apply' command failed" ,
33- "kubectl apply command failed\n %s" , out )
34- }
30+ // install Calico as per instructions on
31+ // https://k3d.io/v5.8.3/usage/advanced/calico/#1-create-the-cluster-without-flannel
32+ // there's a lot of waiting involved here as the various components come up, so the easiest
33+ // is to retry the steps until they succeed
34+ var out string
35+ err := testutil .RetryFor (time .Minute , func () error {
36+ var err error
37+ out , err = TestHelper .Kubectl ("" , []string {"apply" , "-f" , "https://raw.githubusercontent.com/projectcalico/calico/v3.31.0/manifests/tigera-operator.yaml" }... )
38+ if err != nil {
39+ return err
40+ }
41+
42+ deploys := map [string ]testutil.DeploySpec {
43+ "tigera-operator" : {
44+ Namespace : "tigera-operator" ,
45+ Replicas : 1 ,
46+ },
47+ }
48+ TestHelper .WaitRollout (t , deploys )
3549
36- time .Sleep (10 * time .Second )
37- o , err := TestHelper .Kubectl ("" , "--namespace=kube-system" , "wait" , "--for=condition=available" , "--timeout=120s" , "deploy/calico-kube-controllers" )
50+ out , err = TestHelper .Kubectl ("" , []string {"apply" , "-f" , "https://raw.githubusercontent.com/projectcalico/calico/v3.31.0/manifests/custom-resources.yaml" }... )
51+ if err != nil {
52+ return err
53+ }
54+
55+ for _ , system := range []string {"apiserver" , "calico" , "goldmane" , "ippools" , "whisker" } {
56+ out , err = TestHelper .Kubectl ("" , "wait" , "--for=condition=available" , "--timeout=120s" , "tigerastatus" , system )
57+ if err != nil {
58+ return err
59+ }
60+ }
61+
62+ return nil
63+ })
3864 if err != nil {
39- testutil .AnnotatedFatalf (t , "failed to wait for condition=available for calico resources" ,
40- "failed to wait for condition=available for calico resources: %s: %s" , err , o )
65+ testutil .AnnotatedFatalf (t , "failed to install calico" , "failed to install calico: %s: %s" , err , out )
4166 }
4267}
4368
0 commit comments