Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration-tests/container/QA_TAG
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.3
2.0.4
3 changes: 2 additions & 1 deletion integration-tests/container/schedule-curls/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM alpine:3.8

RUN apk add --update curl && \
apk add python3 && \
rm -rf /var/cache/apk/*

COPY schedule-curls.sh /usr/bin/schedule-curls.sh
COPY schedule-curls.py /usr/bin/schedule-curls.py
63 changes: 63 additions & 0 deletions integration-tests/container/schedule-curls/schedule-curls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import sys
import time
import subprocess

if len(sys.argv) != 6:
print("Usage: python fixed_interval_curl.py NUM_META_ITER NUM_ITER FIXED_INTERVAL_SEC SLEEP_BETWEEN_META_ITER URL", file=sys.stderr)
sys.exit(1)


try:
num_meta_iter = int(sys.argv[1])
num_iter = int(sys.argv[2])
fixed_interval = float(sys.argv[3])
sleep_between_iterations = float(sys.argv[4])
url = sys.argv[5]
except ValueError as e:
print(f"Error parsing numerical arguments: {e}", file=sys.stderr)
sys.exit(1)


def format_timestamp(timestamp: float) -> str:
time_str = time.strftime("%H:%M:%S", time.localtime(timestamp))
milliseconds = f"{timestamp % 1:.3f}"[2:]
return f"{time_str}.{milliseconds}"


def run_curl(target_url: str):
start_time = time.time()
try:
subprocess.run(['curl', '-I', '-s', target_url], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
except subprocess.CalledProcessError as e:
print(f"Curl failed with exit code {e.returncode}: {e}", file=sys.stderr)
sys.exit(e.returncode)
end_time = time.time()
duration = end_time - start_time

print(f"Curl timing: start=[{format_timestamp(start_time)}], end=[{format_timestamp(end_time)}], duration={duration:.3f}s", flush=True)


i = 0
while i < num_meta_iter:
j = 0
start_time = time.time()
while j < num_iter:
next_execution_time = start_time + (j * fixed_interval)
current_time = time.time()
sleep_duration = next_execution_time - current_time
if sleep_duration > 0:
time.sleep(sleep_duration)
else:
pass
execution_time = time.time()
time_str = time.strftime("%H:%M:%S", time.localtime(execution_time))
milliseconds = f"{execution_time % 1:.3f}"[2:]
print(f"[{time_str}.{milliseconds}] Executing curl (Meta: {i + 1}/{num_meta_iter}, Iter: {j + 1}/{num_iter})")
run_curl(url)
j += 1
if sleep_between_iterations > 0:
time.sleep(sleep_between_iterations)
i += 1
print("Script finished successfully.")
print("Sleeping for an additional 300s")
time.sleep(300)
22 changes: 0 additions & 22 deletions integration-tests/container/schedule-curls/schedule-curls.sh

This file was deleted.

11 changes: 5 additions & 6 deletions integration-tests/suites/repeated_network_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ func (s *RepeatedNetworkFlowTestSuite) SetupSuite() {
s.Require().NoError(err)
s.ServerContainer = containerID[0:12]

// invokes another container
containerID, err = s.Executor().StartContainer(config.ContainerStartConfig{Name: "nginx-curl", Image: scheduled_curls_image, Command: []string{"sleep", "300"}})
s.Require().NoError(err)
s.ClientContainer = containerID[0:12]

s.ServerIP, err = s.getIPAddress("nginx")
s.Require().NoError(err)

Expand All @@ -95,7 +90,11 @@ func (s *RepeatedNetworkFlowTestSuite) SetupSuite() {
numIter := strconv.Itoa(s.NumIter)
sleepBetweenCurlTime := strconv.Itoa(s.SleepBetweenCurlTime)
sleepBetweenIterations := strconv.Itoa(s.SleepBetweenIterations)
_, err = s.execContainer("nginx-curl", []string{"/usr/bin/schedule-curls.sh", numMetaIter, numIter, sleepBetweenCurlTime, sleepBetweenIterations, serverAddress}, false)

// Invokes the client container and runs the curls
containerID, err = s.Executor().StartContainer(config.ContainerStartConfig{Name: "nginx-curl", Image: scheduled_curls_image, Command: []string{"python3", "/usr/bin/schedule-curls.py", numMetaIter, numIter, sleepBetweenCurlTime, sleepBetweenIterations, serverAddress}})
s.Require().NoError(err)
s.ClientContainer = containerID[0:12]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously the container was started with a sleep command. That meant that no logs were obtained. Now that the container is started with the python script, we get logs for the python script.


s.ClientIP, err = s.getIPAddress("nginx-curl")
s.Require().NoError(err)
Expand Down
Loading