You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: globalroles_v2_test.go
    path of file: ./repos/rancher/tests/v2/validation/rbac/globalrolesv2
    
    the code of the file until where you have to start completion: //go:build (validation || infra.any || cluster.any || stress) && !sanity && !extended

package globalrolesv2

import (
	"testing"

	log "github.com/sirupsen/logrus"
	"github.com/stretchr/testify/require"
	"github.com/stretchr/testify/suite"

	"github.com/rancher/shepherd/clients/rancher"
	management "github.com/rancher/shepherd/clients/rancher/generated/management/v3"
	namegen "github.com/rancher/shepherd/pkg/namegenerator"
	"github.com/rancher/shepherd/pkg/session"

	v3 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3"

	"github.com/rancher/shepherd/extensions/clusters"
	"github.com/rancher/shepherd/extensions/defaults"
	"github.com/rancher/shepherd/extensions/kubeapi/rbac"
	"github.com/rancher/shepherd/extensions/provisioning"
	"github.com/rancher/shepherd/extensions/users"

	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	kwait "k8s.io/apimachinery/pkg/util/wait"
)

type GlobalRolesV2TestSuite struct {
	suite.Suite
	client  *rancher.Client
	session *session.Session
}

func (gr *GlobalRolesV2TestSuite) TearDownSuite() {
	gr.session.Cleanup()
}

func (gr *GlobalRolesV2TestSuite) SetupSuite() {
	testSession := session.NewSession()
	gr.session = testSession

	client, err := rancher.NewClient("", testSession)
	require.NoError(gr.T(), err)

	gr.client = client
}

func (gr *GlobalRolesV2TestSuite) validateRBACResources(createdUser *management.User, inheritedRoles []string) (string, int) {
	log.Info("Verify that the global role binding is created for the user.")
	grbOwner, err := getGlobalRoleBindingForUser(gr.client, createdUser.ID)
	require.NoError(gr.T(), err)
	require.NotEmpty(gr.T(), grbOwner, "Global Role Binding not found for the user")
	grbName := grbOwner

	log.Info("Verify that the cluster role template bindings are created for the downstream clusters.")
	clusterNames, err := clusters.ListDownstreamClusters(gr.client)
	require.NoError(gr.T(), err)
	clusterCount := len(clusterNames)
	expectedCrtbCount := clusterCount * len(inheritedRoles)
	crtbs, err := listClusterRoleTemplateBindingsForInheritedClusterRoles(gr.client, grbOwner, expectedCrtbCount)
	require.NoError(gr.T(), err)
	actualCrtbCount := len(crtbs.Items)
	require.Equal(gr.T(), expectedCrtbCount, actualCrtbCount, "Unexpected number of ClusterRoleTemplateBindings: Expected %d, Actual %d", expectedCrtbCount, actualCrtbCount)

	log.Info("Verify that the cluster r
    
func (gr *GlobalRolesV2TestSuite) TestUserWithInheritedClusterRolesImpactFromClusterDeletion() {
	subSession := gr.session.NewSession()
	defer subSession.Cleanup()

	log.Info("Create a RKE2 downstream cluster.")
	_, rke2SteveObject, testClusterConfig, err := createDownstreamCluster(gr.client, "RKE2")
	require.NoError(gr.T(), err)
	provisioning.VerifyCluster(gr.T(), gr.client, testClusterConfig, rke2SteveObject)

	log.Info("Create a global role with inheritedClusterRoles.")
	inheritedClusterRoles := []string{roleOwner}
	createdGlobalRole, err := createGlobalRoleWithInheritedClusterRoles(gr.client, inheritedClusterRoles)
	require.NoError(gr.T(), err)

	log.Info("Create a user with global role standard user and custom global role.")
	createdUser, err := users.CreateUserWithRole(gr.client, users.UserConfig(), standardUser, createdGlobalRole.Name)
	require.NoError(gr.T(), err)

	_, expectedClusterCount := gr.validateRBACResources(createdUser, inheritedClusterRoles)

	log.Info("Verify that the user can list all the downstream clusters.")
	userClient, err := gr.client.AsUser(createdUser)
	require.NoError(gr.T(), err)
	clusterNames, err := clusters.ListDownstreamClusters(userClient)
	require.NoError(gr.T(), err)
	actualClusterCount := len(clusterNames)
	require.Equal(gr.T(), expectedClusterCount, actualClusterCount, "Unexpected number of Clusters: Expected %d, Actual %d", expectedClusterCount, actualClusterCount)

	log.Info("Delete the RKE2 downstream cluster.")
	clusters.DeleteK3SRKE2Cluster(userClient, rke2SteveObject.ID)

	log.Info("Verify that the global role is not deleted.")
	listOpt := metav1.ListOptions{
		FieldSelector: "metadata.name=" + createdGlobalRole.Name,
	}
	grList, err := rbac.ListGlobalRoles(gr.client, listOpt)
	require.NoError(gr.T(), err)
	require.NotEmpty(gr.T(), grList, "Global Role does not exist.")

	log.Info("Verify that the global role binding is not deleted for the user.")
	grbOwner, err := getGlobalRoleBindingForUser(gr.client, createdUser.ID)
	require.NoError(gr.T(), err)
	require.NotEmpty(gr.T(), grbOwner, "Global Role Binding does not exist for the user.")

	log.Info("Verify that the cluster role template bindings are deleted for the downstream cluster.")
	expectedCrtbCount := actualClusterCount - 1
	crtbs, err := listClusterRoleTemplateBindingsForInheritedClusterRoles(gr.client, grbOwner, expectedCrtbCount)
	require.NoError(gr.T(), err)
	actualCrtbCount := len(crtbs.Items)
	require.Equal(gr.T(), expectedCrtbCount, actualCrtbCount, "Unexpected number of ClusterRoleTemplateBindings: Expected %d, Actual %d", expectedCrtbCount, actualCrtbCount)

	log.Info("Verify that the cluster role bindings are deleted for the downstream cluster.")
	expectedCrbCount := expectedCrtbCount
	crbs, err := getCRBsForCRTBs(gr.client, crtbs)
	require.NoError(gr.T(), err)
	actualCrbCount := len(crbs.Items)
	require.Equal(gr.T(), expectedCrbCount, actualCrbCount, "Unexpected number of ClusterRoleBindings: Expected %d, Actual %d", expectedCrbCount, actualCrbCount)

	log.Info("Verify that the role bindings are deleted for the downstream cluster.")
	expectedRbCount := expectedCrtbCount
	rbs, err := getRBsForCRTBs(gr.client, crtbs)
	require.NoError(gr.T(), err)
	actualRbCount := len(rbs.Items)
	require.Equal(gr.T(), expectedRbCount, actualRbCount, "Unexpected number of RoleBindings: Expected %d, Actual %d", expectedRbCount, actualRbCount)
}