-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #138 covered by test7-wait Signed-off-by: Nick Mitchell <nickm@us.ibm.com>
- Loading branch information
Showing
17 changed files
with
231 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package queue | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"slices" | ||
"time" | ||
) | ||
|
||
func (c S3Client) WaitForCompletion(task string, verbose bool) error { | ||
for { | ||
doneTasks, err := c.Lsf(c.Paths.Bucket, filepath.Join(c.Paths.PoolPrefix, c.Paths.Outbox)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if idx := slices.IndexFunc(doneTasks, func(otask string) bool { return otask == task }); idx >= 0 { | ||
break | ||
} else { | ||
if verbose { | ||
fmt.Fprintf(os.Stderr, "Still waiting for task completion %s. Here is what is done so far: %v\n", task, doneTasks) | ||
} | ||
time.Sleep(3 * time.Second) | ||
} | ||
} | ||
|
||
if verbose { | ||
fmt.Fprintf(os.Stderr, "Task completed %s\n", task) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# test7-wait | ||
|
||
Same as test7, except this test uses the ParameterSweep in "wait" mode. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPTDIR=$(cd $(dirname "$0") && pwd) | ||
|
||
export NAMESPACE=$1 | ||
|
||
# number of task | ||
N=${2-10} | ||
|
||
# name of s3 bucket in which to store the tasks | ||
BUCKET=${3-test7} | ||
RUN_NAME=$BUCKET | ||
|
||
B=$(mktemp -d)/$BUCKET # bucket path | ||
D=$B/$BUCKET # data path; in this case the bucket name and the folder name are both the run name | ||
mkdir -p $D | ||
echo "Staging to $D" 1>&2 | ||
|
||
for idx in $(seq 1 $N) # for each iteration | ||
do | ||
# if we are doing a test, then make sure to use a | ||
# repeatable name for the task files, so that we know what | ||
# to look for when confirming that the tasks were | ||
# processed by the workers | ||
if [[ -n "$CI" ]] || [[ -n "$RUNNING_CODEFLARE_TESTS" ]]; then | ||
id=$idx | ||
else | ||
# otherwise, use a more random name, so that we can | ||
# inject multiple batches of tasks across executions | ||
# of this script | ||
id=$(uuidgen) | ||
fi | ||
|
||
echo "this is task idx=$idx" > $D/task.$id.txt | ||
done | ||
|
||
"$SCRIPTDIR"/../../../tests/bin/add-data.sh $B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPTDIR=$(cd $(dirname "$0") && pwd) | ||
|
||
# make sure these values are compatible with the values in ./settings.sh | ||
NUM_TASKS=6 | ||
|
||
# $1: namespace | ||
|
||
"$SCRIPTDIR"/add-data-to-queue.sh \ | ||
$1 \ | ||
$NUM_TASKS \ | ||
${TEST_NAME-test7} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
apiVersion: lunchpail.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: test7-wait | ||
spec: | ||
role: worker | ||
code: | ||
- name: main.sh | ||
source: | | ||
#!/usr/bin/env sh | ||
# $1 input filepath | ||
# $2 output filepath | ||
in="$1" | ||
out="$2" | ||
dataset_name=test # match with below! | ||
bucket_name=test7-wait | ||
folder_name=test7-wait | ||
N=$(ls $dataset_name/$bucket_name/$folder_name | wc -l | xargs) | ||
echo "Processing $N $in" | ||
sleep 5 | ||
echo "Done with $in" | ||
command: ./main.sh | ||
minSize: auto | ||
securityContext: | ||
runAsUser: 2000 # lunchpail, same as is specified Dockerfile | ||
runAsGroup: 0 # root, ibid | ||
containerSecurityContext: | ||
runAsUser: 2000 # lunchpail, same as is specified Dockerfile | ||
runAsGroup: 0 # root, ibid | ||
|
||
datasets: | ||
- name: test | ||
s3: | ||
secret: test7data | ||
copyIn: | ||
path: "test7-wait/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: test7data | ||
type: Opaque | ||
stringData: | ||
endpoint: {{ .Values.global.s3Endpoint }} | ||
accessKeyID: {{ .Values.global.s3AccessKey }} | ||
secretAccessKey: {{ .Values.global.s3SecretKey }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: lunchpail.io/v1alpha1 | ||
kind: ParameterSweep | ||
metadata: | ||
name: test7-wait-workdispatcher | ||
spec: | ||
min: 1 | ||
max: {{ .Values.nTasks | default 5 }} | ||
step: 1 | ||
interval: {{ .Values.every | default 5 }} | ||
wait: true | ||
verbose: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: lunchpail.io/v1alpha1 | ||
kind: WorkerPool | ||
metadata: | ||
name: test7-wait-pool1 | ||
spec: | ||
workers: | ||
count: 2 | ||
size: auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.1.4.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
api=workqueue | ||
taskqueue=test7-wait | ||
|
||
# /queue/0,1 <-- 2 workers | ||
# task.1,task.3,task.5 <-- 3 tasks per iter | ||
|
||
expected=("Processing 6 /queue/processing/task.1.txt" "Task completed task.1.txt" "Task completed task.3.txt") |