Skip to content

Commit

Permalink
Merged 7.3.43 from upstream to ow-fork (#127)
Browse files Browse the repository at this point in the history
* Merge from apple 7.3.43

* set small letter for repository owner name
  • Loading branch information
MarkSh1 authored Jun 7, 2024
1 parent 9d7974d commit 03e271f
Show file tree
Hide file tree
Showing 119 changed files with 6,102 additions and 2,112 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Calculate versions
id: vers
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
runs-on: ${{ matrix.run_on }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set building repo
run: |
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Download the foundationdb distro
uses: actions/download-artifact@v3
Expand Down Expand Up @@ -141,7 +141,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Download the foundationdb distro
uses: actions/download-artifact@v3
Expand All @@ -168,7 +168,7 @@ jobs:
${{github.workspace}}/packaging/docker/build-images-for-owtech.bash \
${{needs.calc_ver.outputs.full_ver}} \
${{github.workspace}}/bld/linux/packages \
ghcr.io/${{ github.repository_owner }}
ghcr.io/${GITHUB_REPOSITORY_OWNER@L}
tests:
needs: [calc_ver, build]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/make-build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Calculate versions
id: vers
Expand All @@ -43,7 +43,7 @@ jobs:
runs-on: ${{ matrix.run_on }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build an image
run: |
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if(POLICY CMP0135)
endif()

project(foundationdb
VERSION 7.3.27
VERSION 7.3.43
DESCRIPTION "FoundationDB is a scalable, fault-tolerant, ordered key-value store with full ACID transactions."
HOMEPAGE_URL "http://www.foundationdb.org/"
LANGUAGES C CXX ASM)
Expand Down
3 changes: 1 addition & 2 deletions bindings/go/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set(SRCS
src/fdb/tuple/tuple_test.go
src/fdb/database.go
src/fdb/directory/directorySubspace.go
src/fdb/tenant.go
src/fdb/fdb_test.go
src/fdb/snapshot.go)

Expand Down Expand Up @@ -100,8 +101,6 @@ function(build_go_package)
endif()
add_custom_command(OUTPUT ${outfile}
COMMAND ${CMAKE_COMMAND} -E env ${go_env}
${GO_EXECUTABLE} get -d ${GO_IMPORT_PATH}/${BGP_PATH} &&
${CMAKE_COMMAND} -E env ${go_env}
${GO_EXECUTABLE} install ${GO_IMPORT_PATH}/${BGP_PATH}
DEPENDS ${fdb_options_file}
COMMENT "Building ${BGP_NAME}")
Expand Down
4 changes: 4 additions & 0 deletions bindings/go/src/fdb/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ var (
errAPIVersionUnset = Error{2200}
errAPIVersionAlreadySet = Error{2201}
errAPIVersionNotSupported = Error{2203}

errTenantNotFound = Error{2131}
errTenantExists = Error{2132}
errTenantNameInvalid = Error{2134}
)
131 changes: 131 additions & 0 deletions bindings/go/src/fdb/fdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package fdb_test

import (
"bytes"
"fmt"
"os"
"testing"
Expand Down Expand Up @@ -368,3 +369,133 @@ func ExampleOpenWithConnectionString() {

// Output:
}

// Copied from errors.go so that these types aren't public
var (
errTenantNotFound = fdb.Error{2131}
errTenantExists = fdb.Error{2132}
errTenantNameInvalid = fdb.Error{2134}
)

func TestCreateTenant(t *testing.T) {
fdb.MustAPIVersion(API_VERSION)
db := fdb.MustOpenDefault()

testTenantName := fdb.Key("test-create-tenant")

err := db.CreateTenant(testTenantName)
if err != nil {
t.Fatalf("Unable to create tenant: %v\n", err)
}

_, err = db.OpenTenant(testTenantName)
if err != nil {
t.Fatalf("Unable to open tenant: %v\n", err)
}
}

func TestCreateExistTenant(t *testing.T) {
fdb.MustAPIVersion(API_VERSION)
db := fdb.MustOpenDefault()

testTenantName := fdb.Key("test-exist-tenant")

err := db.CreateTenant(testTenantName)
if err != nil {
t.Fatalf("Unable to create tenant: %v\n", err)
}

// This should fail
err = db.CreateTenant(testTenantName)
assertErrorCodeEqual(t, err, errTenantExists)
}

/* FIXME: This test will not pass as does not properly return error code TenantNotFound
func TestOpenNotExistTenant(t *testing.T) {
fdb.MustAPIVersion(API_VERSION)
db := fdb.MustOpenDefault()
testTenantName := fdb.Key("test-not-exist-tenant")
// this should fail
_, err := db.OpenTenant(testTenantName)
assertErrorCodeEqual(t, err, errTenantNotFound)
}
*/

func TestDeleteNotExistTenant(t *testing.T) {
fdb.MustAPIVersion(API_VERSION)
db := fdb.MustOpenDefault()

testTenantName := fdb.Key("test-not-exist-tenant")

// this should fail
err := db.DeleteTenant(testTenantName)
assertErrorCodeEqual(t, err, errTenantNotFound)
}

func inSlice(sl []fdb.Key, t fdb.Key) bool {
for _, s := range sl {
if bytes.Equal(s, t) {
return true
}
}
return false
}

func assertErrorCodeEqual(t *testing.T, actual error, expected fdb.Error) {
if actual == nil {
t.Fatalf("Error is nil when it should be: %v\n", expected.Code)
}

castErr, ok := actual.(fdb.Error)
if !ok {
t.Fatalf("Error is wrong type %v, expected %v\n", actual, expected)
}

if castErr.Code != expected.Code {
t.Fatalf("Error is wrong code, expected %v, actual %v\n", expected.Code, castErr.Code)
}
}

func TestListTenant(t *testing.T) {
fdb.MustAPIVersion(API_VERSION)
db := fdb.MustOpenDefault()

testTenantName1 := fdb.Key("1-test-list-1-tenant-1")
testTenantName2 := fdb.Key("2-test-list-2-tenant-2")

err := db.CreateTenant(testTenantName1)
if err != nil {
t.Fatalf("Unable to create tenant 1: %v\n", err)
}

err = db.CreateTenant(testTenantName2)
if err != nil {
t.Fatalf("Unable to create tenant 2: %v\n", err)
}

ls, err := db.ListTenants()
if err != nil {
t.Fatalf("Unable to list tenants: %v\n", err)
}

if !inSlice(ls, testTenantName1) {
t.Fatalf("tenant 1 not in slice %#v", ls)
}

if !inSlice(ls, testTenantName2) {
t.Fatalf("tenant 2 not in slice, %#v", ls)
}
}

func TestInvalidPrefixTenant(t *testing.T) {
fdb.MustAPIVersion(API_VERSION)
db := fdb.MustOpenDefault()

testTenantName := fdb.Key("\xFFtest-invalid-prefix-tenant")

// this should fail
err := db.CreateTenant(testTenantName)
assertErrorCodeEqual(t, err, errTenantNameInvalid)
}
Loading

0 comments on commit 03e271f

Please sign in to comment.