-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add Staged Artifact validations for RunnerV2 #37974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
1abb4b4
Add checks for dependency corruption
tarun-google 106c037
Add experiment to disable checks
tarun-google 082e3db
Add flag for legacy function too
tarun-google 3ad52e7
fix lint
tarun-google d0b0fbb
fix python flag
tarun-google 6581d90
fix test
tarun-google 643fe5a
fix formatter
tarun-google 1b114e2
update flag from server
tarun-google b6d6133
fix tests
tarun-google 87d43c0
Merge branch 'apache:master' into add_expected_sha_checks
tarun-google 00d67bf
Add log for feature rollout validation
tarun-google 84252ab
Merge branch 'add_expected_sha_checks' of github.com:tarun-google/bea…
tarun-google cf1c46b
Add PipelineOptions util
tarun-google 22c874c
refactor test
tarun-google 9a5da8a
Fix suggestions
tarun-google 5d278ce
add log
tarun-google a72d19e
remove log
tarun-google 5e94599
Merge branch 'apache:master' into add_expected_sha_checks
tarun-google File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,48 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one or more | ||
| // contributor license agreements. See the NOTICE file distributed with | ||
| // this work for additional information regarding copyright ownership. | ||
| // The ASF licenses this file to You 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. | ||
|
|
||
| package artifact | ||
|
|
||
| import ( | ||
| structpb "google.golang.org/protobuf/types/known/structpb" | ||
| ) | ||
|
|
||
| // GetExperiments extracts a list of experiments from the pipeline options. | ||
| func GetExperiments(options *structpb.Struct) []string { | ||
| if options == nil { | ||
| return nil | ||
| } | ||
|
|
||
| var exps []string | ||
| // Try legacy style | ||
| for _, v := range options.GetFields()["options"].GetStructValue().GetFields()["experiments"].GetListValue().GetValues() { | ||
| exps = append(exps, v.GetStringValue()) | ||
| } | ||
| // Try URN style | ||
| for _, v := range options.GetFields()["beam:option:experiments:v1"].GetListValue().GetValues() { | ||
| exps = append(exps, v.GetStringValue()) | ||
| } | ||
| return exps | ||
| } | ||
|
|
||
| // HasExperiment checks if a specific experiment is enabled in the pipeline options. | ||
| func HasExperiment(options *structpb.Struct, experiment string) bool { | ||
| for _, exp := range GetExperiments(options) { | ||
| if exp == experiment { | ||
| return true | ||
| } | ||
| } | ||
| return false | ||
|
tarun-google marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or 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,78 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one or more | ||
| // contributor license agreements. See the NOTICE file distributed with | ||
| // this work for additional information regarding copyright ownership. | ||
| // The ASF licenses this file to You 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. | ||
|
|
||
| package artifact | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| structpb "google.golang.org/protobuf/types/known/structpb" | ||
| ) | ||
|
|
||
| func TestGetExperiments_Nil(t *testing.T) { | ||
| if got := GetExperiments(nil); got != nil { | ||
| t.Errorf("GetExperiments(nil) = %v, want nil", got) | ||
| } | ||
| } | ||
|
|
||
| func TestGetExperiments_Legacy(t *testing.T) { | ||
| options, _ := structpb.NewStruct(map[string]interface{}{ | ||
| "options": map[string]interface{}{ | ||
| "experiments": []interface{}{"exp1", "exp2"}, | ||
| }, | ||
| }) | ||
| exps := GetExperiments(options) | ||
| if len(exps) != 2 || exps[0] != "exp1" || exps[1] != "exp2" { | ||
| t.Errorf("GetExperiments() = %v, want [exp1 exp2]", exps) | ||
| } | ||
| } | ||
|
|
||
| func TestGetExperiments_URN(t *testing.T) { | ||
| urnOptions, _ := structpb.NewStruct(map[string]interface{}{ | ||
| "beam:option:experiments:v1": []interface{}{"expA", "expB"}, | ||
| }) | ||
| expsURN := GetExperiments(urnOptions) | ||
| if len(expsURN) != 2 || expsURN[0] != "expA" || expsURN[1] != "expB" { | ||
| t.Errorf("GetExperiments() = %v, want [expA expB]", expsURN) | ||
| } | ||
| } | ||
|
|
||
| func TestHasExperiment(t *testing.T) { | ||
| options, _ := structpb.NewStruct(map[string]interface{}{ | ||
| "options": map[string]interface{}{ | ||
| "experiments": []interface{}{"exp1", "exp2"}, | ||
| }, | ||
| }) | ||
|
|
||
| if !HasExperiment(options, "exp1") { | ||
| t.Errorf("HasExperiment(exp1) = false, want true") | ||
| } | ||
| if HasExperiment(options, "exp3") { | ||
| t.Errorf("HasExperiment(exp3) = true, want false") | ||
| } | ||
| } | ||
|
|
||
| func TestGetExperiments_Combined(t *testing.T) { | ||
| options, _ := structpb.NewStruct(map[string]interface{}{ | ||
| "options": map[string]interface{}{ | ||
| "experiments": []interface{}{"exp1", "exp2"}, | ||
| }, | ||
| "beam:option:experiments:v1": []interface{}{"expA", "expB"}, | ||
| }) | ||
| exps := GetExperiments(options) | ||
| if len(exps) != 4 || exps[0] != "exp1" || exps[1] != "exp2" || exps[2] != "expA" || exps[3] != "expB" { | ||
| t.Errorf("GetExperiments() = %v, want [exp1 exp2 expA expB]", exps) | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.