-
Notifications
You must be signed in to change notification settings - Fork 80
/
chaos_http.go
62 lines (59 loc) · 2.29 KB
/
chaos_http.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* chaos_http.go
*
* This source file is part of the FoundationDB open source project
*
* Copyright 2023 Apple Inc. and the FoundationDB project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fixtures
import (
chaosmeshv1alpha1 "github.com/chaos-mesh/chaos-mesh/api/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
)
// InjectHTTPClientChaosWrongResultFdbMonitorConf this method can be used to simulate a bad response from the operator to the sidecar. Currently this method returns as body the value "wrong"
// when the operator does a request against the check_hash/fdbmonitor.conf endpoint, e.g. during upgrades.
func (factory *Factory) InjectHTTPClientChaosWrongResultFdbMonitorConf(selector chaosmeshv1alpha1.PodSelectorSpec, namespace string) *ChaosMeshExperiment {
return factory.CreateExperiment(&chaosmeshv1alpha1.HTTPChaos{
ObjectMeta: metav1.ObjectMeta{
Name: RandStringRunes(32),
Namespace: factory.GetChaosNamespace(),
Labels: factory.GetDefaultLabels(),
},
Spec: chaosmeshv1alpha1.HTTPChaosSpec{
Target: chaosmeshv1alpha1.PodHttpResponse,
Duration: pointer.String(ChaosDurationForever),
PodSelector: chaosmeshv1alpha1.PodSelector{
Selector: selector,
Mode: chaosmeshv1alpha1.AllMode,
},
Port: 8080,
Method: pointer.String("GET"),
Path: pointer.String("check_hash/fdbmonitor.conf"),
PodHttpChaosActions: chaosmeshv1alpha1.PodHttpChaosActions{
Replace: &chaosmeshv1alpha1.PodHttpChaosReplaceActions{
Body: []byte("wrong"),
},
},
TLS: &chaosmeshv1alpha1.PodHttpChaosTLS{
SecretName: factory.GetSecretName(),
SecretNamespace: namespace,
CertName: "tls.crt",
KeyName: "tls.key",
CAName: pointer.String("ca.pem"),
},
},
})
}