在 Terraform v13 中创建自动缩放策略和 cloudwatch 警报资源时,它们创建得很好。然而,在对端点进行负载测试时,他们成功地扩展了实例,但当 CPU 利用率在一段时间内达到必要的百分比时,他们无法缩小实例。错误看起来像这样:
"historySummary": "无法执行 AutoScaling 操作:未找到指标值 [5.99763732496649、2.7634547331059975] 和违规增量 -4.00236267503351 的步长调整"
下面列出了地形资源:
自动缩放策略 -
resource "aws_appautoscaling_policy" "frontend_down" {
name = "${var.name}_frontend_scale_down"
service_namespace = "ecs"
resource_id = "service/${aws_ecs_cluster.main.name}/${aws_ecs_service.frontend.name}"
scalable_dimension = "ecs:service:DesiredCount"
step_scaling_policy_configuration {
adjustment_type = "ChangeInCapacity"
cooldown = 30
metric_aggregation_type = "Maximum"
step_adjustment {
metric_interval_lower_bound = 0
scaling_adjustment = -1
}
}
depends_on = [aws_appautoscaling_target.frontend_target]
}
Run Code Online (Sandbox Code Playgroud)
云表警报 -
resource "aws_cloudwatch_metric_alarm" "frontend_service_cpu_low" {
alarm_name = "${var.name}_cpu_utilization_low_fe"
comparison_operator = "LessThanOrEqualToThreshold"
evaluation_periods = "2"
metric_name = "CPUUtilization"
namespace = …Run Code Online (Sandbox Code Playgroud) javascript amazon-web-services autoscaling amazon-cloudwatch terraform
我不确定使用 React 测试库的 Render 的自定义渲染函数的返回类型,我假设它是 element 或 JSX,但这似乎不起作用。
代码:
import React, { ReactElement } from 'react'
import { render, RenderOptions } from '@testing-library/react'
import { theme } from './theme'
import { ThemeProvider } from 'styled-components'
import { Provider } from 'react-redux'
import { createStore } from 'redux'
import { searchReducer, initialState } from './store/reducer/searchReducer'
const store = createStore(searchReducer, initialState)
interface ProviderProps {
children?: NonNullable<React.ReactNode>
}
const TheProvider: React.FC<ProviderProps> = ({
children,
}) => {
return (
<Provider store={store}>
<ThemeProvider theme={theme}> …Run Code Online (Sandbox Code Playgroud) function typescript reactjs react-testing-library react-typescript