Skip to content

Commit

Permalink
Merge pull request #389 from jfdenise/cloud-4173-cont
Browse files Browse the repository at this point in the history
Fix for CLOUD-4173 continuing
  • Loading branch information
jfdenise authored Aug 24, 2023
2 parents 3c6e78a + 2bf5934 commit 257b66a
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ function init_node_name() {
else
JBOSS_NODE_NAME="${HOSTNAME}"
fi

# CLOUD-427: truncate transaction node-id JBOSS_TX_NODE_ID to the last 23 characters of the JBOSS_NODE_NAME
fi
# CLOUD-427: truncate transaction node-id JBOSS_TX_NODE_ID to the last 23 characters of the JBOSS_NODE_NAME
if [ ${#JBOSS_NODE_NAME} -gt 23 ]; then
JBOSS_TX_NODE_ID=${JBOSS_NODE_NAME: -23}
else
JBOSS_TX_NODE_ID=${JBOSS_NODE_NAME}
fi
}
63 changes: 63 additions & 0 deletions jboss/container/wildfly/launch/os/node-name/test/node-name.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bats

# fake JBOSS_HOME
export JBOSS_HOME=$BATS_TMPDIR/jboss_home
rm -rf $JBOSS_HOME 2>/dev/null
mkdir -p $JBOSS_HOME/bin/launch

# copy scripts we are going to use
cp $BATS_TEST_DIRNAME/../added/launch/openshift-node-name.sh $JBOSS_HOME/bin/launch


# source the scripts needed
source $JBOSS_HOME/bin/launch/openshift-node-name.sh


@test "JBoss Node name set to a value smaller than 23" {
JBOSS_NODE_NAME=foo
init_node_name
[ "${JBOSS_NODE_NAME}" = "foo" ]
[ "${JBOSS_TX_NODE_ID}" = "foo" ]
}

@test "JBOSS_NODE_NAME set" {
JBOSS_NODE_NAME=abcdefghijklmnopqrstuvwxyz123
init_node_name
echo $JBOSS_NODE_NAME

# Verify that jboss.node.name is untouched
[ "${JBOSS_NODE_NAME}" = "abcdefghijklmnopqrstuvwxyz123" ]
# Verify that jboss.tx.node.id is truncated to last 23 characters
[ "${JBOSS_TX_NODE_ID}" = "ghijklmnopqrstuvwxyz123" ]
}

@test "Node name set" {
NODE_NAME=abcdefghijklmnopqrstuvwxyz
init_node_name

# Verify that jboss.node.name is untouched
[ "${JBOSS_NODE_NAME}" = "abcdefghijklmnopqrstuvwxyz" ]
# Verify that jboss.tx.node.id is truncated to last 23 characters
[ "${JBOSS_TX_NODE_ID}" = "defghijklmnopqrstuvwxyz" ]
}

@test "Node name set to value smaller than 23" {
NODE_NAME=abcdef
init_node_name

# Verify that jboss.node.name is untouched
[ "${JBOSS_NODE_NAME}" = "abcdef" ]
# Verify that jboss.tx.node.id is untouched
[ "${JBOSS_TX_NODE_ID}" = "abcdef" ]
}

@test "Host name set" {
HOSTNAME=abcdefghijklmnopqrstuvwxyz123
init_node_name
echo $JBOSS_NODE_NAME

# Verify that jboss.node.name is untouched
[ "${JBOSS_NODE_NAME}" = "abcdefghijklmnopqrstuvwxyz123" ]
# Verify that jboss.tx.node.id is truncated to last 23 characters
[ "${JBOSS_TX_NODE_ID}" = "ghijklmnopqrstuvwxyz123" ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ function run_init_node_name() {
else
JBOSS_NODE_NAME="$(hostname)"
fi

# CLOUD-427: truncate transaction node-id JBOSS_TX_NODE_ID to the last 23 characters of the JBOSS_NODE_NAME
fi
# CLOUD-427: truncate transaction node-id JBOSS_TX_NODE_ID to the last 23 characters of the JBOSS_NODE_NAME
if [ ${#JBOSS_NODE_NAME} -gt 23 ]; then
JBOSS_TX_NODE_ID=${JBOSS_NODE_NAME: -23}
else
JBOSS_TX_NODE_ID=${JBOSS_NODE_NAME}
fi
}
}
24 changes: 23 additions & 1 deletion jboss/container/wildfly/run/bash/test/run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,22 @@ setup() {
[ "$status" -eq 0 ]
}

@test "JBoss Node name set" {
@test "JBoss Node name set to a value smaller than 23" {
JBOSS_NODE_NAME=foo
run_init_node_name
[ "${JBOSS_NODE_NAME}" = "foo" ]
[ "${JBOSS_TX_NODE_ID}" = "foo" ]
}

@test "JBOSS_NODE_NAME set" {
JBOSS_NODE_NAME=abcdefghijklmnopqrstuvwxyz123
run_init_node_name
echo $JBOSS_NODE_NAME

# Verify that jboss.node.name is untouched
[ "${JBOSS_NODE_NAME}" = "abcdefghijklmnopqrstuvwxyz123" ]
# Verify that jboss.tx.node.id is truncated to last 23 characters
[ "${JBOSS_TX_NODE_ID}" = "ghijklmnopqrstuvwxyz123" ]
}

@test "Node name set" {
Expand All @@ -50,6 +62,16 @@ setup() {
[ "${JBOSS_TX_NODE_ID}" = "defghijklmnopqrstuvwxyz" ]
}

@test "Node name set to value smaller than 23" {
NODE_NAME=abcdef
run_init_node_name

# Verify that jboss.node.name is untouched
[ "${JBOSS_NODE_NAME}" = "abcdef" ]
# Verify that jboss.tx.node.id is untouched
[ "${JBOSS_TX_NODE_ID}" = "abcdef" ]
}

@test "Host name set" {
HOSTNAME=abcdefghijklmnopqrstuvwxyz123
run_init_node_name
Expand Down

0 comments on commit 257b66a

Please sign in to comment.