[go: up one dir, main page]

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:

  1. Creation of seat assignments worker
  2. Deletion of outdated seat assignments worker
  3. Add create seats workers to group and project after update hooks <- here (needs 1 merged)
  4. 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:

  1. In rails console enable the feature flag
    Feature.enable(:gitlab_com_subscriptions)

Test 01 (Subgroup of a root group becomes a root group)

  1. Create a group (G1)
  2. Click the invite members button.
  3. Invite a few members of your choice and assign them the role of developers
  4. On the main page of G1, create a new subgroup (SG1)
  5. On the SG1 page click the invite members button.
  6. Invite one or more members so that the new members of the subgroup are NOT direct members of the root group
  7. Go to SG1 main page, and on the left hand sidebar locate the settings section and click on general
  8. Scroll down to advance and click on it
  9. Locate the Transfer group section and select no parent group
  10. Click on Transfer group and follow the instructions
  11. SG1 should now be a root group
  12. Go to the rails console, type GitlabSubscriptions::SeatAssignment.by_namespace(Group.find({id of SG1})), and note the output (number of records and ids)
  13. 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))

  1. Follow steps 1-3 in TEST01 to create another root group with some members (G2)
  2. Using G1 created in TEST01, follow steps 4-7 to create a new subgroup (SG2)
  3. 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 the seat assignments
  4. Go to SG2 main page, and on the left hand sidebar locate the settings section and click on general
  5. Scroll down to advance and click on it
  6. Locate the Transfer group section and select SG2. to transfer the subgroup from G1 to G2
  7. Click on Transfer group and follow the instructions
  8. SG2 should now be subgroup of G2
  9. Go to the rails console, type GitlabSubscriptions::SeatAssignment.by_namespace(Group.find({id of G2})), and note the output (number of records and ids)
  10. Note that G2 now have seat assignments corresponding to the members of SG2

TEST 03 (Top group to subgroup)

  1. Create a new group (G3)
  2. 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)
  3. Go to G3 main page, and on the left hand sidebar locate the settings section and click on general
  4. Scroll down to advance and click on it
  5. Locate the Transfer group section and select G1. to transfer the root group to G1
  6. Click on Transfer group and follow the instructions
  7. G3 should now be subgroup of G1
  8. 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)

  1. In G1, create a new subgroup (SG3)
  2. Invite a few members to SG3 (as developers). These new members must not be in the hierarchy of G1 already
  3. 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)
  4. Go to SG3 main page, and on the left hand sidebar locate the settings section and click on general
  5. Scroll down to advance and click on it
  6. Locate the Transfer group section and select SG1. to transfer SG3 to SG1
  7. Click on Transfer group and follow the instructions
  8. SG3 should now be a subgroup of SG1
  9. 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)

  1. Create a new project (P1) and assign a user namespace (UN) in the project URL section
  2. On the left hand size menu, locate manage and select members
  3. Click on the invite members button
  4. invite a new member(s) who is not a member of G1 (the destination group)
  5. On P1 main page, locate the settings menu, expand it, and click on general
  6. Scroll down to advance and click on it
  7. Locate the Transfer project section and select G1. to transfer P1 to G1
  8. Click on Transfer project and follow the instructions
  9. P1 should now be a project of G1
  10. 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))

  1. Create a new group, or use the same as in TEST05 (G1)
  2. Under G1, create a new project, or use the same as in TEST 05 (P1)
  3. Go to main page of P1
  4. On the left hand size menu, locate the manage menu and select members
  5. On the members page, click on the invite members button
  6. Invite a new member(s) who is not a member of your user namespace (UN, the destination user namespace)
  7. On P1 main page, locate the settings menu, expand it, and click on general
  8. Scroll down to advance and click on it
  9. Locate the Transfer project section and select UN. to transfer P1 to UN
  10. Click on Transfer project and follow the instructions
  11. P1 should now be a project of UN
  12. 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) )

  1. Create a new group, or use the same as in TEST06 (G1)
  2. Create a new destination group (G2)
  3. Under G1, create a new project (P1)
  4. Go to main page of P1
  5. On the left hand size menu, locate the manage menu and select members
  6. On the members page, click on the invite members button
  7. Invite a new member(s) who is not a member of G2 (the destination group)
  8. On P1 main page, locate the settings menu, expand it, and click on general
  9. Scroll down to advance and click on it
  10. Locate the Transfer project section and select G2. to transfer P1 to G2
  11. Click on Transfer project and follow the instructions
  12. P1 should now be a project of G2
  13. 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) )

  1. Create a new group, or use the same as in TEST07 (G1)
  2. Create a new group (G2)
  3. Create a new destination subgroup (SG1) within G2
  4. Under G1, create a new project (P1)
  5. Go to main page of P1
  6. On the left hand size menu, locate the manage menu and select members
  7. On the members page, click on the invite members button
  8. Invite a new member(s) that is not a member of G2 (the destination root group)
  9. On P1 main page, locate the settings menu, expand it, and click on general
  10. Scroll down to advance and click on it
  11. Locate the Transfer project section and select SG1. to transfer P1 to SG1
  12. Click on Transfer project and follow the instructions
  13. P1 should now be a project of SG2
  14. 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) )

  1. Create a new group, or use the same as in TEST07 (G1)
  2. Create two new subgroups, SG1, and SG2. We will transfer a project from SG1 to SG2
  3. Under SG1, create a new project (P1)
  4. Go to main page of P1
  5. On the left hand size menu, locate the manage menu and select members
  6. On the members page, click on the invite members button
  7. Invite a new member(s) that is not a member of G1 (root group)
  8. 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)
  9. On P1 main page, locate the settings menu, expand it, and click on general
  10. Scroll down to advance and click on it
  11. Locate the Transfer project section and select SG2. to transfer P1 from SG1 to SG2
  12. Click on Transfer project and follow the instructions
  13. P1 should now be a project of SG2
  14. 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.

Edited by Jorge Cook

Merge request reports

Loading