@@ -143,6 +143,23 @@ func (n *GCSFuseCSITestDriver) PrepareTest(ctx context.Context, f *e2eframework.
143143 }
144144 testK8sSA .Create (ctx )
145145
146+ // Grant the required consumer permission on the test project to the active identity.
147+ // This ensures that tests using the `--billing-project` flag (like requester_pays_bucket)
148+ // can successfully authenticate and pass the consumer quota check (403 Forbidden).
149+ member := fmt .Sprintf ("serviceAccount:%v.svc.id.goog[%v/%v]" , n .meta .GetProjectID (), f .Namespace .Name , K8sServiceAccountName )
150+ if ! n .skipGcpSaTest {
151+ member = fmt .Sprintf ("serviceAccount:%v" , testGcpSA .GetEmail ())
152+ }
153+ billingBinding := utils .NewTestGCPProjectIAMPolicyBinding (n .meta .GetProjectID (), member , "roles/serviceusage.serviceUsageConsumer" , "" )
154+ billingBinding .Create (ctx )
155+
156+ // This is required to run the cloud profiler tests. See requirements here:
157+ // https://cloud.google.com/profiler/docs/profiling-go#permissions
158+ profilerAgentBinding := utils .NewTestGCPProjectIAMPolicyBinding (n .meta .GetProjectID (), member , "roles/cloudprofiler.agent" , "" )
159+ profilerAgentBinding .Create (ctx )
160+ profilerUserBinding := utils .NewTestGCPProjectIAMPolicyBinding (n .meta .GetProjectID (), member , "roles/cloudprofiler.user" , "" )
161+ profilerUserBinding .Create (ctx )
162+
146163 config := & storageframework.PerTestConfig {
147164 Driver : n ,
148165 Framework : f ,
@@ -161,6 +178,9 @@ func (n *GCSFuseCSITestDriver) PrepareTest(ctx context.Context, f *e2eframework.
161178 n .volumeStore = []* gcsVolume {}
162179
163180 testK8sSA .Cleanup (ctx )
181+ profilerUserBinding .Cleanup (ctx )
182+ profilerAgentBinding .Cleanup (ctx )
183+ billingBinding .Cleanup (ctx )
164184 if ! n .skipGcpSaTest {
165185 testGcpSA .Cleanup (ctx )
166186 }
0 commit comments