Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Yann Liu <[email protected]>
  • Loading branch information
yannuil committed May 20, 2024
1 parent 6b3e6ad commit 5e381e6
Show file tree
Hide file tree
Showing 10 changed files with 791 additions and 730 deletions.
1,308 changes: 661 additions & 647 deletions operator/pkg/apis/istio/v1alpha1/values_types.pb.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions operator/pkg/apis/istio/v1alpha1/values_types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,9 @@ message PilotConfig {
// Controls whether Pilot is enabled.
google.protobuf.BoolValue enabled = 1;

// Controls whether Pilot is runing in federation mode
google.protobuf.BoolValue enableFederation = 54;

// Controls whether a HorizontalPodAutoscaler is installed for Pilot.
google.protobuf.BoolValue autoscaleEnabled = 2;

Expand Down
5 changes: 4 additions & 1 deletion pkg/kube/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,10 @@ func EnableCrdWatcher(c Client) Client {
return c
}

var NewCrdWatcher func(Client) kubetypes.CrdWatcher
var (
NewCrdWatcher func(Client) kubetypes.CrdWatcher
NewFastCrdWatcher func(Client) kubetypes.CrdWatcher
)

// NewDefaultClient returns a default client, using standard Kubernetes config resolution to determine
// the cluster to access.
Expand Down
10 changes: 10 additions & 0 deletions pkg/kube/kclient/crdwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type crdWatcher struct {
func init() {
// Unfortunate hack needed to avoid circular imports
kube.NewCrdWatcher = newCrdWatcher
kube.NewFastCrdWatcher = newFastCrdWatcher
}

// newCrdWatcher returns a new CRD watcher controller.
Expand All @@ -61,6 +62,15 @@ func newCrdWatcher(client kube.Client) kubetypes.CrdWatcher {
return c
}

func newFastCrdWatcher(client kube.Client) kubetypes.CrdWatcher {
c := &crdWatcher{
running: make(chan struct{}),
callbacks: map[string][]func(){},
}

return c
}

// HasSynced returns whether the underlying cache has synced and the callback has been called at least once.
func (c *crdWatcher) HasSynced() bool {
return c.crds == nil || c.queue.HasSynced()
Expand Down
1 change: 0 additions & 1 deletion pkg/servicemesh/federation/common/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

corev1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"

maistrainformersfederationv1 "maistra.io/api/client/informers/externalversions/federation/v1"
maistraclient "maistra.io/api/client/versioned"
maistraxnsinformer "maistra.io/api/client/xnsinformer"
Expand Down
4 changes: 4 additions & 0 deletions pkg/servicemesh/federation/discovery/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ func TestReconcile(t *testing.T) {
namespace := "test"
resyncPeriod := 30 * time.Second
options := newTestOptions("test.address")
newCrdWatcher := kube.NewCrdWatcher
kube.NewCrdWatcher = kube.NewFastCrdWatcher
kubeClient := kube.NewFakeClient(
&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -232,6 +234,7 @@ func TestReconcile(t *testing.T) {
},
},
)
kube.NewCrdWatcher = newCrdWatcher
rm, err := common.NewResourceManager(common.ControllerOptions{
KubeClient: kubeClient,
MaistraCS: fake.NewSimpleClientset(),
Expand Down Expand Up @@ -285,6 +288,7 @@ func TestReconcile(t *testing.T) {
}
stopCh := make(chan struct{})
defer close(stopCh)
go kubeClient.RunAndWait(stopCh)
go rm.Start(stopCh)
fedAdded := make(chan struct{})
fedDeleted := make(chan struct{})
Expand Down
4 changes: 4 additions & 0 deletions pkg/servicemesh/federation/status/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,12 @@ func TestStatusManager(t *testing.T) {
log.Configure(logOpts)
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
newCrdWatcher := kube.NewCrdWatcher
kube.NewCrdWatcher = kube.NewFastCrdWatcher
kubeClient := kube.NewFakeClient(&corev1.Pod{
ObjectMeta: istiodName,
})
kube.NewCrdWatcher = newCrdWatcher
stop := make(chan struct{})
defer func() { close(stop) }()
cs := fake.NewSimpleClientset(
Expand All @@ -712,6 +715,7 @@ func TestStatusManager(t *testing.T) {
}
stopChan := make(chan struct{})
defer close(stopChan)
go kubeClient.RunAndWait(stopChan)
go rm.Start(stopChan)
cs.FederationV1().ServiceMeshPeers(namespace).Create(context.TODO(), &v1.ServiceMeshPeer{
ObjectMeta: meshName,
Expand Down
37 changes: 20 additions & 17 deletions security/pkg/k8s/chiron/test-data/example-ca-cert.pem
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDCzCCAfOgAwIBAgIQbfOzhcKTldFipQ1X2WXpHDANBgkqhkiG9w0BAQsFADAv
MS0wKwYDVQQDEyRhNzU5YzcyZC1lNjcyLTQwMzYtYWMzYy1kYzAxMDBmMTVkNWUw
HhcNMTkwNTE2MjIxMTI2WhcNMjQwNTE0MjMxMTI2WjAvMS0wKwYDVQQDEyRhNzU5
YzcyZC1lNjcyLTQwMzYtYWMzYy1kYzAxMDBmMTVkNWUwggEiMA0GCSqGSIb3DQEB
AQUAA4IBDwAwggEKAoIBAQC6sSAN80Ci0DYFpNDumGYoejMQai42g6nSKYS+ekvs
E7uT+eepO74wj8o6nFMNDu58+XgIsvPbWnn+3WtUjJfyiQXxmmTg8om4uY1C7R1H
gMsrL26pUaXZ/lTE8ZV5CnQJ9XilagY4iZKeptuZkxrWgkFBD7tr652EA3hmj+3h
4sTCQ+pBJKG8BJZDNRrCoiABYBMcFLJsaKuGZkJ6KtxhQEO9QxJVaDoSvlCRGa8R
fcVyYQyXOZ+0VHZJQgaLtqGpiQmlFttpCwDiLfMkk3UAd79ovkhN1MCq+O5N7YVt
eVQWaTUqUV2tKUFvVq21Zdl4dRaq+CF5U8uOqLY/4Kg9AgMBAAGjIzAhMA4GA1Ud
DwEB/wQEAwICBDAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCg
oF71Ey2b1QY22C6BXcANF1+wPzxJovFeKYAnUqwh3rF7pI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Jt/h8yspS1ck8
LJtCole9919umByg5oruflqIlQIDAQABozUwMzALBgNVHQ8EBAMCAgQwDAYDVR0T
BAUwAwEB/zAWBgNVHREEDzANggtjYS5pc3Rpby5pbzANBgkqhkiG9w0BAQsFAAOC
AQEAltHEhhyAsve4K4bLgBXtHwWzo6SpFzdAfXpLShpOJNtQNERb3qg6iUGQdY+w
A2BpmSkKr3Rw/6ClP5+cCG7fGocPaZh+c+4Nxm9suMuZBZCtNOeYOMIfvCPcCS+8
PQ/0hC4/0J3WJKzGBssaaMufJxzgFPPtDJ998kY8rlROghdSaVt423/jXIAYnP3Y
05n8TGERBj7TLdtIVbtUIx3JHAo3PWJywA6mEDovFMJhJERp9sDHIr1BbhXK1TFN
Z6HNH6gInkSSMtvC4Ptejb749PTaePRPF7ID//eq/3AH8UK50F3TQcLjEqWUsJUn
aFKltOc+RAjzDklcUPeG4Y6eMA==
-----END CERTIFICATE-----
47 changes: 30 additions & 17 deletions security/pkg/k8s/chiron/test-data/example-ca-cert2.pem
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
-----BEGIN CERTIFICATE-----
MIIDDDCCAfSgAwIBAgIRALsN8ND73NbYSKTZZa4jf2EwDQYJKoZIhvcNAQELBQAw
LzEtMCsGA1UEAxMkZTNlM2RlZWQtYzIyNi00OWM2LThmOTktNDU3NmRmMzQ0YWQ1
MB4XDTE5MDYwMTE1NTU0M1oXDTI0MDUzMDE2NTU0M1owLzEtMCsGA1UEAxMkZTNl
M2RlZWQtYzIyNi00OWM2LThmOTktNDU3NmRmMzQ0YWQ1MIIBIjANBgkqhkiG9w0B
AQEFAAOCAQ8AMIIBCgKCAQEA43oeK/hS92ANjmg50LCl3tM7eYAlBB/XgCl+bfp3
KwEf+uW5yEvzSVHd2VPFI/kJJeLFrsyCRaU4FwxWcEr2Ld07DPL34oyZRRXQF0w6
4ZNSVmevBNdZLqHcoIUtR1iFJbkctE93HpGw5Kg1NXRLDu47wQtzcC3GDOEk1amu
mL916R2OcYE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V5wuaICS9V6H9B
5vkxDYbbABQQ9OJcy8XR7cqlkUATiH5hVRjMSKJiostO+CiVDWjZyJdNgR0kZeaa
9cSYBdTBxN82A/Vtq4ETq/PG5rR08KQY4HqIlOlo16OxGcJ2zVKSk5lTeI1wx/in
uOnJTo5mDJHOJrtYGuCLiqZp/Fbcz/Tb9Qccc1yw78feYiNV6JXKx3uPvfsNbXkY
KnsorT6OQ9G2d/zKPYUw+JEc1BJpk8okvGT8oTfvnfXty63ccN4+iyohQP/GwtQ9
XiIJ0gGGQjY1VA/L2MOYV0hSMLgddvl4Pt8KXsxQ72gGl8a/s1oOKkYfpm/xchpd
3ldrrKbAwExwhsARrA==
-----END CERTIFICATE-----
102 changes: 55 additions & 47 deletions security/pkg/k8s/chiron/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,43 +43,49 @@ import (

const (
exampleCACert = `-----BEGIN CERTIFICATE-----
MIIDCzCCAfOgAwIBAgIQbfOzhcKTldFipQ1X2WXpHDANBgkqhkiG9w0BAQsFADAv
MS0wKwYDVQQDEyRhNzU5YzcyZC1lNjcyLTQwMzYtYWMzYy1kYzAxMDBmMTVkNWUw
HhcNMTkwNTE2MjIxMTI2WhcNMjQwNTE0MjMxMTI2WjAvMS0wKwYDVQQDEyRhNzU5
YzcyZC1lNjcyLTQwMzYtYWMzYy1kYzAxMDBmMTVkNWUwggEiMA0GCSqGSIb3DQEB
AQUAA4IBDwAwggEKAoIBAQC6sSAN80Ci0DYFpNDumGYoejMQai42g6nSKYS+ekvs
E7uT+eepO74wj8o6nFMNDu58+XgIsvPbWnn+3WtUjJfyiQXxmmTg8om4uY1C7R1H
gMsrL26pUaXZ/lTE8ZV5CnQJ9XilagY4iZKeptuZkxrWgkFBD7tr652EA3hmj+3h
4sTCQ+pBJKG8BJZDNRrCoiABYBMcFLJsaKuGZkJ6KtxhQEO9QxJVaDoSvlCRGa8R
fcVyYQyXOZ+0VHZJQgaLtqGpiQmlFttpCwDiLfMkk3UAd79ovk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b3JuaWExEjAQBgNVBAcTCVN1bm55dmFsZTEOMAwGA1UEChMFSXN0aW8x
ETAPBgNVBAMTCElzdGlvIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
AQEAyzCxr/xu0zy5rVBiso9ffgl00bRKvB/HF4AX9/ytmZ6Hqsy13XIQk8/u/By9
iCvVwXIMvyT0CbiJq/aPEj5mJUy0lzbrUs13oneXqrPXf7ir3HzdRw+SBhXlsh9z
APZJXcF93DJU3GabPKwBvGJ0IVMJPIFCuDIPwW4kFAI7R/8A5LSdPrFx6EyMXl7K
M8jekC0y9DnTj83/fY72WcWX7YTpgZeBHAeeQOPTZ2KYbFal2gLsar69PgFS0Tom
ESO9M14Yit7mzB1WDK2z9g3r+zLxENdJ5JG/ZskKe+TO4Diqi5OJt/h8yspS1ck8
LJtCole9919umByg5oruflqIlQIDAQABozUwMzALBgNVHQ8EBAMCAgQwDAYDVR0T
BAUwAwEB/zAWBgNVHREEDzANggtjYS5pc3Rpby5pbzANBgkqhkiG9w0BAQsFAAOC
AQEAltHEhhyAsve4K4bLgBXtHwWzo6SpFzdAfXpLShpOJNtQNERb3qg6iUGQdY+w
A2BpmSkKr3Rw/6ClP5+cCG7fGocPaZh+c+4Nxm9suMuZBZCtNOeYOMIfvCPcCS+8
PQ/0hC4/0J3WJKzGBssaaMufJxzgFPPtDJ998kY8rlROghdSaVt423/jXIAYnP3Y
05n8TGERBj7TLdtIVbtUIx3JHAo3PWJywA6mEDovFMJhJERp9sDHIr1BbhXK1TFN
Z6HNH6gInkSSMtvC4Ptejb749PTaePRPF7ID//eq/3AH8UK50F3TQcLjEqWUsJUn
aFKltOc+RAjzDklcUPeG4Y6eMA==
-----END CERTIFICATE-----
`
DefaulCertTTL = 24 * time.Hour
Expand Down Expand Up @@ -138,21 +144,23 @@ func TestReadCACert(t *testing.T) {
}

for _, tc := range testCases {
cert, err := readCACert(tc.certPath)
if tc.shouldFail {
if err == nil {
t.Errorf("should have failed at readCACert()")
} else {
// Should fail, skip the current case.
continue
t.Run(tc.certPath, func(t *testing.T) {
cert, err := readCACert(tc.certPath)
if tc.shouldFail {
if err == nil {
t.Errorf("should have failed at readCACert()")
} else {
// Should fail, skip the current case.
return
}
} else if err != nil {
t.Errorf("failed at readCACert(): %v", err)
}
} else if err != nil {
t.Errorf("failed at readCACert(): %v", err)
}

if !bytes.Equal(tc.expectedCert, cert) {
t.Error("the certificate read is unexpected")
}
if !bytes.Equal(tc.expectedCert, cert) {
t.Error("the certificate read is unexpected")
}
})
}
}

Expand Down

0 comments on commit 5e381e6

Please sign in to comment.