...

Source file src/github.com/chaos-mesh/chaos-mesh/api/v1alpha1/physical_machine_chaos_types.go

Documentation: github.com/chaos-mesh/chaos-mesh/api/v1alpha1

     1  // Copyright 2021 Chaos Mesh Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  // http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  //
    15  
    16  package v1alpha1
    17  
    18  import (
    19  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    20  )
    21  
    22  // PhysicalMachineChaosAction represents the chaos action about physical machine.
    23  type PhysicalMachineChaosAction string
    24  
    25  var (
    26  	PMStressCPUAction            PhysicalMachineChaosAction = "stress-cpu"
    27  	PMStressMemAction            PhysicalMachineChaosAction = "stress-mem"
    28  	PMDiskWritePayloadAction     PhysicalMachineChaosAction = "disk-write-payload"
    29  	PMDiskReadPayloadAction      PhysicalMachineChaosAction = "disk-read-payload"
    30  	PMDiskFillAction             PhysicalMachineChaosAction = "disk-fill"
    31  	PMNetworkCorruptAction       PhysicalMachineChaosAction = "network-corrupt"
    32  	PMNetworkDuplicateAction     PhysicalMachineChaosAction = "network-duplicate"
    33  	PMNetworkLossAction          PhysicalMachineChaosAction = "network-loss"
    34  	PMNetworkDelayAction         PhysicalMachineChaosAction = "network-delay"
    35  	PMNetworkPartitionAction     PhysicalMachineChaosAction = "network-partition"
    36  	PMNetworkBandwidthAction     PhysicalMachineChaosAction = "network-bandwidth"
    37  	PMNetworkDNSAction           PhysicalMachineChaosAction = "network-dns"
    38  	PMNetworkFloodAction         PhysicalMachineChaosAction = "network-flood"
    39  	PMNetworkDownAction          PhysicalMachineChaosAction = "network-down"
    40  	PMProcessAction              PhysicalMachineChaosAction = "process"
    41  	PMJVMExceptionAction         PhysicalMachineChaosAction = "jvm-exception"
    42  	PMJVMGCAction                PhysicalMachineChaosAction = "jvm-gc"
    43  	PMJVMLatencyAction           PhysicalMachineChaosAction = "jvm-latency"
    44  	PMJVMReturnAction            PhysicalMachineChaosAction = "jvm-return"
    45  	PMJVMStressAction            PhysicalMachineChaosAction = "jvm-stress"
    46  	PMJVMRuleDataAction          PhysicalMachineChaosAction = "jvm-rule-data"
    47  	PMJVMMySQLAction             PhysicalMachineChaosAction = "jvm-mysql"
    48  	PMClockAction                PhysicalMachineChaosAction = "clock"
    49  	PMRedisExpirationAction      PhysicalMachineChaosAction = "redis-expiration"
    50  	PMRedisPenetrationAction     PhysicalMachineChaosAction = "redis-penetration"
    51  	PMRedisCacheLimitAction      PhysicalMachineChaosAction = "redis-cacheLimit"
    52  	PMRedisSentinelRestartAction PhysicalMachineChaosAction = "redis-restart"
    53  	PMRedisSentinelStopAction    PhysicalMachineChaosAction = "redis-stop"
    54  	PMKafkaFillAction            PhysicalMachineChaosAction = "kafka-fill"
    55  	PMKafkaFloodAction           PhysicalMachineChaosAction = "kafka-flood"
    56  	PMKafkaIOAction              PhysicalMachineChaosAction = "kafka-io"
    57  	PMHTTPAbortAction            PhysicalMachineChaosAction = "http-abort"
    58  	PMHTTPDelayAction            PhysicalMachineChaosAction = "http-delay"
    59  	PMHTTPConfigAction           PhysicalMachineChaosAction = "http-config"
    60  	PMHTTPRequestAction          PhysicalMachineChaosAction = "http-request"
    61  	PMFileCreateAction           PhysicalMachineChaosAction = "file-create"
    62  	PMFileModifyPrivilegeAction  PhysicalMachineChaosAction = "file-modify"
    63  	PMFileDeleteAction           PhysicalMachineChaosAction = "file-delete"
    64  	PMFileRenameAction           PhysicalMachineChaosAction = "file-rename"
    65  	PMFileAppendAction           PhysicalMachineChaosAction = "file-append"
    66  	PMFileReplaceAction          PhysicalMachineChaosAction = "file-replace"
    67  	PMVMAction                   PhysicalMachineChaosAction = "vm"
    68  	PMUserDefinedAction          PhysicalMachineChaosAction = "user_defined"
    69  )
    70  
    71  // +kubebuilder:object:root=true
    72  // +kubebuilder:printcolumn:name="action",type=string,JSONPath=`.spec.action`
    73  // +kubebuilder:printcolumn:name="duration",type=string,JSONPath=`.spec.duration`
    74  // +chaos-mesh:experiment
    75  
    76  // PhysicalMachineChaos is the Schema for the physical machine chaos API
    77  type PhysicalMachineChaos struct {
    78  	metav1.TypeMeta   `json:",inline"`
    79  	metav1.ObjectMeta `json:"metadata,omitempty"`
    80  
    81  	// Spec defines the behavior of a physical machine chaos experiment
    82  	Spec PhysicalMachineChaosSpec `json:"spec"`
    83  
    84  	// +optional
    85  	// Most recently observed status of the chaos experiment
    86  	Status PhysicalMachineChaosStatus `json:"status,omitempty"`
    87  }
    88  
    89  // PhysicalMachineChaosSpec defines the desired state of PhysicalMachineChaos
    90  type PhysicalMachineChaosSpec struct {
    91  	// +kubebuilder:validation:Enum=stress-cpu;stress-mem;disk-read-payload;disk-write-payload;disk-fill;network-corrupt;network-duplicate;network-loss;network-delay;network-partition;network-dns;network-bandwidth;network-flood;network-down;process;jvm-exception;jvm-gc;jvm-latency;jvm-return;jvm-stress;jvm-rule-data;jvm-mysql;clock;redis-expiration;redis-penetration;redis-cacheLimit;redis-restart;redis-stop;kafka-fill;kafka-flood;kafka-io;file-create;file-modify;file-delete;file-rename;file-append;file-replace;vm;user_defined
    92  	Action PhysicalMachineChaosAction `json:"action"`
    93  
    94  	PhysicalMachineSelector `json:",inline"`
    95  
    96  	// ExpInfo string `json:"expInfo"`
    97  	ExpInfo `json:",inline"`
    98  
    99  	// Duration represents the duration of the chaos action
   100  	// +optional
   101  	Duration *string `json:"duration,omitempty" webhook:"Duration"`
   102  
   103  	// RemoteCluster represents the remote cluster where the chaos will be deployed
   104  	// +optional
   105  	RemoteCluster string `json:"remoteCluster,omitempty"`
   106  }
   107  
   108  // PhysicalMachineChaosStatus defines the observed state of PhysicalMachineChaos
   109  type PhysicalMachineChaosStatus struct {
   110  	ChaosStatus `json:",inline"`
   111  }
   112  
   113  func (obj *PhysicalMachineChaos) GetSelectorSpecs() map[string]interface{} {
   114  	return map[string]interface{}{
   115  		".": &obj.Spec.PhysicalMachineSelector,
   116  	}
   117  }
   118  
   119  type PhysicalMachineSelector struct {
   120  	// DEPRECATED: Use Selector instead.
   121  	// Only one of Address and Selector could be specified.
   122  	// +optional
   123  	Address []string `json:"address,omitempty"`
   124  
   125  	// Selector is used to select physical machines that are used to inject chaos action.
   126  	// +optional
   127  	Selector PhysicalMachineSelectorSpec `json:"selector,omitempty"`
   128  
   129  	// Mode defines the mode to run chaos action.
   130  	// Supported mode: one / all / fixed / fixed-percent / random-max-percent
   131  	// +kubebuilder:validation:Enum=one;all;fixed;fixed-percent;random-max-percent
   132  	Mode SelectorMode `json:"mode"`
   133  
   134  	// Value is required when the mode is set to `FixedMode` / `FixedPercentMode` / `RandomMaxPercentMode`.
   135  	// If `FixedMode`, provide an integer of physical machines to do chaos action.
   136  	// If `FixedPercentMode`, provide a number from 0-100 to specify the percent of physical machines the server can do chaos action.
   137  	// IF `RandomMaxPercentMode`,  provide a number from 0-100 to specify the max percent of pods to do chaos action
   138  	// +optional
   139  	Value string `json:"value,omitempty"`
   140  }
   141  
   142  // PhysicalMachineSelectorSpec defines some selectors to select objects.
   143  // If the all selectors are empty, all objects will be used in chaos experiment.
   144  type PhysicalMachineSelectorSpec struct {
   145  	GenericSelectorSpec `json:",inline"`
   146  
   147  	// PhysicalMachines is a map of string keys and a set values that used to select physical machines.
   148  	// The key defines the namespace which physical machine belong,
   149  	// and each value is a set of physical machine names.
   150  	// +optional
   151  	PhysicalMachines map[string][]string `json:"physicalMachines,omitempty"`
   152  }
   153  
   154  func (spec *PhysicalMachineSelectorSpec) Empty() bool {
   155  	if spec == nil {
   156  		return true
   157  	}
   158  	if len(spec.AnnotationSelectors) != 0 || len(spec.FieldSelectors) != 0 || len(spec.LabelSelectors) != 0 ||
   159  		len(spec.Namespaces) != 0 || len(spec.PhysicalMachines) != 0 || len(spec.ExpressionSelectors) != 0 {
   160  		return false
   161  	}
   162  	return true
   163  }
   164  
   165  type ExpInfo struct {
   166  	// the experiment ID
   167  	// +optional
   168  	UID string `json:"uid,omitempty" swaggerignore:"true"`
   169  
   170  	// the subAction, generate automatically
   171  	// +optional
   172  	Action string `json:"action,omitempty" swaggerignore:"true"`
   173  
   174  	// +ui:form:when=action=='stress-cpu'
   175  	// +optional
   176  	StressCPU *StressCPUSpec `json:"stress-cpu,omitempty"`
   177  
   178  	// +ui:form:when=action=='stress-mem'
   179  	// +optional
   180  	StressMemory *StressMemorySpec `json:"stress-mem,omitempty"`
   181  
   182  	// +ui:form:when=action=='disk-read-payload'
   183  	// +optional
   184  	DiskReadPayload *DiskPayloadSpec `json:"disk-read-payload,omitempty"`
   185  
   186  	// +ui:form:when=action=='disk-write-payload'
   187  	// +optional
   188  	DiskWritePayload *DiskPayloadSpec `json:"disk-write-payload,omitempty"`
   189  
   190  	// +ui:form:when=action=='disk-fill'
   191  	// +optional
   192  	DiskFill *DiskFillSpec `json:"disk-fill,omitempty"`
   193  
   194  	// +ui:form:when=action=='network-corrupt'
   195  	// +optional
   196  	NetworkCorrupt *NetworkCorruptSpec `json:"network-corrupt,omitempty"`
   197  
   198  	// +ui:form:when=action=='network-duplicate'
   199  	// +optional
   200  	NetworkDuplicate *NetworkDuplicateSpec `json:"network-duplicate,omitempty"`
   201  
   202  	// +ui:form:when=action=='network-loss'
   203  	// +optional
   204  	NetworkLoss *NetworkLossSpec `json:"network-loss,omitempty"`
   205  
   206  	// +ui:form:when=action=='network-delay'
   207  	// +optional
   208  	NetworkDelay *NetworkDelaySpec `json:"network-delay,omitempty"`
   209  
   210  	// +ui:form:when=action=='network-partition'
   211  	// +optional
   212  	NetworkPartition *NetworkPartitionSpec `json:"network-partition,omitempty"`
   213  
   214  	// +ui:form:when=action=='network-dns'
   215  	// +optional
   216  	NetworkDNS *NetworkDNSSpec `json:"network-dns,omitempty"`
   217  
   218  	// +ui:form:when=action=='network-bandwidth'
   219  	// +optional
   220  	NetworkBandwidth *NetworkBandwidthSpec `json:"network-bandwidth,omitempty"`
   221  
   222  	// +ui:form:when=action=='network-flood'
   223  	// +optional
   224  	NetworkFlood *NetworkFloodSpec `json:"network-flood,omitempty"`
   225  
   226  	// +ui:form:when=action=='network-down'
   227  	// +optional
   228  	NetworkDown *NetworkDownSpec `json:"network-down,omitempty"`
   229  
   230  	// +ui:form:when=action=='process'
   231  	// +optional
   232  	Process *ProcessSpec `json:"process,omitempty"`
   233  
   234  	// +ui:form:when=action=='jvm-exception'
   235  	// +optional
   236  	JVMException *JVMExceptionSpec `json:"jvm-exception,omitempty"`
   237  
   238  	// +ui:form:when=action=='jvm-gc'
   239  	// +optional
   240  	JVMGC *JVMGCSpec `json:"jvm-gc,omitempty"`
   241  
   242  	// +ui:form:when=action=='jvm-latency'
   243  	// +optional
   244  	JVMLatency *JVMLatencySpec `json:"jvm-latency,omitempty"`
   245  
   246  	// +ui:form:when=action=='jvm-return'
   247  	// +optional
   248  	JVMReturn *JVMReturnSpec `json:"jvm-return,omitempty"`
   249  
   250  	// +ui:form:when=action=='jvm-stress'
   251  	// +optional
   252  	JVMStress *JVMStressSpec `json:"jvm-stress,omitempty"`
   253  
   254  	// +ui:form:when=action=='jvm-rule-data'
   255  	// +optional
   256  	JVMRuleData *JVMRuleDataSpec `json:"jvm-rule-data,omitempty"`
   257  
   258  	// +ui:form:when=action=='jvm-mysql'
   259  	// +optional
   260  	JVMMySQL *PMJVMMySQLSpec `json:"jvm-mysql,omitempty"`
   261  
   262  	// +ui:form:when=action=='clock'
   263  	// +optional
   264  	Clock *ClockSpec `json:"clock,omitempty"`
   265  
   266  	// +ui:form:when=action=='redis-expiration'
   267  	// +optional
   268  	RedisExpiration *RedisExpirationSpec `json:"redis-expiration,omitempty"`
   269  
   270  	// +ui:form:when=action=='redis-penetration'
   271  	// +optional
   272  	RedisPenetration *RedisPenetrationSpec `json:"redis-penetration,omitempty"`
   273  
   274  	// +ui:form:when=action=='redis-cacheLimit'
   275  	// +optional
   276  	RedisCacheLimit *RedisCacheLimitSpec `json:"redis-cacheLimit,omitempty"`
   277  
   278  	// +ui:form:when=action=='redis-restart'
   279  	// +optional
   280  	RedisSentinelRestart *RedisSentinelRestartSpec `json:"redis-restart,omitempty"`
   281  
   282  	// +ui:form:when=action=='redis-stop'
   283  	// +optional
   284  	RedisSentinelStop *RedisSentinelStopSpec `json:"redis-stop,omitempty"`
   285  
   286  	// +ui:form:when=action=='kafka-fill'
   287  	// +optional
   288  	KafkaFill *KafkaFillSpec `json:"kafka-fill,omitempty"`
   289  
   290  	// +ui:form:when=action=='kafka-flood'
   291  	// +optional
   292  	KafkaFlood *KafkaFloodSpec `json:"kafka-flood,omitempty"`
   293  
   294  	// +ui:form:when=action=='kafka-io'
   295  	// +optional
   296  	KafkaIO *KafkaIOSpec `json:"kafka-io,omitempty"`
   297  
   298  	// +ui:form:when=action=='http-abort'
   299  	// +optional
   300  	HTTPAbort *HTTPAbortSpec `json:"http-abort,omitempty"`
   301  
   302  	// +ui:form:when=action=='http-delay'
   303  	// +optional
   304  	HTTPDelay *HTTPDelaySpec `json:"http-delay,omitempty"`
   305  
   306  	// +ui:form:when=action=='http-config'
   307  	// +optional
   308  	HTTPConfig *HTTPConfigSpec `json:"http-config,omitempty"`
   309  
   310  	// +ui:form:when=action=='http-request'
   311  	// +optional
   312  	HTTPRequest *HTTPRequestSpec `json:"http-request,omitempty"`
   313  
   314  	// +ui:form:when=action=='file-create'
   315  	// +optional
   316  	FileCreate *FileCreateSpec `json:"file-create,omitempty"`
   317  
   318  	// +ui:form:when=action=='file-modify'
   319  	// +optional
   320  	FileModifyPrivilege *FileModifyPrivilegeSpec `json:"file-modify,omitempty"`
   321  
   322  	// +ui:form:when=action=='file-delete'
   323  	// +optional
   324  	FileDelete *FileDeleteSpec `json:"file-delete,omitempty"`
   325  
   326  	// +ui:form:when=action=='file-create'
   327  	// +optional
   328  	FileRename *FileRenameSpec `json:"file-rename,omitempty"`
   329  
   330  	// +ui:form:when=action=='file-append'
   331  	// +optional
   332  	FileAppend *FileAppendSpec `json:"file-append,omitempty"`
   333  
   334  	// +ui:form:when=action=='file-replace'
   335  	// +optional
   336  	FileReplace *FileReplaceSpec `json:"file-replace,omitempty"`
   337  
   338  	// +ui:form:when=action=='vm'
   339  	// +optional
   340  	VM *VMSpec `json:"vm,omitempty"`
   341  
   342  	// +ui:form:when=action=='user_defined'
   343  	// +optional
   344  	UserDefined *UserDefinedSpec `json:"user_defined,omitempty"`
   345  }
   346  
   347  type StressCPUSpec struct {
   348  	// specifies P percent loading per CPU worker. 0 is effectively a sleep (no load) and 100 is full loading.
   349  	Load int `json:"load,omitempty"`
   350  	// specifies N workers to apply the stressor.
   351  	Workers int `json:"workers,omitempty"`
   352  	// extend stress-ng options
   353  	Options []string `json:"options,omitempty"`
   354  }
   355  
   356  type StressMemorySpec struct {
   357  	// specifies N bytes consumed per vm worker, default is the total available memory.
   358  	// One can specify the size as % of total available memory or in units of B, KB/KiB, MB/MiB, GB/GiB, TB/TiB..
   359  	Size string `json:"size,omitempty"`
   360  	// extend stress-ng options
   361  	Options []string `json:"options,omitempty"`
   362  }
   363  
   364  type DiskFileSpec struct {
   365  	// specifies how many units of data will write into the file path. support unit: c=1, w=2, b=512, kB=1000,
   366  	// K=1024, MB=1000*1000, M=1024*1024, GB=1000*1000*1000, G=1024*1024*1024 BYTES. example : 1M | 512kB
   367  	Size string `json:"size,omitempty"`
   368  	// specifies the location to fill data in. if path not provided,
   369  	// payload will read/write from/into a temp file, temp file will be deleted after writing
   370  	Path string `json:"path,omitempty"`
   371  }
   372  
   373  type DiskPayloadSpec struct {
   374  	DiskFileSpec `json:",inline"`
   375  
   376  	// specifies the number of process work on writing, default 1, only 1-255 is valid value
   377  	PayloadProcessNum uint8 `json:"payload-process-num,omitempty"`
   378  }
   379  
   380  type DiskFillSpec struct {
   381  	DiskFileSpec `json:",inline"`
   382  
   383  	// fill disk by fallocate
   384  	FillByFallocate bool `json:"fill-by-fallocate,omitempty"`
   385  }
   386  
   387  type NetworkCommonSpec struct {
   388  	// correlation is percentage (10 is 10%)
   389  	Correlation string `json:"correlation,omitempty"`
   390  	// the network interface to impact
   391  	Device string `json:"device,omitempty"`
   392  	// only impact egress traffic from these source ports, use a ',' to separate or to indicate the range, such as 80, 8001:8010.
   393  	// it can only be used in conjunction with -p tcp or -p udp
   394  	SourcePort string `json:"source-port,omitempty"`
   395  	// only impact egress traffic to these destination ports, use a ',' to separate or to indicate the range, such as 80, 8001:8010.
   396  	// it can only be used in conjunction with -p tcp or -p udp
   397  	EgressPort string `json:"egress-port,omitempty"`
   398  	// only impact egress traffic to these IP addresses
   399  	IPAddress string `json:"ip-address,omitempty"`
   400  	// only impact traffic using this IP protocol, supported: tcp, udp, icmp, all
   401  	IPProtocol string `json:"ip-protocol,omitempty"`
   402  	// only impact traffic to these hostnames
   403  	Hostname string `json:"hostname,omitempty"`
   404  }
   405  
   406  type NetworkCorruptSpec struct {
   407  	NetworkCommonSpec `json:",inline"`
   408  
   409  	// percentage of packets to corrupt (10 is 10%)
   410  	Percent string `json:"percent,omitempty"`
   411  }
   412  
   413  type NetworkDuplicateSpec struct {
   414  	NetworkCommonSpec `json:",inline"`
   415  
   416  	// percentage of packets to duplicate (10 is 10%)
   417  	Percent string `json:"percent,omitempty"`
   418  }
   419  
   420  type NetworkLossSpec struct {
   421  	NetworkCommonSpec `json:",inline"`
   422  
   423  	// percentage of packets to loss (10 is 10%)
   424  	Percent string `json:"percent,omitempty"`
   425  }
   426  
   427  type NetworkDelaySpec struct {
   428  	NetworkCommonSpec `json:",inline"`
   429  
   430  	// jitter time, time units: ns, us (or µs), ms, s, m, h.
   431  	Jitter string `json:"jitter,omitempty"`
   432  	// delay egress time, time units: ns, us (or µs), ms, s, m, h.
   433  	Latency string `json:"latency,omitempty"`
   434  	// only the packet which match the tcp flag can be accepted, others will be dropped.
   435  	// only set when the IPProtocol is tcp, used for partition.
   436  	AcceptTCPFlags string `json:"accept-tcp-flags,omitempty"`
   437  }
   438  
   439  type NetworkPartitionSpec struct {
   440  	// the network interface to impact
   441  	Device string `json:"device,omitempty"`
   442  	// only impact traffic to these hostnames
   443  	Hostname string `json:"hostname,omitempty"`
   444  	// only impact egress traffic to these IP addresses
   445  	IPAddress string `json:"ip-address,omitempty"`
   446  	// specifies the partition direction, values can be 'from', 'to'.
   447  	// 'from' means packets coming from the 'IPAddress' or 'Hostname' and going to your server,
   448  	// 'to' means packets originating from your server and going to the 'IPAddress' or 'Hostname'.
   449  	Direction string `json:"direction,omitempty"`
   450  	// only impact egress traffic to these IP addresses
   451  	IPProtocol string `json:"ip-protocol,omitempty"`
   452  	// only the packet which match the tcp flag can be accepted, others will be dropped.
   453  	// only set when the IPProtocol is tcp, used for partition.
   454  	AcceptTCPFlags string `json:"accept-tcp-flags,omitempty"`
   455  }
   456  
   457  type NetworkDNSSpec struct {
   458  	// update the DNS server in /etc/resolv.conf with this value
   459  	DNSServer string `json:"dns-server,omitempty"`
   460  	// map specified host to this IP address
   461  	DNSIp string `json:"dns-ip,omitempty"`
   462  	// map this host to specified IP
   463  	DNSDomainName string `json:"dns-domain-name,omitempty"`
   464  }
   465  
   466  type NetworkBandwidthSpec struct {
   467  	Rate string `json:"rate"`
   468  	// +kubebuilder:validation:Minimum=1
   469  	Limit uint32 `json:"limit"`
   470  	// +kubebuilder:validation:Minimum=1
   471  	Buffer uint32 `json:"buffer"`
   472  
   473  	Peakrate *uint64 `json:"peakrate,omitempty"`
   474  	Minburst *uint32 `json:"minburst,omitempty"`
   475  
   476  	Device    string `json:"device,omitempty"`
   477  	IPAddress string `json:"ip-address,omitempty"`
   478  	Hostname  string `json:"hostname,omitempty"`
   479  }
   480  
   481  type NetworkFloodSpec struct {
   482  	// The speed of network traffic, allows bps, kbps, mbps, gbps, tbps unit. bps means bytes per second
   483  	Rate string `json:"rate"`
   484  	// Generate traffic to this IP address
   485  	IPAddress string `json:"ip-address,omitempty"`
   486  	// Generate traffic to this port on the IP address
   487  	Port string `json:"port,omitempty"`
   488  	// The number of iperf parallel client threads to run
   489  	Parallel int32 `json:"parallel,omitempty"`
   490  	// The number of seconds to run the iperf test
   491  	Duration string `json:"duration"`
   492  }
   493  
   494  type NetworkDownSpec struct {
   495  	// The network interface to impact
   496  	Device string `json:"device,omitempty"`
   497  	// NIC down time, time units: ns, us (or µs), ms, s, m, h.
   498  	Duration string `json:"duration,omitempty"`
   499  }
   500  
   501  type ProcessSpec struct {
   502  	// the process name or the process ID
   503  	Process string `json:"process,omitempty"`
   504  	// the signal number to send
   505  	Signal int `json:"signal,omitempty"`
   506  
   507  	// the command to be run when recovering experiment
   508  	RecoverCmd string `json:"recoverCmd,omitempty"`
   509  }
   510  
   511  type JVMExceptionSpec struct {
   512  	JVMCommonSpec      `json:",inline"`
   513  	JVMClassMethodSpec `json:",inline"`
   514  
   515  	// the exception which needs to throw for action `exception`
   516  	ThrowException string `json:"exception,omitempty"`
   517  }
   518  
   519  type JVMStressSpec struct {
   520  	JVMCommonSpec `json:",inline"`
   521  
   522  	// the CPU core number need to use, only set it when action is stress
   523  	CPUCount int `json:"cpu-count,omitempty"`
   524  
   525  	// the memory type need to locate, only set it when action is stress, the value can be 'stack' or 'heap'
   526  	MemoryType string `json:"mem-type,omitempty"`
   527  }
   528  
   529  type JVMGCSpec struct {
   530  	JVMCommonSpec `json:",inline"`
   531  }
   532  
   533  type JVMLatencySpec struct {
   534  	JVMCommonSpec      `json:",inline"`
   535  	JVMClassMethodSpec `json:",inline"`
   536  
   537  	// the latency duration for action 'latency', unit ms
   538  	LatencyDuration int `json:"latency,omitempty"`
   539  }
   540  
   541  type JVMReturnSpec struct {
   542  	JVMCommonSpec      `json:",inline"`
   543  	JVMClassMethodSpec `json:",inline"`
   544  
   545  	// the return value for action 'return'
   546  	ReturnValue string `json:"value,omitempty"`
   547  }
   548  
   549  type JVMRuleDataSpec struct {
   550  	JVMCommonSpec `json:",inline"`
   551  
   552  	// RuleData used to save the rule file's data, will use it when recover
   553  	RuleData string `json:"rule-data,omitempty"`
   554  }
   555  
   556  type PMJVMMySQLSpec struct {
   557  	JVMCommonSpec `json:",inline"`
   558  
   559  	JVMMySQLSpec `json:",inline"`
   560  
   561  	// The exception which needs to throw for action `exception`
   562  	// or the exception message needs to throw in action `mysql`
   563  	ThrowException string `json:"exception,omitempty"`
   564  
   565  	// The latency duration for action 'latency'
   566  	// or the latency duration in action `mysql`
   567  	LatencyDuration int `json:"latency,omitempty"`
   568  }
   569  
   570  type ClockSpec struct {
   571  	// the pid of target program.
   572  	Pid int `json:"pid,omitempty"`
   573  	// specifies the length of time offset.
   574  	TimeOffset string `json:"time-offset,omitempty"`
   575  	// the identifier of the particular clock on which to act.
   576  	// More clock description in linux kernel can be found in man page of clock_getres, clock_gettime, clock_settime.
   577  	// Muti clock ids should be split with ","
   578  	ClockIdsSlice string `json:"clock-ids-slice,omitempty"`
   579  }
   580  
   581  type RedisCommonSpec struct {
   582  	// The adress of Redis server
   583  	Addr string `json:"addr,omitempty"`
   584  	// The password of Redis server
   585  	Password string `json:"password,omitempty"`
   586  }
   587  
   588  type RedisExpirationSpec struct {
   589  	RedisCommonSpec `json:",inline"`
   590  	// The expiration of the keys
   591  	Expiration string `json:"expiration,omitempty"`
   592  	// The keys to be expired
   593  	Key string `json:"key,omitempty"`
   594  	// Additional options for `expiration`
   595  	Option string `json:"option,omitempty"`
   596  }
   597  
   598  type RedisPenetrationSpec struct {
   599  	RedisCommonSpec `json:",inline"`
   600  	// The number of requests to be sent
   601  	RequestNum int `json:"requestNum,omitempty"`
   602  }
   603  
   604  type RedisCacheLimitSpec struct {
   605  	RedisCommonSpec `json:",inline"`
   606  	// The size of `maxmemory`
   607  	Size string `json:"cacheSize,omitempty"`
   608  	// Specifies maxmemory as a percentage of the original value
   609  	Percent string `json:"percent,omitempty"`
   610  }
   611  
   612  type RedisSentinelRestartSpec struct {
   613  	RedisCommonSpec `json:",inline"`
   614  	// The path of Sentinel conf
   615  	Conf string `json:"conf,omitempty"`
   616  	// The control flag determines whether to flush config
   617  	FlushConfig bool `json:"flushConfig,omitempty"`
   618  	// The path of `redis-server` command-line tool
   619  	RedisPath bool `json:"redisPath,omitempty"`
   620  }
   621  
   622  type RedisSentinelStopSpec struct {
   623  	RedisCommonSpec `json:",inline"`
   624  	// The path of Sentinel conf
   625  	Conf string `json:"conf,omitempty"`
   626  	// The control flag determines whether to flush config
   627  	FlushConfig bool `json:"flushConfig,omitempty"`
   628  	// The path of `redis-server` command-line tool
   629  	RedisPath bool `json:"redisPath,omitempty"`
   630  }
   631  
   632  type KafkaCommonSpec struct {
   633  	// The topic to attack
   634  	Topic string `json:"topic,omitempty"`
   635  	// The host of kafka server
   636  	Host string `json:"host,omitempty"`
   637  	// The port of kafka server
   638  	Port uint16 `json:"port,omitempty"`
   639  	// The username of kafka client
   640  	Username string `json:"username,omitempty"`
   641  	// The password of kafka client
   642  	Password string `json:"password,omitempty"`
   643  }
   644  
   645  type KafkaFillSpec struct {
   646  	KafkaCommonSpec `json:",inline"`
   647  	// The size of each message
   648  	MessageSize uint `json:"messageSize,omitempty"`
   649  	// The max bytes to fill
   650  	MaxBytes uint64 `json:"maxBytes,omitempty"`
   651  	// The command to reload kafka config
   652  	ReloadCommand string `json:"reloadCommand,omitempty"`
   653  }
   654  
   655  type KafkaFloodSpec struct {
   656  	KafkaCommonSpec `json:",inline"`
   657  	// The size of each message
   658  	MessageSize uint `json:"messageSize,omitempty"`
   659  	// The number of worker threads
   660  	Threads uint `json:"threads,omitempty"`
   661  }
   662  
   663  type KafkaIOSpec struct {
   664  	// The topic to attack
   665  	Topic string `json:"topic,omitempty"`
   666  	// The path of server config
   667  	ConfigFile string `json:"configFile,omitempty"`
   668  	// Make kafka cluster non-readable
   669  	NonReadable bool `json:"nonReadable,omitempty"`
   670  	// Make kafka cluster non-writable
   671  	NonWritable bool `json:"nonWritable,omitempty"`
   672  }
   673  
   674  type HTTPCommonSpec struct {
   675  	// Composed with one of the port of HTTP connection, we will only attack HTTP connection with port inside proxy_ports
   676  	ProxyPorts []uint `json:"proxy_ports"`
   677  	// HTTP target: Request or Response
   678  	Target string `json:"target"`
   679  	// The TCP port that the target service listens on
   680  	Port int32 `json:"port,omitempty"`
   681  	// Match path of Uri with wildcard matches
   682  	Path string `json:"path,omitempty"`
   683  	// HTTP method
   684  	Method string `json:"method,omitempty"`
   685  	// Code is a rule to select target by http status code in response
   686  	Code string `json:"code,omitempty"`
   687  }
   688  
   689  type HTTPAbortSpec struct {
   690  	HTTPCommonSpec `json:",inline"`
   691  }
   692  
   693  type HTTPDelaySpec struct {
   694  	HTTPCommonSpec `json:",inline"`
   695  	// Delay represents the delay of the target request/response
   696  	Delay string `json:"delay"`
   697  }
   698  
   699  type HTTPConfigSpec struct {
   700  	// The config file path
   701  	FilePath string `json:"file_path,omitempty"`
   702  }
   703  
   704  // used for HTTP request, now only support GET
   705  type HTTPRequestSpec struct {
   706  	// Request to send"
   707  	URL string `json:"url,omitempty"`
   708  	// Enable connection pool
   709  	EnableConnPool bool `json:"enable-conn-pool,omitempty"`
   710  	// The number of requests to send
   711  	Count int `json:"count,omitempty"`
   712  }
   713  
   714  type FileCreateSpec struct {
   715  	// FileName is the name of the file to be created, modified, deleted, renamed, or appended.
   716  	FileName string `json:"file-name,omitempty"`
   717  	// DirName is the directory name to create or delete.
   718  	DirName string `json:"dir-name,omitempty"`
   719  }
   720  
   721  type FileModifyPrivilegeSpec struct {
   722  	// FileName is the name of the file to be created, modified, deleted, renamed, or appended.
   723  	FileName string `json:"file-name,omitempty"`
   724  	// Privilege is the file privilege to be set.
   725  	Privilege uint32 `json:"privilege,omitempty"`
   726  }
   727  
   728  type FileDeleteSpec struct {
   729  	// FileName is the name of the file to be created, modified, deleted, renamed, or appended.
   730  	FileName string `json:"file-name,omitempty"`
   731  	// DirName is the directory name to create or delete.
   732  	DirName string `json:"dir-name,omitempty"`
   733  }
   734  
   735  type FileRenameSpec struct {
   736  	// SourceFile is the name need to be renamed.
   737  	SourceFile string `json:"source-file,omitempty"`
   738  	// DestFile is the name to be renamed.
   739  	DestFile string `json:"dest-file,omitempty"`
   740  }
   741  
   742  type FileAppendSpec struct {
   743  	// FileName is the name of the file to be created, modified, deleted, renamed, or appended.
   744  	FileName string `json:"file-name,omitempty"`
   745  	// Data is the data for append.
   746  	Data string `json:"data,omitempty"`
   747  	// Count is the number of times to append the data.
   748  	Count int `json:"count,omitempty"`
   749  }
   750  
   751  type FileReplaceSpec struct {
   752  	// FileName is the name of the file to be created, modified, deleted, renamed, or appended.
   753  	FileName string `json:"file-name,omitempty"`
   754  	// OriginStr is the origin string of the file.
   755  	OriginStr string `json:"origin-string,omitempty"`
   756  	// DestStr is the destination string of the file.
   757  	DestStr string `json:"dest-string,omitempty"`
   758  	// Line is the line number of the file to be replaced.
   759  	Line int `json:"line,omitempty"`
   760  }
   761  
   762  type VMSpec struct {
   763  	// The name of the VM to be injected
   764  	VMName string `json:"vm-name,omitempty"`
   765  }
   766  
   767  type UserDefinedSpec struct {
   768  	// The command to be executed when attack
   769  	AttackCmd string `json:"attackCmd,omitempty"`
   770  	// The command to be executed when recover
   771  	RecoverCmd string `json:"recoverCmd,omitempty"`
   772  }
   773