Skip to content

Commit e245c56

Browse files
committed
Revert "Deprecated Site Replication in UI (minio#3469)"
This reverts commit 4e5dcf0.
1 parent 2054ee6 commit e245c56

File tree

53 files changed

+6455
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+6455
-15
lines changed

.github/workflows/jobs.yaml

Lines changed: 114 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ jobs:
228228
run: npm install [email protected]
229229

230230
- name: Run TestCafe Tests
231-
run: npx testcafe "firefox:headless" web-app/tests/subpath-nginx/ -q --skip-js-errors -c 3
231+
run: npx testcafe "chrome:headless" web-app/tests/subpath-nginx/ -q --skip-js-errors -c 3
232232

233233
- name: Clean up docker
234234
if: always()
@@ -282,7 +282,7 @@ jobs:
282282
run: npm install [email protected]
283283

284284
- name: Run TestCafe Tests
285-
run: npx testcafe "firefox:headless" web-app/tests/permissions-1/ -q --skip-js-errors -c 3
285+
run: npx testcafe "chrome:headless" web-app/tests/permissions-1/ -q --skip-js-errors -c 3
286286

287287
- name: Clean up users & policies
288288
run: |
@@ -334,7 +334,7 @@ jobs:
334334
run: npm install [email protected]
335335

336336
- name: Run TestCafe Tests
337-
run: npx testcafe "firefox:headless" web-app/tests/permissions-2/ -q --skip-js-errors -c 3
337+
run: npx testcafe "chrome:headless" web-app/tests/permissions-2/ -q --skip-js-errors -c 3
338338

339339
- name: Clean up users & policies
340340
run: |
@@ -386,7 +386,7 @@ jobs:
386386
run: npm install [email protected]
387387

388388
- name: Run TestCafe Tests
389-
run: npx testcafe "firefox:headless" web-app/tests/permissions-3/ -q --skip-js-errors -c 3
389+
run: npx testcafe "chrome:headless" web-app/tests/permissions-3/ -q --skip-js-errors -c 3
390390

391391
- name: Clean up users & policies
392392
run: |
@@ -439,7 +439,7 @@ jobs:
439439

440440
- name: Run TestCafe Tests
441441
timeout-minutes: 10
442-
run: npx testcafe "firefox:headless" web-app/tests/permissions-4/ --skip-js-errors
442+
run: npx testcafe "chrome:headless" web-app/tests/permissions-4/ --skip-js-errors
443443

444444
all-permissions-5:
445445
name: Permissions Tests Part 5
@@ -487,7 +487,7 @@ jobs:
487487

488488
- name: Run TestCafe Tests
489489
timeout-minutes: 5
490-
run: npx testcafe "firefox:headless" web-app/tests/permissions-5/ --skip-js-errors
490+
run: npx testcafe "chrome:headless" web-app/tests/permissions-5/ --skip-js-errors
491491

492492
all-permissions-6:
493493
name: Permissions Tests Part 6
@@ -535,7 +535,7 @@ jobs:
535535

536536
- name: Run TestCafe Tests
537537
timeout-minutes: 5
538-
run: npx testcafe "firefox:headless" web-app/tests/permissions-6/ --skip-js-errors
538+
run: npx testcafe "chrome:headless" web-app/tests/permissions-6/ --skip-js-errors
539539

540540
all-permissions-7:
541541
name: Permissions Tests Part 7
@@ -582,7 +582,7 @@ jobs:
582582

583583
- name: Run TestCafe Tests
584584
timeout-minutes: 5
585-
run: npx testcafe "firefox:headless" web-app/tests/permissions-7/ --skip-js-errors
585+
run: npx testcafe "chrome:headless" web-app/tests/permissions-7/ --skip-js-errors
586586

587587
all-permissions-8:
588588
name: Permissions Tests Part 8
@@ -630,7 +630,7 @@ jobs:
630630

631631
- name: Run TestCafe Tests
632632
timeout-minutes: 5
633-
run: npx testcafe "firefox:headless" web-app/tests/permissions-8/ --skip-js-errors
633+
run: npx testcafe "chrome:headless" web-app/tests/permissions-8/ --skip-js-errors
634634

635635
all-permissions-A:
636636
name: Permissions Tests Part A
@@ -677,7 +677,7 @@ jobs:
677677
run: npm install [email protected]
678678

679679
- name: Run TestCafe Tests
680-
run: npx testcafe "firefox:headless" web-app/tests/permissions-A/ --skip-js-errors -c 3
680+
run: npx testcafe "chrome:headless" web-app/tests/permissions-A/ --skip-js-errors -c 3
681681

682682
- name: Clean up users & policies
683683
run: |
@@ -728,7 +728,7 @@ jobs:
728728
run: npm install [email protected]
729729

730730
- name: Run TestCafe Tests
731-
run: npx testcafe "firefox:headless" web-app/tests/permissions-B/ --skip-js-errors -c 3
731+
run: npx testcafe "chrome:headless" web-app/tests/permissions-B/ --skip-js-errors -c 3
732732

733733
- name: Clean up users & policies
734734
run: |
@@ -900,7 +900,88 @@ jobs:
900900
- name: Run tests
901901
working-directory: ./web-app
902902
run: yarn test
903+
replication:
904+
name: Site Replication Test
905+
needs:
906+
- lint-job
907+
- ui-assets
908+
- semgrep-static-code-analysis
909+
- latest-minio
910+
runs-on: [ubuntu-latest]
911+
912+
strategy:
913+
matrix:
914+
go-version: [1.22.x]
915+
916+
steps:
917+
- name: Check out code
918+
uses: actions/checkout@v3
919+
920+
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
921+
uses: actions/setup-go@v5
922+
with:
923+
go-version: ${{ matrix.go-version }}
924+
id: go
903925

926+
- name: Clone github.com/minio/minio
927+
uses: actions/checkout@master
928+
with:
929+
repository: minio/minio
930+
path: "minio_repository"
931+
- name: Check-out matching MinIO branch
932+
env:
933+
GH_BRANCH: ${{ github.head_ref || github.ref_name }}
934+
GH_PR_REPO: ${{ github.event.pull_request.head.repo.full_name }}
935+
run: |
936+
GH_PR_ACCOUNT=`echo $GH_PR_REPO | sed "s/\\/.*//"`
937+
if [ ! -z "$GH_PR_ACCOUNT" ] && [ ! "$GH_PR_ACCOUNT" = "minio" ]; then
938+
ALTREPO="https://github.com/$GH_PR_ACCOUNT/minio.git"
939+
echo "Attempting to fetch $ALTREPO..."
940+
git remote add alt $ALTREPO
941+
(git fetch alt && git checkout "alt/$GH_BRANCH") || echo "$ALTREPO ($GH_BRANCH) not available, so keeping default repository/branch"
942+
fi
943+
- uses: actions/cache@v4
944+
id: minio-latest-cache
945+
name: MinIO Latest Cache
946+
with:
947+
path: |
948+
./minio
949+
key: ${{ runner.os }}-minio-latest-${{ hashFiles('./minio_repository/go.sum') }}
950+
951+
- name: Build on ${{ matrix.os }}
952+
run: |
953+
echo "The idea is to build minio image from downloaded repository";
954+
cd $GITHUB_WORKSPACE/minio_repository;
955+
echo "Get git version to build MinIO Image";
956+
VERSION=`git rev-parse HEAD`;
957+
echo $VERSION;
958+
echo "Create MinIO image";
959+
make docker VERSION=$VERSION;
960+
961+
docker build -q --no-cache -t minio/minio:$VERSION . -f Dockerfile
962+
echo "Jumping back to console repository to run the integration test"
963+
cd $GITHUB_WORKSPACE;
964+
965+
echo "We are going to use the built image on test-integration";
966+
MINIO_VERSION="minio/minio:$VERSION";
967+
echo $MINIO_VERSION;
968+
969+
make test-replication MINIO_VERSION=$MINIO_VERSION;
970+
- uses: actions/cache@v4
971+
id: coverage-cache-replication
972+
name: Coverage Cache Replication
973+
with:
974+
path: |
975+
./replication/coverage/
976+
key: ${{ runner.os }}-replication-coverage-2-${{ github.run_id }}
977+
978+
# To save our replication.out file into an artifact.
979+
# By default, GitHub stores build logs and artifacts for 90 days.
980+
- uses: actions/upload-artifact@v4
981+
with:
982+
name: replication-artifact
983+
path: ./replication/coverage/replication.out
984+
if-no-files-found: error
904985
sso-integration:
905986
name: SSO Integration Test
906987
needs:
@@ -993,6 +1074,7 @@ jobs:
9931074
- test-api-on-go
9941075
- test-pkg-on-go
9951076
- sso-integration
1077+
- replication
9961078
runs-on: ${{ matrix.os }}
9971079
strategy:
9981080
matrix:
@@ -1028,6 +1110,14 @@ jobs:
10281110
./sso-integration/coverage/
10291111
key: ${{ runner.os }}-sso-coverage-2-${{ github.run_id }}
10301112

1113+
- uses: actions/cache@v4
1114+
id: coverage-cache-replication
1115+
name: Coverage Cache Replication
1116+
with:
1117+
path: |
1118+
./replication/coverage/
1119+
key: ${{ runner.os }}-replication-coverage-2-${{ github.run_id }}
1120+
10311121
- uses: actions/cache@v4
10321122
id: coverage-cache-api
10331123
name: Coverage Cache API
@@ -1044,6 +1134,12 @@ jobs:
10441134
./pkg/coverage/
10451135
key: ${{ runner.os }}-coverage-pkg-2-${{ github.run_id }}
10461136

1137+
# Get the replication.out file from the artifact since this is working for self host runner.
1138+
- uses: actions/download-artifact@v4
1139+
with:
1140+
name: replication-artifact
1141+
path: replication/coverage
1142+
10471143
- name: Get coverage
10481144
run: |
10491145
echo "change directory to gocovmerge"
@@ -1055,12 +1151,12 @@ jobs:
10551151
echo "go build gocoverage.go"
10561152
go build gocovmerge.go
10571153
echo "put together the outs for final coverage resolution"
1058-
./gocovmerge ../integration/coverage/system.out ../sso-integration/coverage/sso-system.out ../api/coverage/coverage.out ../pkg/coverage/coverage-pkg.out > all.out
1154+
./gocovmerge ../integration/coverage/system.out ../replication/coverage/replication.out ../sso-integration/coverage/sso-system.out ../api/coverage/coverage.out ../pkg/coverage/coverage-pkg.out > all.out
10591155
echo "Download mc for Ubuntu"
10601156
wget -q https://dl.min.io/client/mc/release/linux-amd64/mc
10611157
echo "Change the permissions to execute mc command"
10621158
chmod +x mc
1063-
echo "Only run our test if play is up and running"
1159+
echo "Only run our test if play is up and running since we require it for replication tests here."
10641160
PLAY_IS_ON=`wget --spider --server-response https://play.min.io:9443/login 2>&1 | grep '200\ OK' | wc -l`
10651161
if [ $PLAY_IS_ON == 1 ]
10661162
then
@@ -1084,6 +1180,11 @@ jobs:
10841180
./mc cp system.html play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
10851181
./mc cp ../integration/coverage/system.out play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
10861182
./mc cp ../integration/coverage/system.out play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
1183+
go tool cover -html=../replication/coverage/replication.out -o replication.html
1184+
./mc cp replication.html play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
1185+
./mc cp replication.html play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
1186+
./mc cp ../replication/coverage/replication.out play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
1187+
./mc cp ../replication/coverage/replication.out play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
10871188
go tool cover -html=../sso-integration/coverage/sso-system.out -o sso-system.html
10881189
./mc cp sso-system.html play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
10891190
./mc cp sso-system.html play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true

api/admin_replication_status.go

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2022 MinIO, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
package api
18+
19+
import (
20+
"context"
21+
22+
"github.com/go-openapi/runtime/middleware"
23+
"github.com/minio/console/api/operations"
24+
siteRepApi "github.com/minio/console/api/operations/site_replication"
25+
"github.com/minio/console/models"
26+
"github.com/minio/madmin-go/v3"
27+
)
28+
29+
func registerSiteReplicationStatusHandler(api *operations.ConsoleAPI) {
30+
api.SiteReplicationGetSiteReplicationStatusHandler = siteRepApi.GetSiteReplicationStatusHandlerFunc(func(params siteRepApi.GetSiteReplicationStatusParams, session *models.Principal) middleware.Responder {
31+
rInfo, err := getSRStatusResponse(session, params)
32+
if err != nil {
33+
return siteRepApi.NewGetSiteReplicationStatusDefault(err.Code).WithPayload(err.APIError)
34+
}
35+
return siteRepApi.NewGetSiteReplicationStatusOK().WithPayload(rInfo)
36+
})
37+
}
38+
39+
func getSRStatusResponse(session *models.Principal, params siteRepApi.GetSiteReplicationStatusParams) (*models.SiteReplicationStatusResponse, *CodedAPIError) {
40+
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
41+
defer cancel()
42+
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
43+
if err != nil {
44+
return nil, ErrorWithContext(ctx, err)
45+
}
46+
adminClient := AdminClient{Client: mAdmin}
47+
res, err := getSRStats(ctx, adminClient, params)
48+
if err != nil {
49+
return nil, ErrorWithContext(ctx, err)
50+
}
51+
return res, nil
52+
}
53+
54+
func getSRStats(ctx context.Context, client MinioAdmin, params siteRepApi.GetSiteReplicationStatusParams) (info *models.SiteReplicationStatusResponse, err error) {
55+
srParams := madmin.SRStatusOptions{
56+
Buckets: *params.Buckets,
57+
Policies: *params.Policies,
58+
Users: *params.Users,
59+
Groups: *params.Groups,
60+
}
61+
if params.EntityType != nil && params.EntityValue != nil {
62+
srParams.Entity = madmin.GetSREntityType(*params.EntityType)
63+
srParams.EntityValue = *params.EntityValue
64+
}
65+
66+
srInfo, err := client.getSiteReplicationStatus(ctx, srParams)
67+
68+
retInfo := models.SiteReplicationStatusResponse{
69+
BucketStats: &srInfo.BucketStats,
70+
Enabled: srInfo.Enabled,
71+
GroupStats: srInfo.GroupStats,
72+
MaxBuckets: int64(srInfo.MaxBuckets),
73+
MaxGroups: int64(srInfo.MaxGroups),
74+
MaxPolicies: int64(srInfo.MaxPolicies),
75+
MaxUsers: int64(srInfo.MaxUsers),
76+
PolicyStats: &srInfo.PolicyStats,
77+
Sites: &srInfo.Sites,
78+
StatsSummary: srInfo.StatsSummary,
79+
UserStats: &srInfo.UserStats,
80+
}
81+
82+
if err != nil {
83+
return nil, err
84+
}
85+
return &retInfo, nil
86+
}

0 commit comments

Comments
 (0)