(t *testing.T)
| 682 | } |
| 683 | |
| 684 | func TestImportPartitionsServerless(t *testing.T) { |
| 685 | RequireBucketSpecificCredentials(t) |
| 686 | if base.UnitTestUrlIsWalrus() { |
| 687 | t.Skip("This test requires cbgt") |
| 688 | } |
| 689 | if !base.TestUseXattrs() { |
| 690 | t.Skip("tests import which is not available without xattrs") |
| 691 | } |
| 692 | tests := []struct { |
| 693 | name string |
| 694 | importPartition *uint16 |
| 695 | expectedPartitions *uint16 |
| 696 | serverless bool |
| 697 | }{ |
| 698 | { |
| 699 | name: "serverless partitions", |
| 700 | expectedPartitions: base.Ptr(uint16(6)), |
| 701 | serverless: true, |
| 702 | }, |
| 703 | { |
| 704 | name: "serverless partitions with import_partition specified", |
| 705 | importPartition: base.Ptr(uint16(8)), |
| 706 | expectedPartitions: base.Ptr(uint16(8)), |
| 707 | serverless: true, |
| 708 | }, |
| 709 | { |
| 710 | name: "non serverless partitions", |
| 711 | expectedPartitions: base.Ptr(uint16(16)), |
| 712 | serverless: false, |
| 713 | }, |
| 714 | } |
| 715 | |
| 716 | for _, test := range tests { |
| 717 | t.Run(test.name, func(t *testing.T) { |
| 718 | expectedPartitions := test.expectedPartitions |
| 719 | if !base.IsEnterpriseEdition() { |
| 720 | t.Logf("Import partitions setting is only supported in EE") |
| 721 | expectedPartitions = nil |
| 722 | } |
| 723 | |
| 724 | ctx := base.TestCtx(t) |
| 725 | tb := base.GetTestBucket(t) |
| 726 | defer tb.Close(ctx) |
| 727 | rt := NewRestTester(t, &RestTesterConfig{CustomTestBucket: tb.NoCloseClone(), PersistentConfig: true, serverless: test.serverless}) |
| 728 | defer rt.Close() |
| 729 | sc := rt.ServerContext() |
| 730 | |
| 731 | var dbconf *DbConfig |
| 732 | if test.name == "serverless partitions with import_partition specified" { |
| 733 | resp := rt.SendAdminRequest(http.MethodPut, "/db/", fmt.Sprintf(`{"bucket": "%s", "use_views": %t, "num_index_replicas": 0, "import_partitions": 8}`, |
| 734 | tb.GetName(), base.TestsDisableGSI())) |
| 735 | RequireStatus(t, resp, http.StatusCreated) |
| 736 | dbconf = sc.GetDbConfig("db") |
| 737 | } else { |
| 738 | dbconf = DefaultDbConfig(sc.Config, base.TestUseXattrs()) |
| 739 | } |
| 740 | |
| 741 | assert.Equal(t, expectedPartitions, dbconf.ImportPartitions) |
nothing calls this directly
no test coverage detected