Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
autoscaler
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
kubernetes
autoscaler
Commits
81d27d48
Commit
81d27d48
authored
5 months ago
by
Omer Aplatony
Browse files
Options
Downloads
Patches
Plain Diff
comment out TestUnchangedCAReloader test (flake)
Signed-off-by:
Omer Aplatony
<
omerap12@gmail.com
>
parent
4af31633
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
vertical-pod-autoscaler/pkg/admission-controller/certs_test.go
+117
-116
117 additions, 116 deletions
...cal-pod-autoscaler/pkg/admission-controller/certs_test.go
with
117 additions
and
116 deletions
vertical-pod-autoscaler/pkg/admission-controller/certs_test.go
+
117
−
116
View file @
81d27d48
...
@@ -276,119 +276,120 @@ func TestChangedCAReloader(t *testing.T) {
...
@@ -276,119 +276,120 @@ func TestChangedCAReloader(t *testing.T) {
assert
.
NotEqual
(
t
,
oldCAEncodedString
,
newCAEncodedString
,
"expected CA to change"
)
assert
.
NotEqual
(
t
,
oldCAEncodedString
,
newCAEncodedString
,
"expected CA to change"
)
}
}
func
TestUnchangedCAReloader
(
t
*
testing
.
T
)
{
// TODO(omerap12): Temporary workaround for flakiness (#7831)
tempDir
:=
t
.
TempDir
()
// func TestUnchangedCAReloader(t *testing.T) {
caCert
:=
&
x509
.
Certificate
{
// tempDir := t.TempDir()
SerialNumber
:
big
.
NewInt
(
0
),
// caCert := &x509.Certificate{
Subject
:
pkix
.
Name
{
// SerialNumber: big.NewInt(0),
Organization
:
[]
string
{
"ca"
},
// Subject: pkix.Name{
},
// Organization: []string{"ca"},
NotBefore
:
time
.
Now
(),
// },
NotAfter
:
time
.
Now
()
.
AddDate
(
2
,
0
,
0
),
// NotBefore: time.Now(),
IsCA
:
true
,
// NotAfter: time.Now().AddDate(2, 0, 0),
ExtKeyUsage
:
[]
x509
.
ExtKeyUsage
{
x509
.
ExtKeyUsageClientAuth
,
x509
.
ExtKeyUsageServerAuth
},
// IsCA: true,
KeyUsage
:
x509
.
KeyUsageDigitalSignature
|
x509
.
KeyUsageCertSign
,
// ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
BasicConstraintsValid
:
true
,
// KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
}
// BasicConstraintsValid: true,
caKey
,
err
:=
rsa
.
GenerateKey
(
rand
.
Reader
,
4096
)
// }
if
err
!=
nil
{
// caKey, err := rsa.GenerateKey(rand.Reader, 4096)
t
.
Error
(
err
)
// if err != nil {
}
// t.Error(err)
caBytes
,
err
:=
x509
.
CreateCertificate
(
rand
.
Reader
,
caCert
,
caCert
,
&
caKey
.
PublicKey
,
caKey
)
// }
if
err
!=
nil
{
// caBytes, err := x509.CreateCertificate(rand.Reader, caCert, caCert, &caKey.PublicKey, caKey)
t
.
Error
(
err
)
// if err != nil {
}
// t.Error(err)
caPath
:=
path
.
Join
(
tempDir
,
"ca.crt"
)
// }
caFile
,
err
:=
os
.
Create
(
caPath
)
// caPath := path.Join(tempDir, "ca.crt")
if
err
!=
nil
{
// caFile, err := os.Create(caPath)
t
.
Error
(
err
)
// if err != nil {
}
// t.Error(err)
err
=
pem
.
Encode
(
caFile
,
&
pem
.
Block
{
// }
Type
:
"CERTIFICATE"
,
// err = pem.Encode(caFile, &pem.Block{
Bytes
:
caBytes
,
// Type: "CERTIFICATE",
})
// Bytes: caBytes,
if
err
!=
nil
{
// })
t
.
Error
(
err
)
// if err != nil {
}
// t.Error(err)
// }
testClientSet
:=
fake
.
NewSimpleClientset
()
// testClientSet := fake.NewSimpleClientset()
selfRegistration
(
testClientSet
,
// selfRegistration(
readFile
(
caPath
),
// testClientSet,
0
*
time
.
Second
,
// readFile(caPath),
"default"
,
// 0*time.Second,
"vpa-service"
,
// "default",
"http://example.com/"
,
// "vpa-service",
true
,
// "http://example.com/",
int32
(
32
),
// true,
""
,
// int32(32),
[]
string
{},
// "",
false
,
// []string{},
"key1:value1,key2:value2"
,
// false,
)
// "key1:value1,key2:value2",
// )
webhookConfigInterface
:=
testClientSet
.
AdmissionregistrationV1
()
.
MutatingWebhookConfigurations
()
oldWebhookConfig
,
err
:=
webhookConfigInterface
.
Get
(
context
.
TODO
(),
webhookConfigName
,
metav1
.
GetOptions
{})
// webhookConfigInterface := testClientSet.AdmissionregistrationV1().MutatingWebhookConfigurations()
if
err
!=
nil
{
// oldWebhookConfig, err := webhookConfigInterface.Get(context.TODO(), webhookConfigName, metav1.GetOptions{})
t
.
Error
(
err
)
// if err != nil {
}
// t.Error(err)
// }
assert
.
Len
(
t
,
oldWebhookConfig
.
Webhooks
,
1
,
"expected one webhook configuration"
)
webhook
:=
oldWebhookConfig
.
Webhooks
[
0
]
// assert.Len(t, oldWebhookConfig.Webhooks, 1, "expected one webhook configuration")
oldWebhookCABundle
:=
webhook
.
ClientConfig
.
CABundle
// webhook := oldWebhookConfig.Webhooks[0]
// oldWebhookCABundle := webhook.ClientConfig.CABundle
var
reloadWebhookCACalled
,
patchCalled
atomic
.
Bool
reloadWebhookCACalled
.
Store
(
false
)
// var reloadWebhookCACalled, patchCalled atomic.Bool
patchCalled
.
Store
(
false
)
// reloadWebhookCACalled.Store(false)
testClientSet
.
PrependReactor
(
"get"
,
"mutatingwebhookconfigurations"
,
func
(
action
k8stesting
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
// patchCalled.Store(false)
reloadWebhookCACalled
.
Store
(
true
)
// testClientSet.PrependReactor("get", "mutatingwebhookconfigurations", func(action k8stesting.Action) (bool, runtime.Object, error) {
return
false
,
nil
,
nil
// reloadWebhookCACalled.Store(true)
})
// return false, nil, nil
testClientSet
.
PrependReactor
(
"patch"
,
"mutatingwebhookconfigurations"
,
func
(
action
k8stesting
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
// })
patchCalled
.
Store
(
true
)
// testClientSet.PrependReactor("patch", "mutatingwebhookconfigurations", func(action k8stesting.Action) (bool, runtime.Object, error) {
return
false
,
nil
,
nil
// patchCalled.Store(true)
})
// return false, nil, nil
// })
reloader
:=
certReloader
{
clientCaPath
:
caPath
,
// reloader := certReloader{
mutatingWebhookClient
:
testClientSet
.
AdmissionregistrationV1
()
.
MutatingWebhookConfigurations
(),
// clientCaPath: caPath,
}
// mutatingWebhookClient: testClientSet.AdmissionregistrationV1().MutatingWebhookConfigurations(),
stop
:=
make
(
chan
struct
{})
// }
defer
close
(
stop
)
// stop := make(chan struct{})
if
err
:=
reloader
.
start
(
stop
);
err
!=
nil
{
// defer close(stop)
t
.
Error
(
err
)
// if err := reloader.start(stop); err != nil {
}
// t.Error(err)
// }
originalCaFile
,
err
:=
os
.
ReadFile
(
caPath
)
if
err
!=
nil
{
// originalCaFile, err := os.ReadFile(caPath)
t
.
Error
(
err
)
// if err != nil {
}
// t.Error(err)
err
=
os
.
WriteFile
(
caPath
,
originalCaFile
,
0666
)
// }
if
err
!=
nil
{
// err = os.WriteFile(caPath, originalCaFile, 0666)
t
.
Error
(
err
)
// if err != nil {
}
// t.Error(err)
// }
oldCAEncodedString
:=
base64
.
StdEncoding
.
EncodeToString
(
oldWebhookCABundle
)
// oldCAEncodedString := base64.StdEncoding.EncodeToString(oldWebhookCABundle)
for
tries
:=
0
;
tries
<
10
;
tries
++
{
if
reloadWebhookCACalled
.
Load
()
{
// for tries := 0; tries < 10; tries++ {
break
// if reloadWebhookCACalled.Load() {
}
// break
time
.
Sleep
(
1
*
time
.
Second
)
// }
}
// time.Sleep(1 * time.Second)
if
!
reloadWebhookCACalled
.
Load
()
{
// }
t
.
Error
(
"expected reloadWebhookCA to be called"
)
// if !reloadWebhookCACalled.Load() {
}
// t.Error("expected reloadWebhookCA to be called")
// }
assert
.
False
(
t
,
patchCalled
.
Load
(),
"expected patch to not be called"
)
// assert.False(t, patchCalled.Load(), "expected patch to not be called")
newWebhookConfig
,
err
:=
webhookConfigInterface
.
Get
(
context
.
TODO
(),
webhookConfigName
,
metav1
.
GetOptions
{})
assert
.
Nil
(
t
,
err
,
"expected no error"
)
// newWebhookConfig, err := webhookConfigInterface.Get(context.TODO(), webhookConfigName, metav1.GetOptions{})
assert
.
NotNil
(
t
,
newWebhookConfig
,
"expected webhook configuration"
)
// assert.Nil(t, err, "expected no error")
assert
.
Len
(
t
,
newWebhookConfig
.
Webhooks
,
1
,
"expected one webhook configuration"
)
// assert.NotNil(t, newWebhookConfig, "expected webhook configuration")
// assert.Len(t, newWebhookConfig.Webhooks, 1, "expected one webhook configuration")
newWebhookCABundle
:=
newWebhookConfig
.
Webhooks
[
0
]
.
ClientConfig
.
CABundle
newCAEncodedString
:=
base64
.
StdEncoding
.
EncodeToString
(
newWebhookCABundle
)
// newWebhookCABundle := newWebhookConfig.Webhooks[0].ClientConfig.CABundle
assert
.
Equal
(
t
,
oldCAEncodedString
,
newCAEncodedString
,
"expected CA to not change"
)
// newCAEncodedString := base64.StdEncoding.EncodeToString(newWebhookCABundle)
}
// assert.Equal(t, oldCAEncodedString, newCAEncodedString, "expected CA to not change")
// }
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment