- 生产页保存对内/对外库时,在同一事务内把还没上传、原本瞄准旧生产库的待入库项改指向新库,并在保存提示里回报迁移条数;执行已开始的项目标保持冻结。 - 重排改为「上一次生效目标 → 新目标」成对过滤:测试与生产共用 test_publications,测试侧保存不再带走瞄准生产库的待入库(验收附带发现)。 - 用例补生产重排、测试侧保存不误搬生产作业、生产保存不动测试作业三组断言。
This commit is contained in:
@@ -17,7 +17,7 @@ type RoutingBindingStore interface {
|
||||
SaveRoutingKBBindings(context.Context, string, string, string) error
|
||||
// SaveRoutingKBBindingsWithReplan also re-points 待入库 publications that
|
||||
// were still waiting for the previous knowledge base (same transaction).
|
||||
SaveRoutingKBBindingsWithReplan(ctx context.Context, internalID, externalID, effectiveInternal, effectiveExternal, updatedBy string, now time.Time) (postgresstore.RoutingBindingReplanResult, error)
|
||||
SaveRoutingKBBindingsWithReplan(ctx context.Context, save postgresstore.RoutingBindingSave, now time.Time) (postgresstore.RoutingBindingReplanResult, error)
|
||||
}
|
||||
|
||||
// KnowledgeBaseLister enumerates candidate knowledge bases in the connected
|
||||
@@ -196,6 +196,9 @@ func (config Config) handleSaveRoutingBindings(w http.ResponseWriter, r *http.Re
|
||||
// The saved binding re-routes FUTURE annotations; pending 待入库 items that
|
||||
// have never been uploaded are re-pointed in the same transaction, otherwise
|
||||
// they would keep aiming at the previous (possibly removed) knowledge base.
|
||||
// Only items aimed at the PREVIOUS effective target of this side move, so a
|
||||
// test-side save cannot carry off production-side pending work.
|
||||
previousInternal, previousExternal := config.effectiveRoutingTargets(r.Context())
|
||||
effectiveInternal := internal
|
||||
if effectiveInternal == "" {
|
||||
effectiveInternal = config.InternalRoutingKnowledgeBaseID
|
||||
@@ -204,7 +207,12 @@ func (config Config) handleSaveRoutingBindings(w http.ResponseWriter, r *http.Re
|
||||
if effectiveExternal == "" {
|
||||
effectiveExternal = config.ExternalRoutingKnowledgeBaseID
|
||||
}
|
||||
replan, err := config.RoutingBindings.SaveRoutingKBBindingsWithReplan(r.Context(), internal, external, effectiveInternal, effectiveExternal, actorFor(r), config.Now().UTC())
|
||||
replan, err := config.RoutingBindings.SaveRoutingKBBindingsWithReplan(r.Context(), postgresstore.RoutingBindingSave{
|
||||
InternalID: internal, ExternalID: external,
|
||||
Previous: postgresstore.EffectiveKBIDs{Internal: previousInternal, External: previousExternal},
|
||||
Effective: postgresstore.EffectiveKBIDs{Internal: effectiveInternal, External: effectiveExternal},
|
||||
UpdatedBy: actorFor(r),
|
||||
}, config.Now().UTC())
|
||||
if err != nil {
|
||||
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": "could not save routing bindings"})
|
||||
return
|
||||
|
||||
@@ -18,7 +18,8 @@ type bindingStoreFake struct {
|
||||
external string
|
||||
saver string
|
||||
// replan records what the last save asked for, so tests can assert that the
|
||||
// effective (env-fallback aware) targets were used.
|
||||
// effective (env-fallback aware) targets and the previous pair were used.
|
||||
replanPrevious [2]string
|
||||
replanEffective [2]string
|
||||
replanResult postgresstore.RoutingBindingReplanResult
|
||||
replanCallCount int
|
||||
@@ -33,9 +34,10 @@ func (fake *bindingStoreFake) SaveRoutingKBBindings(_ context.Context, internal,
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fake *bindingStoreFake) SaveRoutingKBBindingsWithReplan(_ context.Context, internal, external, effectiveInternal, effectiveExternal, updatedBy string, _ time.Time) (postgresstore.RoutingBindingReplanResult, error) {
|
||||
fake.internal, fake.external, fake.saver = internal, external, updatedBy
|
||||
fake.replanEffective = [2]string{effectiveInternal, effectiveExternal}
|
||||
func (fake *bindingStoreFake) SaveRoutingKBBindingsWithReplan(_ context.Context, save postgresstore.RoutingBindingSave, _ time.Time) (postgresstore.RoutingBindingReplanResult, error) {
|
||||
fake.internal, fake.external, fake.saver = save.InternalID, save.ExternalID, save.UpdatedBy
|
||||
fake.replanPrevious = [2]string{save.Previous.Internal, save.Previous.External}
|
||||
fake.replanEffective = [2]string{save.Effective.Internal, save.Effective.External}
|
||||
fake.replanCallCount++
|
||||
return fake.replanResult, nil
|
||||
}
|
||||
@@ -134,6 +136,9 @@ func TestRoutingBindingsSaveReportsReplanAndUsesEffectiveTargets(t *testing.T) {
|
||||
if store.replanEffective != [2]string{"kb-in", "env-external"} {
|
||||
t.Fatalf("effective targets = %#v, want the env fallback on the unbound side", store.replanEffective)
|
||||
}
|
||||
if store.replanPrevious != [2]string{"env-internal", "env-external"} {
|
||||
t.Fatalf("previous targets = %#v, want the pre-save effective pair", store.replanPrevious)
|
||||
}
|
||||
var envelope struct {
|
||||
Data struct {
|
||||
Replanned int `json:"replanned"`
|
||||
|
||||
Reference in New Issue
Block a user