Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
burigolucas committed Jan 26, 2025
1 parent ff2f380 commit 9a8c0b4
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 55 deletions.
52 changes: 27 additions & 25 deletions hack/update-schemas.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
#!/bin/sh
#!/usr/bin/env bash

# Copyright 2019 The Tekton Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

CRD_PATH=$(dirname "${0}")/../config/300-crds
API_PATH=$(dirname "${0}")/../pkg/apis
OLDGOFLAGS="${GOFLAGS:-}"
GOFLAGS=""

CRD_PATH=$(dirname "${0}")/../config/300-crds
API_PATH=$(dirname "${0}")/../pkg/apis

TEMP_DIR_LOGS=$(mktemp -d)

for FILENAME in `find $CRD_PATH -type f`;
Expand All @@ -21,21 +40,24 @@ do
else
API_SUBDIR=${GROUP%".tekton.dev"}
fi
#echo "GROUP: $GROUP"
#echo "API_SUBDIR: $API_SUBDIR"

TEMP_DIR=$(mktemp -d)
cp -p $FILENAME $TEMP_DIR/.
LOG_FILE=$TEMP_DIR_LOGS/log-schema-generation-$(basename $FILENAME)

counter=0 limit=10
while [ "$counter" -lt "$limit" ]; do
# FIXME:(burigolucas): add schema for fields with generic type once supported by controller-tools
# FIXME:(burigolucas): add schema for recursive fields once supported by controller-tools
# FIXME:(burigolucas): add reference for dependent external/internal schemas once supported in CRD specification
# FIXME:(burigolucas): controller-gen return status 1 with message "Error: not all generators ran successfully"
set +e
go run sigs.k8s.io/controller-tools/cmd/controller-gen@v0.17.1 \
schemapatch:manifests=$TEMP_DIR,generateEmbeddedObjectMeta=false \
output:dir=$CRD_PATH \
paths=$API_PATH/$API_SUBDIR/... > $LOG_FILE 2>&1
rc=$?
set -e
if [ $rc -eq 0 ]; then
break
fi
Expand All @@ -50,26 +72,6 @@ do
fi
done

# # NOTE: the controller-gen removes the field 'x-kubernetes-preserve-unknown-fields: true'
# # The command below restores the field.
# cat >$TEMP_DIR/tmp-fix <<EOF
# # One can use x-kubernetes-preserve-unknown-fields: true
# # at the root of the schema (and inside any properties, additionalProperties)
# # to get the traditional CRD behaviour that nothing is pruned, despite
# # setting spec.preserveUnknownProperties: false.
# #
# # See https://kubernetes.io/blog/2019/06/20/crd-structural-schema/
# # See issue: https://github.com/knative/serving/issues/912
# x-kubernetes-preserve-unknown-fields: true
# EOF
# FIELD_IDENTATION="$(grep 'openAPIV3Schema:' $FILENAME | head -1)"
# FIELD_IDENTATION="${FIELD_IDENTATION%openAPIV3Schema:} "
# sed -i "s/^/$FIELD_IDENTATION/" $TEMP_DIR/tmp-fix

# if ! grep -qF "$(head -n1 $TEMP_DIR/tmp-fix)" $FILENAME; then
# sed -i "/ openAPIV3Schema:/r $TEMP_DIR/tmp-fix" $FILENAME
# fi

rm -rf $TEMP_DIR
done

Expand Down
60 changes: 30 additions & 30 deletions pkg/reconciler/taskrun/taskrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1716,28 +1716,28 @@ status:
podName: "test-taskrun-results-type-mismatched-pod"
provenance:
featureFlags:
RunningInEnvWithInjectedSidecars: true
EnforceNonfalsifiability: "none"
EnableAPIFields: "alpha"
AwaitSidecarReadiness: true
VerificationNoMatchPolicy: "ignore"
EnableProvenanceInStatus: true
ResultExtractionMethod: "termination-message"
MaxResultSize: 4096
Coschedule: "workspaces"
DisableInlineSpec: ""
runningInEnvWithInjectedSidecars: true
enforceNonfalsifiability: "none"
enableAPIFields: "alpha"
awaitSidecarReadiness: true
verificationNoMatchPolicy: "ignore"
enableProvenanceInStatus: true
resultExtractionMethod: "termination-message"
maxResultSize: 4096
coschedule: "workspaces"
disableInlineSpec: ""
provenance:
featureFlags:
RunningInEnvWithInjectedSidecars: true
EnableAPIFields: "alpha"
EnforceNonfalsifiability: "none"
AwaitSidecarReadiness: true
VerificationNoMatchPolicy: "ignore"
EnableProvenanceInStatus: true
ResultExtractionMethod: "termination-message"
MaxResultSize: 4096
Coschedule: "workspaces"
DisableInlineSpec: ""
runningInEnvWithInjectedSidecars: true
enableAPIFields: "alpha"
enforceNonfalsifiability: "none"
awaitSidecarReadiness: true
verificationNoMatchPolicy: "ignore"
enableProvenanceInStatus: true
resultExtractionMethod: "termination-message"
maxResultSize: 4096
coschedule: "workspaces"
disableInlineSpec: ""
`, pipelineErrors.UserErrorLabel, pipelineErrors.UserErrorLabel))
reconciliatonError = errors.New("1 error occurred:\n\t* Provided results don't match declared results; may be invalid JSON or missing result declaration: \"aResult\": task result is expected to be \"array\" type but was initialized to a different type \"string\"")
toBeRetriedTaskRun = parse.MustParseV1TaskRun(t, `
Expand Down Expand Up @@ -1782,16 +1782,16 @@ status:
type: Succeeded
provenance:
featureFlags:
RunningInEnvWithInjectedSidecars: true
EnableAPIFields: "beta"
EnforceNonfalsifiability: "none"
AwaitSidecarReadiness: true
VerificationNoMatchPolicy: "ignore"
EnableProvenanceInStatus: true
ResultExtractionMethod: "termination-message"
MaxResultSize: 4096
Coschedule: "workspaces"
DisableInlineSpec: ""
runningInEnvWithInjectedSidecars: true
enableAPIFields: "beta"
enforceNonfalsifiability: "none"
awaitSidecarReadiness: true
verificationNoMatchPolicy: "ignore"
enableProvenanceInStatus: true
resultExtractionMethod: "termination-message"
maxResultSize: 4096
coschedule: "workspaces"
disableInlineSpec: ""
`)
toBeRetriedWithResultsTaskRun = parse.MustParseV1TaskRun(t, `
metadata:
Expand Down

0 comments on commit 9a8c0b4

Please sign in to comment.