Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,6 @@ endif

TEST_NET := --net=host

SPACE :=
TABV4 := $(SPACE) $(SPACE) $(SPACE) $(SPACE)
ifdef DUMP_AGENCY_ON_FAILURE
$(info Checking for jq...)
CHECK_JQ_INSTALLTION := $(shell jq --version 2>&1 >/dev/null | cat)
ifneq ($(CHECK_JQ_INSTALLTION),)
$(info )
$(info Error: 'jq' is not installed. This check happens because DUMP_AGENCY_ON_FAILURE is set, and 'jq' is used during the creation of the agency dump. Verified for version jq==1.6. )
$(info Try installing it with:)
$(info $(TABV4) sudo apt install jq)
$(info )
$(error $(CHECK_JQ_INSTALLTION))
endif
endif
# Installation of jq is required for processing AGENCY_DUMP
# ifdef DUMP_AGENCY_ON_FAILURE
# CHECK_JQ_INSTALLTION := $(shell command -v jq >/dev/null 2>&1 || (
Expand Down
4 changes: 2 additions & 2 deletions collection.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2017-2021 ArangoDB GmbH, Cologne, Germany
// Copyright 2017-2025 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -183,7 +183,7 @@ type CollectionProperties struct {

IsSmartChild bool `json:"isSmartChild,omitempty"`

InternalValidatorType *int `json:"internalValidatorType, omitempty"`
InternalValidatorType *int `json:"internalValidatorType,omitempty"`

// Set to create a smart edge or vertex collection.
// This requires ArangoDB Enterprise Edition.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//
// DISCLAIMER
//
// Copyright 2025 ArangoDB GmbH, Cologne, Germany
//
// 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.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//

package main

import (
"encoding/json"
"fmt"
"io"
"os"
)

func ExtractValue(input io.Reader) error {
var data map[string]interface{}

decoder := json.NewDecoder(input)
if err := decoder.Decode(&data); err != nil {
return fmt.Errorf("failed to decode JSON: %w", err)
}

configuration, ok := data["configuration"].(map[string]interface{})
if !ok {
return fmt.Errorf("key 'configuration' not found or not an object")
}
pool, ok := configuration["pool"].(map[string]interface{})
if !ok {
return fmt.Errorf("key 'pool' not found or not an array")
}

leaderId, ok := data["leaderId"].(string)
if !ok {
return fmt.Errorf("key 'leaderId' not found or not a str")
}
if leaderId == "" {
return fmt.Errorf("key 'leaderId' not set")
}

endpoint, ok := pool[leaderId].(string)
if !ok {
return fmt.Errorf("key '%s' not found or not a str", leaderId)
}
fmt.Println(endpoint)

return nil
}

func main() {
if err := ExtractValue(os.Stdin); err != nil {
fmt.Fprintf(os.Stderr, "JsonAgencyConfigParseError: %v\n and as a result the agency dump could not be created.\n", err)

}
}
17 changes: 10 additions & 7 deletions test/on_failure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@ if [ -n "${DUMP_AGENCY_ON_FAILURE}" ] && [ "${TEST_MODE}" = "cluster" ]; then
# _api/agency/config returns leader endpoint with protocol that is usually not supported by curl
AGENCY_CONFIG=$(bash -c "curl -k --no-progress-meter ${AUTH} ${ANY_ENDPOINT}/_api/agency/config")

LEADER_ENDPOINT_WITH_UNSUPPORTED_PROTOCOL=$(echo $AGENCY_CONFIG | jq -r '.configuration.pool[.leaderId]' | cat)
# same as: jq -r '.configuration.pool[.leaderId]'
LEADER_ENDPOINT_WITH_UNSUPPORTED_PROTOCOL=$(echo $AGENCY_CONFIG | go run ./test/json_agency_config_parse_leader_id/json_agency_config_parse_leader_id.go | cat)
SED_UNSUPPORTED_PROTOCOL_ENDPOINT_TO_ENDPOINT="s/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//${PROTOCOL}:\/\//"
LEADER_ENDPOINT=$(echo $LEADER_ENDPOINT_WITH_UNSUPPORTED_PROTOCOL | sed $SED_UNSUPPORTED_PROTOCOL_ENDPOINT_TO_ENDPOINT)
echo "Leader agent endpoint: $LEADER_ENDPOINT"

DUMP_FILE_PATH=$DUMP_AGENCY_ON_FAILURE
mkdir -p $(dirname ${DUMP_FILE_PATH})
AGENCY_DUMP=$(bash -c "curl -Lk --no-progress-meter ${AUTH} ${LEADER_ENDPOINT}/_api/agency/state")
echo $AGENCY_DUMP > $DUMP_FILE_PATH
echo "Agency dump created at $(realpath $DUMP_FILE_PATH)"
if expr "$LEADER_ENDPOINT" : "^$PROTOCOL" > /dev/null; then
echo "Leader agent endpoint: $LEADER_ENDPOINT"
DUMP_FILE_PATH=$DUMP_AGENCY_ON_FAILURE
mkdir -p $(dirname ${DUMP_FILE_PATH})
AGENCY_DUMP=$(bash -c "curl -Lk --no-progress-meter ${AUTH} ${LEADER_ENDPOINT}/_api/agency/state")
echo $AGENCY_DUMP > $DUMP_FILE_PATH
echo "Agency dump created at $(realpath $DUMP_FILE_PATH)"
fi
fi

echo "\nV${MAJOR_VERSION} Tests with ARGS: TEST_MODE=${TEST_MODE} TEST_AUTH=${TEST_AUTH} TEST_CONTENT_TYPE=${TEST_CONTENT_TYPE} TEST_SSL=${TEST_SSL} TEST_CONNECTION=${TEST_CONNECTION} TEST_CVERSION=${TEST_CVERSION}";
Expand Down