Add create seats workers to transfer services
What does this MR do and why?
This Merge Request connects the workers responsible for creating seat assignments to both the Group and Project transfer services.
Context This MR is part of a larger effort to correctly handle seat assignment creation and deletion during group or project transfers. Specifically, it is 1 of 4 MRs addressing:
-
Creation of seat assignments worker
✅ - Deletion of outdated seat assignments worker
- Add create seats workers to group and project after update hooks <- here (needs 1 merged)
- Add remove outdated seats worker to group and project after update hooks (needs 2 merged).
References
It's a part of:
How to set up and validate locally
Prerequisite:
- In rails console enable the feature flag
Feature.enable(:gitlab_com_subscriptions)
Test 01 (Subgroup of a root group becomes a root group)
- Create a group (G1)
- Click the
invite membersbutton. - Invite a few members of your choice and assign them the role of developers
- On the main page of G1, create a new subgroup (SG1)
- On the SG1 page click the
invite membersbutton. - Invite one or more members so that the new members of the subgroup are NOT direct members of the root group
- Go to SG1 main page, and on the left hand sidebar locate the settings section and click on general
- Scroll down to advance and click on it
- Locate the Transfer group section and select no parent group
- Click on Transfer group and follow the instructions
- SG1 should now be a root group
- Go to the rails console, type
GitlabSubscriptions::SeatAssignment.by_namespace(Group.find({id of SG1})), and note the output (number of records and ids) - Note that the seat assignments corresponds to the members of SG1 that were transferred from G1
Test 02 (Subgroup (SG2) of a root group to subgroup to another root group (G2))
- Follow steps 1-3 in TEST01 to create another root group with some members (G2)
- Using G1 created in TEST01, follow steps 4-7 to create a new subgroup (SG2)
- Using the rails console, type
GitlabSubscriptions::SeatAssignment.by_namespace(Group.find({id of G2}))to obtain the total of seats for the root group (G2). Take down the number and ids of theseat assignments - Go to SG2 main page, and on the left hand sidebar locate the settings section and click on general
- Scroll down to advance and click on it
- Locate the Transfer group section and select SG2. to transfer the subgroup from G1 to G2
- Click on Transfer group and follow the instructions
- SG2 should now be subgroup of G2
- Go to the rails console, type
GitlabSubscriptions::SeatAssignment.by_namespace(Group.find({id of G2})), and note the output (number of records and ids) - Note that G2 now have seat assignments corresponding to the members of SG2
TEST 03 (Top group to subgroup)
- Create a new group (G3)
- Invite a few members and assign them the role of developers (if you use G1 for the transfer, add members that are not in G1)
- Go to G3 main page, and on the left hand sidebar locate the settings section and click on general
- Scroll down to advance and click on it
- Locate the Transfer group section and select G1. to transfer the root group to G1
- Click on Transfer group and follow the instructions
- G3 should now be subgroup of G1
- In the rails console type
GitlabSubscriptions::SeatAssignment.by_namespace(Namespace.find({id of G1}))and note that the members of G3 now have seat assignments in G1
TEST 04 (subgroup to subgroup in the same hierarchy)
- In G1, create a new subgroup (SG3)
- Invite a few members to SG3 (as developers). These new members must not be in the hierarchy of G1 already
- In the rails console type
GitlabSubscriptions::SeatAssignment.by_namespace(Group.find({id of G1}))and note that new members of SG3 occupy a seat assignment (not the scope of this MR) - Go to SG3 main page, and on the left hand sidebar locate the settings section and click on general
- Scroll down to advance and click on it
- Locate the Transfer group section and select SG1. to transfer SG3 to SG1
- Click on Transfer group and follow the instructions
- SG3 should now be a subgroup of SG1
- In the rails console type
GitlabSubscriptions::SeatAssignment.by_namespace(Group.find({id of G1})). Notice that no changes occurred with the transfer
TEST 05 (Project transfer user namespace to a group)
- Create a new project (P1) and assign a user namespace (UN) in the project URL section
- On the left hand size menu, locate manage and select members
- Click on the invite members button
- invite a new member(s) who is not a member of G1 (the destination group)
- On P1 main page, locate the settings menu, expand it, and click on general
- Scroll down to advance and click on it
- Locate the Transfer project section and select G1. to transfer P1 to G1
- Click on Transfer project and follow the instructions
- P1 should now be a project of G1
- In the rails console type
GitlabSubscriptions::SeatAssignment.by_namespace(Namespace.find({id of G1})). Notice the appropriate members of P1 now have a seat assignment in G1
TEST 06 (Project transfer from a group to a user namespace (UN))
- Create a new group, or use the same as in TEST05 (G1)
- Under G1, create a new project, or use the same as in TEST 05 (P1)
- Go to main page of P1
- On the left hand size menu, locate the manage menu and select members
- On the members page, click on the invite members button
- Invite a new member(s) who is not a member of your user namespace (UN, the destination user namespace)
- On P1 main page, locate the settings menu, expand it, and click on general
- Scroll down to advance and click on it
- Locate the Transfer project section and select UN. to transfer P1 to UN
- Click on Transfer project and follow the instructions
- P1 should now be a project of UN
- In the rails console type
GitlabSubscriptions::SeatAssignment.by_namespace(Namespace.find({id of UN})). Notice that, upon transfer, the seat assignments for members of P1 were were created in UN
TEST 07 (Project transfer from a top group (G1) to another top group (G2) )
- Create a new group, or use the same as in TEST06 (G1)
- Create a new destination group (G2)
- Under G1, create a new project (P1)
- Go to main page of P1
- On the left hand size menu, locate the manage menu and select members
- On the members page, click on the invite members button
- Invite a new member(s) who is not a member of G2 (the destination group)
- On P1 main page, locate the settings menu, expand it, and click on general
- Scroll down to advance and click on it
- Locate the Transfer project section and select G2. to transfer P1 to G2
- Click on Transfer project and follow the instructions
- P1 should now be a project of G2
- In the rails console type
GitlabSubscriptions::SeatAssignment.by_namespace(Namespace.find({id of G2})). Notice that, upon transfer, the seat assignments for members of P1 were were created in G2
TEST 08 (Project transfer from a group (G1) to subgroup in another hierarchy (G2) )
- Create a new group, or use the same as in TEST07 (G1)
- Create a new group (G2)
- Create a new destination subgroup (SG1) within G2
- Under G1, create a new project (P1)
- Go to main page of P1
- On the left hand size menu, locate the manage menu and select members
- On the members page, click on the invite members button
- Invite a new member(s) that is not a member of G2 (the destination root group)
- On P1 main page, locate the settings menu, expand it, and click on general
- Scroll down to advance and click on it
- Locate the Transfer project section and select SG1. to transfer P1 to SG1
- Click on Transfer project and follow the instructions
- P1 should now be a project of SG2
- Since G2 is the root ancestor of SG1, in the rails console type
GitlabSubscriptions::SeatAssignment.by_namespace(Namespace.find({id of G2})). Notice that, upon transfer, the seat assignments for members of P1 were were created in G2
TEST 09 (Project transfer from a subgroup (SG1) to subgroup in the same hierarchy (SG2) )
- Create a new group, or use the same as in TEST07 (G1)
- Create two new subgroups, SG1, and SG2. We will transfer a project from SG1 to SG2
- Under SG1, create a new project (P1)
- Go to main page of P1
- On the left hand size menu, locate the manage menu and select members
- On the members page, click on the invite members button
- Invite a new member(s) that is not a member of G1 (root group)
- In the rails console type
GitlabSubscriptions::SeatAssignment.by_namespace(Namespace.find({id of G1})). Take note of the seat assignments; these should correspond to the members of G1 and its descendants (functionality outside the scope of this MR) - On P1 main page, locate the settings menu, expand it, and click on general
- Scroll down to advance and click on it
- Locate the Transfer project section and select SG2. to transfer P1 from SG1 to SG2
- Click on Transfer project and follow the instructions
- P1 should now be a project of SG2
- In the rails console type
GitlabSubscriptions::SeatAssignment.by_namespace(Namespace.find({id of G1})). Notice that the seat assignments of step 9 are the same after the transfer (no changes).
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.