TestGitOpsRolloutMultiTarget tests a more complex GitOps scenario: - A release with 3 migration files targeting 2 databases (test and prod) - Verifies that all files are applied to all target databases - Ensures schema consistency across environments
(t *testing.T)
| 925 | // - Verifies that all files are applied to all target databases |
| 926 | // - Ensures schema consistency across environments |
| 927 | func TestGitOpsRolloutMultiTarget(t *testing.T) { |
| 928 | t.Parallel() |
| 929 | a := require.New(t) |
| 930 | ctx := context.Background() |
| 931 | ctl := &controller{} |
| 932 | ctx, err := ctl.StartServerWithExternalPg(ctx) |
| 933 | a.NoError(err) |
| 934 | defer ctl.Close(ctx) |
| 935 | |
| 936 | // Create a project for GitOps testing. |
| 937 | projectID := generateRandomString("gitops-multi") |
| 938 | projectResp, err := ctl.projectServiceClient.CreateProject(ctx, connect.NewRequest(&v1pb.CreateProjectRequest{ |
| 939 | Project: &v1pb.Project{ |
| 940 | Name: fmt.Sprintf("projects/%s", projectID), |
| 941 | Title: projectID, |
| 942 | AllowSelfApproval: true, |
| 943 | }, |
| 944 | ProjectId: projectID, |
| 945 | })) |
| 946 | a.NoError(err) |
| 947 | project := projectResp.Msg |
| 948 | |
| 949 | // Provision test and prod instances. |
| 950 | instanceRootDir := t.TempDir() |
| 951 | |
| 952 | testInstanceDir, err := ctl.provisionSQLiteInstance(instanceRootDir, "gitops-multi-test") |
| 953 | a.NoError(err) |
| 954 | |
| 955 | prodInstanceDir, err := ctl.provisionSQLiteInstance(instanceRootDir, "gitops-multi-prod") |
| 956 | a.NoError(err) |
| 957 | |
| 958 | // Add the provisioned instances. |
| 959 | testInstanceResp, err := ctl.instanceServiceClient.CreateInstance(ctx, connect.NewRequest(&v1pb.CreateInstanceRequest{ |
| 960 | InstanceId: generateRandomString("instance"), |
| 961 | Instance: &v1pb.Instance{ |
| 962 | Title: "gitops-multi-test", |
| 963 | Engine: v1pb.Engine_SQLITE, |
| 964 | Environment: new("environments/test"), |
| 965 | Activation: true, |
| 966 | DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: testInstanceDir, Id: "admin"}}, |
| 967 | }, |
| 968 | })) |
| 969 | a.NoError(err) |
| 970 | testInstance := testInstanceResp.Msg |
| 971 | |
| 972 | prodInstanceResp, err := ctl.instanceServiceClient.CreateInstance(ctx, connect.NewRequest(&v1pb.CreateInstanceRequest{ |
| 973 | InstanceId: generateRandomString("instance"), |
| 974 | Instance: &v1pb.Instance{ |
| 975 | Title: "gitops-multi-prod", |
| 976 | Engine: v1pb.Engine_SQLITE, |
| 977 | Environment: new("environments/prod"), |
| 978 | Activation: true, |
| 979 | DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: prodInstanceDir, Id: "admin"}}, |
| 980 | }, |
| 981 | })) |
| 982 | a.NoError(err) |
| 983 | prodInstance := prodInstanceResp.Msg |
| 984 |
nothing calls this directly
no test coverage detected