package source import ( "testing" "time" "github.com/stretchr/testify/require" ) func TestRecordMetricsQuerier_Counts(t *testing.T) { start := time.Now().UTC().Truncate(time.Hour) end := start.Add(time.Hour) r := NewRecordMetricsQuerier(NewNoOpMetricsQuerier()) r.QueryLocalStorageActiveMinutes(start, end) r.QueryLocalStorageUsedAvg(start, end) r.QueryLocalStorageUsedMax(start, end) r.QueryLocalStorageBytes(start, end) r.QueryKMLocalStorageUsedAvg(start, end) r.QueryKMLocalStorageUsedMax(start, end) r.QueryKMLocalStorageBytes(start, end) r.QueryNodeInfo(start, end) r.QueryNodeUptime(start, end) r.QueryNodeActiveMinutes(start, end) r.QueryNodeCPUCoresCapacity(start, end) r.QueryNodeCPUCoresAllocatable(start, end) r.QueryNodeRAMBytesCapacity(start, end) r.QueryNodeRAMBytesAllocatable(start, end) r.QueryNodeGPUCount(start, end) r.QueryNodeCPUModeTotal(start, end) r.QueryNodeIsSpot(start, end) r.QueryNodeRAMSystemPercent(start, end) r.QueryNodeRAMUserPercent(start, end) r.QueryNodeResourceCapacities(start, end) r.QueryNodeResourcesAllocatable(start, end) r.QueryLBActiveMinutes(start, end) r.QueryLBPricePerHr(start, end) r.QueryClusterInfo(start, end) r.QueryClusterUptime(start, end) r.QueryClusterManagementDuration(start, end) r.QueryClusterManagementPricePerHr(start, end) r.QueryPods(start, end) r.QueryPodsUID(start, end) r.QueryPodInfo(start, end) r.QueryPodUptime(start, end) r.QueryPodOwners(start, end) r.QueryPodPVCVolumes(start, end) r.QueryPodNetworkEgressBytes(start, end) r.QueryPodNetworkIngressBytes(start, end) r.QueryContainerUptime(start, end) r.QueryContainerResourceRequests(start, end) r.QueryContainerResourceLimits(start, end) r.QueryRAMBytesAllocated(start, end) r.QueryRAMRequests(start, end) r.QueryRAMLimits(start, end) r.QueryRAMUsageAvg(start, end) r.QueryRAMUsageMax(start, end) r.QueryNodeRAMPricePerGiBHr(start, end) r.QueryCPUCoresAllocated(start, end) r.QueryCPURequests(start, end) r.QueryCPULimits(start, end) r.QueryCPUUsageAvg(start, end) r.QueryCPUUsageMax(start, end) r.QueryNodeCPUPricePerHr(start, end) r.QueryGPUsAllocated(start, end) r.QueryGPUsRequested(start, end) r.QueryGPUsUsageAvg(start, end) r.QueryGPUsUsageMax(start, end) r.QueryNodeGPUPricePerHr(start, end) r.QueryGPUInfo(start, end) r.QueryIsGPUShared(start, end) r.QueryDCGMDeviceInfo(start, end) r.QueryDCGMDeviceUptime(start, end) r.QueryDCGMContainerUsageAvg(start, end) r.QueryDCGMContainerUsageMax(start, end) r.QueryPodPVCAllocation(start, end) r.QueryPVCBytesRequested(start, end) r.QueryPVCInfo(start, end) r.QueryKMPVCInfo(start, end) r.QueryPVCUptime(start, end) r.QueryPVCBytesUsedAverage(start, end) r.QueryPVCBytesUsedMax(start, end) r.QueryPVBytes(start, end) r.QueryPVPricePerGiBHour(start, end) r.QueryPVInfo(start, end) r.QueryPVActiveMinutes(start, end) r.QueryPVUsedAverage(start, end) r.QueryPVUsedMax(start, end) r.QueryKMPVInfo(start, end) r.QueryPVUptime(start, end) r.QueryDeploymentInfo(start, end) r.QueryDeploymentUptime(start, end) r.QueryDeploymentLabels(start, end) r.QueryDeploymentAnnotations(start, end) r.QueryDeploymentMatchLabels(start, end) r.QueryStatefulSetInfo(start, end) r.QueryStatefulSetUptime(start, end) r.QueryStatefulSetLabels(start, end) r.QueryStatefulSetAnnotations(start, end) r.QueryStatefulSetMatchLabels(start, end) r.QueryDaemonSetInfo(start, end) r.QueryDaemonSetUptime(start, end) r.QueryDaemonSetLabels(start, end) r.QueryDaemonSetAnnotations(start, end) r.QueryJobInfo(start, end) r.QueryJobUptime(start, end) r.QueryJobLabels(start, end) r.QueryJobAnnotations(start, end) r.QueryCronJobInfo(start, end) r.QueryCronJobUptime(start, end) r.QueryCronJobLabels(start, end) r.QueryCronJobAnnotations(start, end) r.QueryReplicaSetInfo(start, end) r.QueryReplicaSetUptime(start, end) r.QueryReplicaSetLabels(start, end) r.QueryReplicaSetAnnotations(start, end) r.QueryReplicaSetOwners(start, end) r.QueryNamespaceInfo(start, end) r.QueryNamespaceUptime(start, end) r.QueryServiceInfo(start, end) r.QueryServiceUptime(start, end) r.QueryServiceSelectorLabels(start, end) r.QueryNetZoneGiB(start, end) r.QueryNetZonePricePerGiB(start, end) r.QueryNetRegionGiB(start, end) r.QueryNetRegionPricePerGiB(start, end) r.QueryNetInternetGiB(start, end) r.QueryNetInternetPricePerGiB(start, end) r.QueryNetInternetServiceGiB(start, end) r.QueryNetNatGatewayPricePerGiB(start, end) r.QueryNetNatGatewayGiB(start, end) r.QueryNetTransferBytes(start, end) r.QueryNetZoneIngressGiB(start, end) r.QueryNetRegionIngressGiB(start, end) r.QueryNetInternetIngressGiB(start, end) r.QueryNetInternetServiceIngressGiB(start, end) r.QueryNetNatGatewayIngressPricePerGiB(start, end) r.QueryNetNatGatewayIngressGiB(start, end) r.QueryNetReceiveBytes(start, end) r.QueryNamespaceAnnotations(start, end) r.QueryPodAnnotations(start, end) r.QueryNodeLabels(start, end) r.QueryNamespaceLabels(start, end) r.QueryPodLabels(start, end) r.QueryPodsWithDaemonSetOwner(start, end) r.QueryPodsWithJobOwner(start, end) r.QueryPodsWithReplicaSetOwner(start, end) r.QueryReplicaSetsWithoutOwners(start, end) r.QueryReplicaSetsWithRollout(start, end) r.QueryResourceQuotaInfo(start, end) r.QueryResourceQuotaUptime(start, end) r.QueryResourceQuotaSpecCPURequestAverage(start, end) r.QueryResourceQuotaSpecCPURequestMax(start, end) r.QueryResourceQuotaSpecRAMRequestAverage(start, end) r.QueryResourceQuotaSpecRAMRequestMax(start, end) r.QueryResourceQuotaSpecCPULimitAverage(start, end) r.QueryResourceQuotaSpecCPULimitMax(start, end) r.QueryResourceQuotaSpecRAMLimitAverage(start, end) r.QueryResourceQuotaSpecRAMLimitMax(start, end) r.QueryResourceQuotaStatusUsedCPURequestAverage(start, end) r.QueryResourceQuotaStatusUsedCPURequestMax(start, end) r.QueryResourceQuotaStatusUsedRAMRequestAverage(start, end) r.QueryResourceQuotaStatusUsedRAMRequestMax(start, end) r.QueryResourceQuotaStatusUsedCPULimitAverage(start, end) r.QueryResourceQuotaStatusUsedCPULimitMax(start, end) r.QueryResourceQuotaStatusUsedRAMLimitAverage(start, end) r.QueryResourceQuotaStatusUsedRAMLimitMax(start, end) r.QueryDataCoverage(30) expected := map[string]int{ "QueryLocalStorageActiveMinutes": 1, "QueryLocalStorageUsedAvg": 1, "QueryLocalStorageUsedMax": 1, "QueryLocalStorageBytes": 1, "QueryKMLocalStorageUsedAvg": 1, "QueryKMLocalStorageUsedMax": 1, "QueryKMLocalStorageBytes": 1, "QueryNodeInfo": 1, "QueryNodeUptime": 1, "QueryNodeActiveMinutes": 1, "QueryNodeCPUCoresCapacity": 1, "QueryNodeCPUCoresAllocatable": 1, "QueryNodeRAMBytesCapacity": 1, "QueryNodeRAMBytesAllocatable": 1, "QueryNodeGPUCount": 1, "QueryNodeCPUModeTotal": 1, "QueryNodeIsSpot": 1, "QueryNodeRAMSystemPercent": 1, "QueryNodeRAMUserPercent": 1, "QueryNodeResourceCapacities": 1, "QueryNodeResourcesAllocatable": 1, "QueryLBActiveMinutes": 1, "QueryLBPricePerHr": 1, "QueryClusterInfo": 1, "QueryClusterUptime": 1, "QueryClusterManagementDuration": 1, "QueryClusterManagementPricePerHr": 1, "QueryPods": 1, "QueryPodsUID": 1, "QueryPodInfo": 1, "QueryPodUptime": 1, "QueryPodOwners": 1, "QueryPodPVCVolumes": 1, "QueryPodNetworkEgressBytes": 1, "QueryPodNetworkIngressBytes": 1, "QueryContainerUptime": 1, "QueryContainerResourceRequests": 1, "QueryContainerResourceLimits": 1, "QueryRAMBytesAllocated": 1, "QueryRAMRequests": 1, "QueryRAMLimits": 1, "QueryRAMUsageAvg": 1, "QueryRAMUsageMax": 1, "QueryNodeRAMPricePerGiBHr": 1, "QueryCPUCoresAllocated": 1, "QueryCPURequests": 1, "QueryCPULimits": 1, "QueryCPUUsageAvg": 1, "QueryCPUUsageMax": 1, "QueryNodeCPUPricePerHr": 1, "QueryGPUsAllocated": 1, "QueryGPUsRequested": 1, "QueryGPUsUsageAvg": 1, "QueryGPUsUsageMax": 1, "QueryNodeGPUPricePerHr": 1, "QueryGPUInfo": 1, "QueryIsGPUShared": 1, "QueryDCGMDeviceInfo": 1, "QueryDCGMDeviceUptime": 1, "QueryDCGMContainerUsageAvg": 1, "QueryDCGMContainerUsageMax": 1, "QueryPodPVCAllocation": 1, "QueryPVCBytesRequested": 1, "QueryPVCInfo": 1, "QueryKMPVCInfo": 1, "QueryPVCUptime": 1, "QueryPVCBytesUsedAverage": 1, "QueryPVCBytesUsedMax": 1, "QueryPVBytes": 1, "QueryPVPricePerGiBHour": 1, "QueryPVInfo": 1, "QueryPVActiveMinutes": 1, "QueryPVUsedAverage": 1, "QueryPVUsedMax": 1, "QueryKMPVInfo": 1, "QueryPVUptime": 1, "QueryDeploymentInfo": 1, "QueryDeploymentUptime": 1, "QueryDeploymentLabels": 1, "QueryDeploymentAnnotations": 1, "QueryDeploymentMatchLabels": 1, "QueryStatefulSetInfo": 1, "QueryStatefulSetUptime": 1, "QueryStatefulSetLabels": 1, "QueryStatefulSetAnnotations": 1, "QueryStatefulSetMatchLabels": 1, "QueryDaemonSetInfo": 1, "QueryDaemonSetUptime": 1, "QueryDaemonSetLabels": 1, "QueryDaemonSetAnnotations": 1, "QueryJobInfo": 1, "QueryJobUptime": 1, "QueryJobLabels": 1, "QueryJobAnnotations": 1, "QueryCronJobInfo": 1, "QueryCronJobUptime": 1, "QueryCronJobLabels": 1, "QueryCronJobAnnotations": 1, "QueryReplicaSetInfo": 1, "QueryReplicaSetUptime": 1, "QueryReplicaSetLabels": 1, "QueryReplicaSetAnnotations": 1, "QueryReplicaSetOwners": 1, "QueryNamespaceInfo": 1, "QueryNamespaceUptime": 1, "QueryServiceInfo": 1, "QueryServiceUptime": 1, "QueryServiceSelectorLabels": 1, "QueryNetZoneGiB": 1, "QueryNetZonePricePerGiB": 1, "QueryNetRegionGiB": 1, "QueryNetRegionPricePerGiB": 1, "QueryNetInternetGiB": 1, "QueryNetInternetPricePerGiB": 1, "QueryNetInternetServiceGiB": 1, "QueryNetNatGatewayPricePerGiB": 1, "QueryNetNatGatewayGiB": 1, "QueryNetTransferBytes": 1, "QueryNetZoneIngressGiB": 1, "QueryNetRegionIngressGiB": 1, "QueryNetInternetIngressGiB": 1, "QueryNetInternetServiceIngressGiB": 1, "QueryNetNatGatewayIngressPricePerGiB": 1, "QueryNetNatGatewayIngressGiB": 1, "QueryNetReceiveBytes": 1, "QueryNamespaceAnnotations": 1, "QueryPodAnnotations": 1, "QueryNodeLabels": 1, "QueryNamespaceLabels": 1, "QueryPodLabels": 1, "QueryPodsWithDaemonSetOwner": 1, "QueryPodsWithJobOwner": 1, "QueryPodsWithReplicaSetOwner": 1, "QueryReplicaSetsWithoutOwners": 1, "QueryReplicaSetsWithRollout": 1, "QueryResourceQuotaInfo": 1, "QueryResourceQuotaUptime": 1, "QueryResourceQuotaSpecCPURequestAverage": 1, "QueryResourceQuotaSpecCPURequestMax": 1, "QueryResourceQuotaSpecRAMRequestAverage": 1, "QueryResourceQuotaSpecRAMRequestMax": 1, "QueryResourceQuotaSpecCPULimitAverage": 1, "QueryResourceQuotaSpecCPULimitMax": 1, "QueryResourceQuotaSpecRAMLimitAverage": 1, "QueryResourceQuotaSpecRAMLimitMax": 1, "QueryResourceQuotaStatusUsedCPURequestAverage": 1, "QueryResourceQuotaStatusUsedCPURequestMax": 1, "QueryResourceQuotaStatusUsedRAMRequestAverage": 1, "QueryResourceQuotaStatusUsedRAMRequestMax": 1, "QueryResourceQuotaStatusUsedCPULimitAverage": 1, "QueryResourceQuotaStatusUsedCPULimitMax": 1, "QueryResourceQuotaStatusUsedRAMLimitAverage": 1, "QueryResourceQuotaStatusUsedRAMLimitMax": 1, "QueryDataCoverage": 1, } require.Equal(t, expected, r.Calls) }