-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* annotate backup throttler func * query, update queue usage to etcd * use protobuf marshal unmarshal queue usage * watch etcd to update queue instead of in memory Co-authored-by: chengjoey <30427474+chengjoey@users.noreply.github.com>
- Loading branch information
Showing
16 changed files
with
423 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) 2021 Terminus, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package reconciler | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"reflect" | ||
"testing" | ||
"time" | ||
|
||
"bou.ke/monkey" | ||
|
||
"github.com/erda-project/erda/modules/pipeline/pipengine/reconciler/queuemanage/manager" | ||
"github.com/erda-project/erda/pkg/jsonstore/etcd" | ||
) | ||
|
||
func TestContinueBackupQueueUsage(t *testing.T) { | ||
etcdClient := &etcd.Store{} | ||
pm := monkey.PatchInstanceMethod(reflect.TypeOf(etcdClient), "Put", func(j *etcd.Store, ctx context.Context, key string, value string) error { | ||
return fmt.Errorf("failed to put msg") | ||
}) | ||
defer pm.Unpatch() | ||
q := manager.New(context.Background(), manager.WithEtcdClient(etcdClient)) | ||
//pm1 := monkey.PatchInstanceMethod(reflect.TypeOf(q), "Export", func(mgr *types.QueueManager) json.RawMessage { | ||
// u := &pb.QueueUsage{} | ||
// bu, _ := json.Marshal(u) | ||
// sna := manager.SnapshotObj{ | ||
// QueueUsageByID: map[string]json.RawMessage{ | ||
// "1": bu, | ||
// }, | ||
// } | ||
// snaByte, _ := json.Marshal(&sna) | ||
// return snaByte | ||
//}) | ||
//defer pm1.Unpatch() | ||
r := &Reconciler{ | ||
QueueManager: q, | ||
} | ||
t.Run("continueBackupQueueUsage", func(t *testing.T) { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
go r.continueBackupQueueUsage(ctx) | ||
time.Sleep(2 * time.Second) | ||
cancel() | ||
}) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.