Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: add dbauthz to unhanger tests#14394

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
spikecurtis merged 1 commit intomainfromspike/14393-unhanger-dbauthz-tests
Aug 22, 2024

Conversation

spikecurtis
Copy link
Contributor

@spikecurtisspikecurtis commentedAug 22, 2024
edited
Loading

relates to#14393

customer is having issues with the unhanger failing to kill a hung build. I noticed that our unhanger unit tests don't actually use the dbauthz. This PR adds authz to the unhanger tests.

Many tests failed on template import and template dry-run jobs, because the test code inserts build jobs without a corresponding template version, and our authz layer uses permission on the template version as a proxy for permission on the job.

I'mpretty sure that our actual API calls ensure that there is always a template version for the the job, but for some future work, it would be nice to have the database enforce this.

@spikecurtisGraphite App
Copy link
ContributorAuthor

This stack of pull requests is managed by Graphite.Learn more about stacking.

Join@spikecurtis and the rest of your teammates onGraphiteGraphite

@spikecurtisspikecurtis marked this pull request as ready for reviewAugust 22, 2024 10:41
@spikecurtisspikecurtisforce-pushed thespike/14393-unhanger-dbauthz-tests branch from196399c to3a2c955CompareAugust 22, 2024 11:09
Copy link
Member

@EmyrkEmyrk left a comment

Choose a reason for hiding this comment

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

Minor nits, not blocking

@@ -37,7 +43,7 @@ func TestDetectorNoJobs(t *testing.T) {
statsCh = make(chan unhanger.Stats)
)

detector := unhanger.New(ctx,db, pubsub, log, tickCh).WithStatsChannel(statsCh)
detector := unhanger.New(ctx,wrapDBAuthz(db, log), pubsub, log, tickCh).WithStatsChannel(statsCh)
Copy link
Member

Choose a reason for hiding this comment

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

Feels odd to have a rawdb laying around outside this function call scope. I'd probably do this to not have adb laying around. Up to you 🤷‍♂️

var (ctx=testutil.Context(t,testutil.WaitLong)rdb,pubsub=dbtestutil.NewDB(t)db=wrapDBAuthz(rdb,slogtest.Make(t,nil))log=slogtest.Make(t,nil)tickCh=make(chan time.Time)statsCh=make(chan unhanger.Stats))

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

The annoying thing about that is that I'd have to set up a dbauthz principal for the calls that write the job, user, template, etc. Authz for those operations is irrelevant to this test.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yea it is annoying.dbgen gets around that with agenCtx:

vargenCtx=dbauthz.As(context.Background(), rbac.Subject{

If you use dbgen to handle all the initial state, you can ignore that requirement.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Almost, but not quite all state isdbgen. It make sense to me to keep this way, since it really is just the unhanger under test here, so only it need the dbauthz.

@spikecurtisspikecurtisforce-pushed thespike/14393-unhanger-dbauthz-tests branch from3a2c955 tob4ba388CompareAugust 22, 2024 18:02
@spikecurtisspikecurtisforce-pushed thespike/14393-unhanger-dbauthz-tests branch fromb4ba388 to4ce4adaCompareAugust 22, 2024 18:12
@spikecurtisspikecurtis merged commitd52bc91 intomainAug 22, 2024
28 checks passed
@spikecurtisGraphite App
Copy link
ContributorAuthor

Merge activity

@spikecurtisspikecurtis deleted the spike/14393-unhanger-dbauthz-tests branchAugust 22, 2024 18:23
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsAug 22, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@EmyrkEmyrkEmyrk approved these changes

Assignees

@spikecurtisspikecurtis

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@spikecurtis@Emyrk

[8]ページ先頭

©2009-2025 Movatter.jp