Skip to content

Commit 822cf92

Browse files
committed
wip
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent fd049aa commit 822cf92

File tree

2 files changed

+50
-23
lines changed

2 files changed

+50
-23
lines changed

observability/install-observability.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,22 @@ echo -e "${GREEN}Installing Observability Stack${NC}"
2828
echo -e "${GREEN}OpenTelemetry + Prometheus + Grafana${NC}"
2929
echo -e "${GREEN}========================================${NC}"
3030

31-
# Check if helm is installed
31+
# Check if helm is installed, download locally if not
3232
echo -e "\n${YELLOW}Checking helm installation...${NC}"
3333
if ! command -v helm &> /dev/null; then
34-
echo -e "${RED}Error: helm is not installed${NC}"
35-
echo "Please install helm: https://helm.sh/docs/intro/install/"
36-
exit 1
34+
echo -e "${YELLOW}helm not found, downloading locally...${NC}"
35+
HELM_INSTALL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.helm"
36+
mkdir -p "$HELM_INSTALL_DIR"
37+
HELM_BIN="$HELM_INSTALL_DIR/helm"
38+
if [ ! -f "$HELM_BIN" ]; then
39+
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 \
40+
| HELM_INSTALL_DIR="$HELM_INSTALL_DIR" USE_SUDO=false bash
41+
fi
42+
export PATH="$HELM_INSTALL_DIR:$PATH"
43+
echo -e "${GREEN}✓ helm downloaded to $HELM_BIN${NC}"
44+
else
45+
echo -e "${GREEN}✓ helm is installed${NC}"
3746
fi
38-
echo -e "${GREEN}✓ helm is installed${NC}"
3947

4048
# Add Helm repositories
4149
echo -e "\n${YELLOW}Adding Helm repositories...${NC}"

sample-operators/metrics-processing/src/test/java/io/javaoperatorsdk/operator/sample/metrics/MetricsHandlingE2E.java

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,46 @@ private void closePortForward(LocalPortForward portForward, String name) {
112112
}
113113
}
114114

115+
// todo check historgram execution time
116+
// failoures by controller
117+
// delete event rate - delete resources in test
118+
// error rate
115119
@Test
116120
void testPropagatedMetrics() throws Exception {
117-
log.info("Starting metrics propagation test");
118-
119-
// Create successful resources
120-
MetricsHandlingCustomResource1 successResource1 = createResource1("test-success-1", 42);
121-
operator.create(successResource1);
122-
123-
MetricsHandlingCustomResource2 successResource2 = createResource2("test-success-2", 77);
124-
operator.create(successResource2);
125-
126-
// Create resources that will fail
127-
MetricsHandlingCustomResource1 failResource1 = createResource1("test-fail-1", 100);
128-
operator.create(failResource1);
129-
130-
MetricsHandlingCustomResource2 errorResource2 = createResource2("test-error-2", 200);
131-
operator.create(errorResource2);
121+
log.info("Starting longevity metrics test (running for ~50 seconds)");
122+
123+
// Create initial resources including ones that trigger failures
124+
operator.create(createResource1("test-success-1", 42));
125+
operator.create(createResource2("test-success-2", 77));
126+
operator.create(createResource1("test-fail-1", 100));
127+
operator.create(createResource2("test-error-2", 200));
128+
129+
// Continuously trigger reconciliations for ~50 seconds by alternating between
130+
// creating new resources and updating specs of existing ones
131+
long deadline = System.currentTimeMillis() + Duration.ofSeconds(50).toMillis();
132+
int counter = 0;
133+
while (System.currentTimeMillis() < deadline) {
134+
counter++;
135+
switch (counter % 3) {
136+
case 0 -> {
137+
operator.create(createResource1("test-dynamic-1-" + counter, counter * 3));
138+
log.info("Iteration {}: created test-dynamic-1-{}", counter, counter);
139+
}
140+
case 1 -> {
141+
var r1 = operator.get(MetricsHandlingCustomResource1.class, "test-success-1");
142+
r1.getSpec().setNumber(counter * 7);
143+
operator.replace(r1);
144+
log.info("Iteration {}: updated test-success-1 number to {}", counter, counter * 7);
145+
}
146+
case 2 -> {
147+
operator.create(createResource2("test-dynamic-2-" + counter, counter * 5));
148+
log.info("Iteration {}: created test-dynamic-2-{}", counter, counter);
149+
}
150+
}
151+
Thread.sleep(1000);
152+
}
132153

133-
// Wait for reconciliations to happen multiple times
134-
log.info("Waiting for reconciliations to occur...");
135-
Thread.sleep(10000);
154+
log.info("Longevity phase completed ({} iterations), verifying metrics", counter);
136155
verifyPrometheusMetrics();
137156
}
138157

0 commit comments

Comments
 (0)