Skip to content

Commit

Permalink
tests: add test for LoggingLogMetric lazy reconciliation
Browse files Browse the repository at this point in the history
A little hacky right now, we don't have a better mechanism than
sleeping and trying to coordinate timings.
  • Loading branch information
justinsb committed May 15, 2024
1 parent edaf892 commit 7e7db49
Show file tree
Hide file tree
Showing 6 changed files with 529 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/e2e/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ func TestE2EScript(t *testing.T) {
exportResource = nil
shouldGetKubeObject = false

case "SLEEP":
// Allow some time for reconcile
// Maybe we should instead wait for observedState
time.Sleep(2 * time.Second)

case "DELETE-NO-WAIT":
create.DeleteResources(h, create.CreateDeleteTestOptions{Create: []*unstructured.Unstructured{obj}, SkipWaitForDelete: true})

Expand Down
179 changes: 179 additions & 0 deletions tests/e2e/testdata/scenarios/direct/llm_lazy_reconcile/_http00.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
GET https://logging.googleapis.com/v2/projects/${projectId}/metrics/lazyreconcile-${uniqueId}?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5
X-Goog-Api-Client: gl-go/1.22.3 gdcl/0.177.0

404 Not Found
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"error": {
"code": 404,
"message": "Metric lazyreconcile-${uniqueId} does not exist.",
"status": "NOT_FOUND"
}
}

---

POST https://logging.googleapis.com/v2/projects/${projectId}/metrics?alt=json&prettyPrint=false
Content-Type: application/json
User-Agent: google-api-go-client/0.5
X-Goog-Api-Client: gl-go/1.22.3 gdcl/0.177.0

{
"bucketOptions": {
"explicitBuckets": {
"bounds": [
2.5,
5
]
}
},
"filter": "resource.type=gae_app AND severity\u003e=ERROR",
"metricDescriptor": {
"metricKind": "DELTA",
"valueType": "DISTRIBUTION"
},
"name": "lazyreconcile-${uniqueId}",
"valueExtractor": "EXTRACT(jsonPayload.response)"
}

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"bucketOptions": {
"explicitBuckets": {
"bounds": [
2.5,
5
]
}
},
"createTime": "2024-04-01T12:34:56.123456Z",
"filter": "resource.type=gae_app AND severity\u003e=ERROR",
"metricDescriptor": {
"metricKind": "DELTA",
"name": "projects/${projectId}/metricDescriptors/logging.googleapis.com/user/lazyreconcile-${uniqueId}",
"type": "logging.googleapis.com/user/lazyreconcile-${uniqueId}",
"valueType": "DISTRIBUTION"
},
"name": "lazyreconcile-${uniqueId}",
"updateTime": "2024-04-01T12:34:56.123456Z",
"valueExtractor": "EXTRACT(jsonPayload.response)"
}

---

GET https://logging.googleapis.com/v2/projects/${projectId}/metrics/lazyreconcile-${uniqueId}?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5
X-Goog-Api-Client: gl-go/1.22.3 gdcl/0.177.0

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"bucketOptions": {
"explicitBuckets": {
"bounds": [
2.5,
5
]
}
},
"createTime": "2024-04-01T12:34:56.123456Z",
"filter": "resource.type=gae_app AND severity\u003e=ERROR",
"metricDescriptor": {
"metricKind": "DELTA",
"name": "projects/${projectId}/metricDescriptors/logging.googleapis.com/user/lazyreconcile-${uniqueId}",
"type": "logging.googleapis.com/user/lazyreconcile-${uniqueId}",
"valueType": "DISTRIBUTION"
},
"name": "lazyreconcile-${uniqueId}",
"updateTime": "2024-04-01T12:34:56.123456Z",
"valueExtractor": "EXTRACT(jsonPayload.response)"
}

---

PUT https://logging.googleapis.com/v2/projects/${projectId}/metrics/lazyreconcile-${uniqueId}?alt=json&prettyPrint=false
Content-Type: application/json
User-Agent: google-api-go-client/0.5
X-Goog-Api-Client: gl-go/1.22.3 gdcl/0.177.0

{
"bucketOptions": {
"explicitBuckets": {
"bounds": [
2.5,
5
]
}
},
"createTime": "2024-04-01T12:34:56.123456Z",
"filter": "resource.type=gae_app AND severity\u003e=ERROR",
"metricDescriptor": {
"metricKind": "DELTA",
"valueType": "DISTRIBUTION"
},
"name": "lazyreconcile-${uniqueId}",
"updateTime": "2024-04-01T12:34:56.123456Z",
"valueExtractor": "EXTRACT(jsonPayload.response)"
}

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"bucketOptions": {
"explicitBuckets": {
"bounds": [
2.5,
5
]
}
},
"createTime": "2024-04-01T12:34:56.123456Z",
"filter": "resource.type=gae_app AND severity\u003e=ERROR",
"metricDescriptor": {
"metricKind": "DELTA",
"name": "projects/${projectId}/metricDescriptors/logging.googleapis.com/user/lazyreconcile-${uniqueId}",
"type": "logging.googleapis.com/user/lazyreconcile-${uniqueId}",
"valueType": "DISTRIBUTION"
},
"name": "lazyreconcile-${uniqueId}",
"updateTime": "2024-04-01T12:34:56.123456Z",
"valueExtractor": "EXTRACT(jsonPayload.response)"
}
195 changes: 195 additions & 0 deletions tests/e2e/testdata/scenarios/direct/llm_lazy_reconcile/_http01.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
GET https://logging.googleapis.com/v2/projects/${projectId}/metrics/lazyreconcile-${uniqueId}?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5
X-Goog-Api-Client: gl-go/1.22.3 gdcl/0.177.0

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"bucketOptions": {
"explicitBuckets": {
"bounds": [
2.5,
5
]
}
},
"createTime": "2024-04-01T12:34:56.123456Z",
"filter": "resource.type=gae_app AND severity\u003e=ERROR",
"metricDescriptor": {
"metricKind": "DELTA",
"name": "projects/${projectId}/metricDescriptors/logging.googleapis.com/user/lazyreconcile-${uniqueId}",
"type": "logging.googleapis.com/user/lazyreconcile-${uniqueId}",
"valueType": "DISTRIBUTION"
},
"name": "lazyreconcile-${uniqueId}",
"updateTime": "2024-04-01T12:34:56.123456Z",
"valueExtractor": "EXTRACT(jsonPayload.response)"
}

---

PUT https://logging.googleapis.com/v2/projects/${projectId}/metrics/lazyreconcile-${uniqueId}?alt=json&prettyPrint=false
Content-Type: application/json
User-Agent: google-api-go-client/0.5
X-Goog-Api-Client: gl-go/1.22.3 gdcl/0.177.0

{
"bucketOptions": {
"explicitBuckets": {
"bounds": [
2.5,
5
]
}
},
"createTime": "2024-04-01T12:34:56.123456Z",
"filter": "resource.type=gae_app AND severity\u003e=ERROR",
"metricDescriptor": {
"metricKind": "DELTA",
"valueType": "DISTRIBUTION"
},
"name": "lazyreconcile-${uniqueId}",
"updateTime": "2024-04-01T12:34:56.123456Z",
"valueExtractor": "EXTRACT(jsonPayload.response)"
}

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"bucketOptions": {
"explicitBuckets": {
"bounds": [
2.5,
5
]
}
},
"createTime": "2024-04-01T12:34:56.123456Z",
"filter": "resource.type=gae_app AND severity\u003e=ERROR",
"metricDescriptor": {
"metricKind": "DELTA",
"name": "projects/${projectId}/metricDescriptors/logging.googleapis.com/user/lazyreconcile-${uniqueId}",
"type": "logging.googleapis.com/user/lazyreconcile-${uniqueId}",
"valueType": "DISTRIBUTION"
},
"name": "lazyreconcile-${uniqueId}",
"updateTime": "2024-04-01T12:34:56.123456Z",
"valueExtractor": "EXTRACT(jsonPayload.response)"
}

---

GET https://logging.googleapis.com/v2/projects/${projectId}/metrics/lazyreconcile-${uniqueId}?alt=json&prettyPrint=false
User-Agent: google-api-go-client/0.5
X-Goog-Api-Client: gl-go/1.22.3 gdcl/0.177.0

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"bucketOptions": {
"explicitBuckets": {
"bounds": [
2.5,
5
]
}
},
"createTime": "2024-04-01T12:34:56.123456Z",
"filter": "resource.type=gae_app AND severity\u003e=ERROR",
"metricDescriptor": {
"metricKind": "DELTA",
"name": "projects/${projectId}/metricDescriptors/logging.googleapis.com/user/lazyreconcile-${uniqueId}",
"type": "logging.googleapis.com/user/lazyreconcile-${uniqueId}",
"valueType": "DISTRIBUTION"
},
"name": "lazyreconcile-${uniqueId}",
"updateTime": "2024-04-01T12:34:56.123456Z",
"valueExtractor": "EXTRACT(jsonPayload.response)"
}

---

PUT https://logging.googleapis.com/v2/projects/${projectId}/metrics/lazyreconcile-${uniqueId}?alt=json&prettyPrint=false
Content-Type: application/json
User-Agent: google-api-go-client/0.5
X-Goog-Api-Client: gl-go/1.22.3 gdcl/0.177.0

{
"bucketOptions": {
"explicitBuckets": {
"bounds": [
2.5,
5
]
}
},
"createTime": "2024-04-01T12:34:56.123456Z",
"filter": "resource.type=gae_app AND severity\u003e=ERROR",
"metricDescriptor": {
"metricKind": "DELTA",
"valueType": "DISTRIBUTION"
},
"name": "lazyreconcile-${uniqueId}",
"updateTime": "2024-04-01T12:34:56.123456Z",
"valueExtractor": "EXTRACT(jsonPayload.response)"
}

200 OK
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
"bucketOptions": {
"explicitBuckets": {
"bounds": [
2.5,
5
]
}
},
"createTime": "2024-04-01T12:34:56.123456Z",
"filter": "resource.type=gae_app AND severity\u003e=ERROR",
"metricDescriptor": {
"metricKind": "DELTA",
"name": "projects/${projectId}/metricDescriptors/logging.googleapis.com/user/lazyreconcile-${uniqueId}",
"type": "logging.googleapis.com/user/lazyreconcile-${uniqueId}",
"valueType": "DISTRIBUTION"
},
"name": "lazyreconcile-${uniqueId}",
"updateTime": "2024-04-01T12:34:56.123456Z",
"valueExtractor": "EXTRACT(jsonPayload.response)"
}
Loading

0 comments on commit 7e7db49

Please sign in to comment.