Skip to content

Commit

Permalink
Continue implementation of decision jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
sevein committed Jun 6, 2024
1 parent 6471094 commit 88a7895
Show file tree
Hide file tree
Showing 37 changed files with 2,612 additions and 1,619 deletions.
9 changes: 9 additions & 0 deletions hack/ccp/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ linters:
- misspell
- gofumpt
- gci
- importas
- unparam
- gosec
- unused
Expand Down Expand Up @@ -39,3 +40,11 @@ linters-settings:
confidence: low
excludes:
- G601 # does not apply to go1.22+
importas:
no-unaliased: true
no-extra-aliases: false
alias:
- pkg: github.com/artefactual/archivematica/hack/ccp/internal/api/gen/archivematica/ccp/admin/v1beta1
alias: adminv1
- pkg: github.com/artefactual/archivematica/hack/ccp/internal/api/gen/archivematica/ccp/admin/v1beta1/adminv1beta1connect
alias: adminv1connect
20 changes: 11 additions & 9 deletions hack/ccp/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
version: v1
version: v2
managed:
enabled: true
go_package_prefix:
default: github.com/artefactual/archivematica/hack/ccp/internal/api/gen
except:
- buf.build/bufbuild/protovalidate
disable:
- file_option: go_package
module: buf.build/bufbuild/protovalidate
override:
- file_option: go_package_prefix
value: github.com/artefactual/archivematica/hack/ccp/internal/api/gen
plugins:
- plugin: buf.build/protocolbuffers/go
- remote: buf.build/protocolbuffers/go
out: internal/api/gen
opt: paths=source_relative
- plugin: buf.build/connectrpc/go
- remote: buf.build/connectrpc/go
out: internal/api/gen
opt: paths=source_relative
- plugin: buf.build/connectrpc/es
- remote: buf.build/connectrpc/es
out: web/src/gen
opt: target=ts
- plugin: buf.build/bufbuild/es
- remote: buf.build/bufbuild/es
out: web/src/gen
opt: target=ts
6 changes: 6 additions & 0 deletions hack/ccp/buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Generated by buf. DO NOT EDIT.
version: v2
deps:
- name: buf.build/bufbuild/protovalidate
commit: 46a4cf4ba1094a34bcd89a6c67163b4b
digest: b5:2076a950fdf4a8047064d55fd1d20ef21e6d745bf56e3edf557071abd4488ed48c9466d60831d8a03489dc1fcc8ceaa073d197411b59ecd873e28b1328034e0b
3 changes: 0 additions & 3 deletions hack/ccp/buf.work.yaml

This file was deleted.

19 changes: 19 additions & 0 deletions hack/ccp/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: v2
modules:
- path: proto
name: buf.build/artefactual/archivematica
deps:
- buf.build/bufbuild/protovalidate
lint:
use:
- DEFAULT
except:
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
disallow_comment_ignores: true
breaking:
use:
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
18 changes: 9 additions & 9 deletions hack/ccp/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/artefactual/archivematica/hack/ccp

go 1.22.3
go 1.22.4

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.1-20240508200655-46a4cf4ba109.1
Expand All @@ -16,9 +16,10 @@ require (
github.com/fsnotify/fsnotify v1.7.0
github.com/go-logr/logr v1.4.2
github.com/go-sql-driver/mysql v1.8.1
github.com/gohugoio/hugo v0.126.1
github.com/gohugoio/hugo v0.127.0
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
github.com/hashicorp/go-retryablehttp v0.7.6
github.com/hashicorp/go-retryablehttp v0.7.7
github.com/mikespook/gearman-go v0.0.0-20220520031403-2a518e866145
github.com/otiai10/copy v1.14.0
github.com/peterbourgon/ff/v3 v3.4.0
Expand All @@ -33,7 +34,7 @@ require (
go.uber.org/goleak v1.3.0
go.uber.org/mock v0.4.0
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
golang.org/x/net v0.25.0
golang.org/x/net v0.26.0
golang.org/x/sync v0.7.0
google.golang.org/protobuf v1.34.1
gotest.tools/v3 v3.5.1
Expand Down Expand Up @@ -67,7 +68,6 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/cel-go v0.20.1 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/iancoleman/orderedmap v0.2.0 // indirect
github.com/klauspost/compress v1.16.0 // indirect
Expand Down Expand Up @@ -117,11 +117,11 @@ require (
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/tools v0.21.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/grpc v1.62.1 // indirect
Expand Down
34 changes: 18 additions & 16 deletions hack/ccp/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/gohugoio/go-i18n/v2 v2.1.3-0.20230805085216-e63c13218d0e h1:QArsSubW7eDh8APMXkByjQWvuljwPGAGQpJEFn0F0wY=
github.com/gohugoio/go-i18n/v2 v2.1.3-0.20230805085216-e63c13218d0e/go.mod h1:3Ltoo9Banwq0gOtcOwxuHG6omk+AwsQPADyw2vQYOJQ=
github.com/gohugoio/hugo v0.126.1 h1:jzs1VX6Ru/NR0luf4Z9ahKLVmYzQEox4Cxd/kyzgN9A=
github.com/gohugoio/hugo v0.126.1/go.mod h1:wo66RnKrp9Mx0WeeF22LJxPY6YB+v2weKdZpHa8fI/A=
github.com/gohugoio/httpcache v0.7.0 h1:ukPnn04Rgvx48JIinZvZetBfHaWE7I01JR2Q2RrQ3Vs=
github.com/gohugoio/httpcache v0.7.0/go.mod h1:fMlPrdY/vVJhAriLZnrF5QpN3BNAcoBClgAyQd+lGFI=
github.com/gohugoio/hugo v0.127.0 h1:7iKOa0NntxekHHkx2sc4BTsNUpTYE28jnpNM3vrvNr4=
github.com/gohugoio/hugo v0.127.0/go.mod h1:CH5I652/zeb3xwK7dOpd4GFn6ID2hOyvBXaJ2uNDRYQ=
github.com/gohugoio/hugo-goldmark-extensions/extras v0.1.0 h1:YhxZNU8y2vxV6Ibr7QJzzUlpr8oHHWX/l+Q1R/a5Zao=
github.com/gohugoio/hugo-goldmark-extensions/extras v0.1.0/go.mod h1:0cuvOnGKW7WeXA3i7qK6IS07FH1bgJ2XzOjQ7BMJYH4=
github.com/gohugoio/hugo-goldmark-extensions/passthrough v0.2.0 h1:PCtO5l++psZf48yen2LxQ3JiOXxaRC6v0594NeHvGZg=
Expand Down Expand Up @@ -194,8 +196,8 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-retryablehttp v0.7.6 h1:TwRYfx2z2C4cLbXmT8I5PgP/xmuqASDyiVuGYfs9GZM=
github.com/hashicorp/go-retryablehttp v0.7.6/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/iancoleman/orderedmap v0.2.0 h1:sq1N/TFpYH++aViPcaKjys3bDClUEU7s5B+z6jq8pNA=
Expand Down Expand Up @@ -420,8 +422,8 @@ golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
Expand All @@ -442,8 +444,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -464,14 +466,14 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand All @@ -482,8 +484,8 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw=
golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
13 changes: 11 additions & 2 deletions hack/ccp/hack/integration.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
#!/usr/bin/env bash

# USAGE:
# ./hack/integration.sh "TestServerCreatePackageWithUserDecision"

set -e

readonly __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly __root="$(cd "$(dirname "${__dir}")" && pwd)"

runFlag=""
if [[ -n "$1" ]]; then
runFlag="-run=$1"
fi

env \
CCP_INTEGRATION_ENABLED=1 \
CCP_INTEGRATION_ENABLE_LOGGING=no \
CCP_INTEGRATION_ENABLE_LOGGING=yes \
CCP_INTEGRATION_ENABLE_TESTCONTAINERS_LOGGING=no \
go test -count=1 -v ${__root}/integration/ -run=TestServerCreatePackage
CCP_INTEGRATION_ENABLE_MCPCLIENT_LOGGING=no \
go test -count=1 -v ${__root}/integration/ $runFlag
2 changes: 1 addition & 1 deletion hack/ccp/hack/make/dep_buf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $(call _assert_var,UNAME_ARCH)
$(call _assert_var,CACHE_VERSIONS)
$(call _assert_var,CACHE_BIN)

BUF_VERSION ?= 1.31.0
BUF_VERSION ?= 1.32.2

BUF := $(CACHE_VERSIONS)/buf/$(BUF_VERSION)
$(BUF):
Expand Down
23 changes: 23 additions & 0 deletions hack/ccp/integration/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package integration_test

import "slices"

// automatedConfigTransformations is the preferred list of transformations that
// we apply to the "automated" config in our tests.
var automatedConfigTransformations = []string{
// Send SIP to backlog.
"bb194013-597c-4e4a-8493-b36d190f8717", "7065d256-2f47-4b7d-baec-2c4699626121",
// Virus scanning disabled.
"856d2d65-cd25-49fa-8da9-cabb78292894", "63767e4b-9ce8-4fe2-8724-65cc1f763de0",
"1dad74a2-95df-4825-bbba-dca8b91d2371", "697c0883-798d-4af7-b8b6-101c7f709cd5",
"7e81f94e-6441-4430-a12d-76df09181b66", "77355172-b437-4324-9dcc-e2607ad27cb1",
"390d6507-5029-4dae-bcd4-ce7178c9b560", "63be6081-bee8-4cf5-a453-91893e31940f",
"97a5ddc0-d4e0-43ac-a571-9722405a0a9b", "7f5244fe-590b-4e38-beaf-0cf1ccb9e71b",
}

func configTransformations(processingConfigTransformations ...string) []string {
return slices.Concat(
automatedConfigTransformations,
processingConfigTransformations,
)
}
67 changes: 65 additions & 2 deletions hack/ccp/integration/server_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package integration_test

import (
"errors"
"testing"
"time"

Expand All @@ -10,13 +11,17 @@ import (
"gotest.tools/v3/poll"

adminv1 "github.com/artefactual/archivematica/hack/ccp/internal/api/gen/archivematica/ccp/admin/v1beta1"
"github.com/artefactual/archivematica/hack/ccp/internal/workflow"
)

func TestServerCreatePackage(t *testing.T) {
requireFlag(t)
env := createEnv(t)

transferDir := env.createTransfer()
transferDir := env.createTransfer(
workflow.AutomatedConfig,
configTransformations()...,
)

cpResp, err := env.ccpClient.CreatePackage(env.ctx, &connect.Request[adminv1.CreatePackageRequest]{
Msg: &adminv1.CreatePackageRequest{
Expand Down Expand Up @@ -49,7 +54,65 @@ func TestServerCreatePackage(t *testing.T) {
return poll.Continue("work is still ongoing")
},
poll.WithDelay(time.Second/4),
poll.WithTimeout(time.Second*120),
poll.WithTimeout(time.Minute*2),
)

t.Log("Test completed successfully!")
}

func TestServerCreatePackageWithUserDecision(t *testing.T) {
requireFlag(t)
env := createEnv(t)

transferDir := env.createTransfer(
workflow.AutomatedConfig,
configTransformations(
// Remove "Assign UUIDs to directories" to trigger prompt.
"bd899573-694e-4d33-8c9b-df0af802437d", "",
)...,
)

cpResp, err := env.ccpClient.CreatePackage(env.ctx, &connect.Request[adminv1.CreatePackageRequest]{
Msg: &adminv1.CreatePackageRequest{
Name: "Foobar",
Path: []string{transferDir},
AutoApprove: &wrapperspb.BoolValue{Value: true},
},
})
assert.NilError(t, err)

poll.WaitOn(t,
func(lt poll.LogT) poll.Result {
rpResp, err := env.ccpClient.ReadPackage(env.ctx, &connect.Request[adminv1.ReadPackageRequest]{
Msg: &adminv1.ReadPackageRequest{
Id: cpResp.Msg.Id,
},
})
if err != nil {
return poll.Error(err)
}

pkg := rpResp.Msg.Pkg
if pkg.Status == adminv1.PackageStatus_PACKAGE_STATUS_AWAITING_DECISION {
switch rpResp.Msg.Decision.Name {
case "Assign UUIDs to directories?":
resolve(t, env.ctx, env.ccpClient, pkg, rpResp.Msg.Decision, "Yes")
return poll.Continue("decision resolved")
default:
return poll.Error(errors.New("unexpected decision to be resolved"))
}
}
if pkg.Status == adminv1.PackageStatus_PACKAGE_STATUS_FAILED {
return poll.Error(errors.New("package processing failed"))
}
if pkg.Status == adminv1.PackageStatus_PACKAGE_STATUS_DONE || pkg.Status == adminv1.PackageStatus_PACKAGE_STATUS_COMPLETED_SUCCESSFULLY {
return poll.Success()
}

return poll.Continue("work is still ongoing")
},
poll.WithDelay(time.Second/4),
poll.WithTimeout(time.Minute),
)

t.Log("Test completed successfully!")
Expand Down
Loading

0 comments on commit 88a7895

Please sign in to comment.