Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gatling 3.11 upgrade #120

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

annappropriate
Copy link

Description

https://docs.gatling.io/release-notes/oss/upgrading/3.10-to-3.11/#upgrading-the-gatling-gradle-plugin-to-3110

It now uses a --simulation= option to force the desired simulation instead of the non-standard gatlingRun- pattern.

Checklist

Please check if applicable

  • Tests have been added (if applicable, ie. when operator codes are added or modified)
  • Relevant docs have been added or modified (if applicable, ie. when new features are added or current features are modified)

Relevant issue #

@kane8n kane8n requested a review from a team June 12, 2024 00:42
Copy link
Contributor

@gold-kou gold-kou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kane8n
Copy link
Contributor

kane8n commented Jun 12, 2024

Thanks for the PullRequest!
It seems to work fine with gatling 3.11.
However, there seems to be a backward compatibility issue, so please let me check.

@kane8n
Copy link
Contributor

kane8n commented Jul 12, 2024

@annappropriate
Sorry for the very long wait.
We will implement the following for gatling 3.11 support to maintain backward compatibility.
Please test if it works with this PullRequest ahead of time so we can merge it.

diff --git a/pkg/commands/commands.go b/pkg/commands/commands.go
index aacf3c6..55e33af 100644
--- a/pkg/commands/commands.go
+++ b/pkg/commands/commands.go
@@ -37,6 +37,53 @@ func GetGatlingRunnerCommand(
        generateLocalReport bool) string {
 
        template := `
+# Function to compare two semantic versions
+compare_versions() {
+    version1=$1
+    version2=$2
+
+    # Split version numbers into variables
+    IFS='.' set -- $version1
+    ver1_maj=$1
+    ver1_min=${2:-0}
+    ver1_pat=${3:-0}
+
+    IFS='.' set -- $version2
+    ver2_maj=$1
+    ver2_min=${2:-0}
+    ver2_pat=${3:-0}
+
+    # Compare major versions
+    if [ "$ver1_maj" -lt "$ver2_maj" ]; then
+        echo -1
+        return
+    elif [ "$ver1_maj" -gt "$ver2_maj" ]; then
+        echo 1
+        return
+    fi
+
+    # Compare minor versions
+    if [ "$ver1_min" -lt "$ver2_min" ]; then
+        echo -1
+        return
+    elif [ "$ver1_min" -gt "$ver2_min" ]; then
+        echo 1
+        return
+    fi
+
+    # Compare patch versions
+    if [ "$ver1_pat" -lt "$ver2_pat" ]; then
+        echo -1
+        return
+    elif [ "$ver1_pat" -gt "$ver2_pat" ]; then
+        echo 1
+        return
+    fi
+
+    # Versions are equal
+    echo 0
+}
+
 SIMULATIONS_FORMAT=%s
 SIMULATIONS_DIR_PATH=%s
 TEMP_SIMULATIONS_DIR_PATH=%s
@@ -73,7 +120,12 @@ fi
 if [ ${SIMULATIONS_FORMAT} = "bundle" ]; then
   gatling.sh -sf ${SIMULATIONS_DIR_PATH} -s ${SIMULATION_CLASS} -rsf ${RESOURCES_DIR_PATH} -rf ${RESULTS_DIR_PATH} %s %s
 elif [ ${SIMULATIONS_FORMAT} = "gradle" ]; then
-  gradle -Dgatling.core.directory.results=${RESULTS_DIR_PATH} gatlingRun-${SIMULATION_CLASS} 
+  gatling_ver=$(gradle buildEnvironment | grep 'gatling-gradle-plugin:' | sed -n 's/.*:gatling-gradle-plugin:\(.*\)$/\1/p')
+  if [ compare_versions "${gatling_ver}" "3.10" -le 0 ]; then
+    gradle -Dgatling.core.directory.results=${RESULTS_DIR_PATH} gatlingRun-${SIMULATION_CLASS} 
+  else
+    gradle -Dgatling.core.directory.results=${RESULTS_DIR_PATH} --simulation=${SIMULATION_CLASS}
+  fi
 fi
 
 GATLING_EXIT_STATUS=$?

@annappropriate
Copy link
Author

Hi @kane8n, I just got around to this.
Unfortunately, I am struggling to test because I can't get it to work.
I tried both locally, and via dev containers, and no matter which command I run (e.g. make build or make install-crd), I get the same error message both on master and with your patch:

root@gatling-operator-dev-container:/workspaces/gatling-operator# make build
/workspaces/gatling-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x9d57cf]

goroutine 144 [running]:
go/types.(*Checker).handleBailout(0xc0002de200, 0xc000053d40)
        /usr/lib/go/src/go/types/check.go:367 +0x88
panic({0xb91320?, 0x1245830?})
        /usr/lib/go/src/runtime/panic.go:770 +0x132
go/types.(*StdSizes).Sizeof(0x0, {0xd74168, 0x124de60})
        /usr/lib/go/src/go/types/sizes.go:228 +0x30f
go/types.(*Config).sizeof(...)
        /usr/lib/go/src/go/types/sizes.go:333
go/types.representableConst.func1({0xd74168?, 0x124de60?})
        /usr/lib/go/src/go/types/const.go:76 +0x9e
go/types.representableConst({0xd7a580, 0x121a7e0}, 0xc0002de200, 0x124de60, 0x0)
        /usr/lib/go/src/go/types/const.go:92 +0x192
go/types.(*Checker).arrayLength(0xc0002de200, {0xd787b8, 0xc001bb7f00?})
        /usr/lib/go/src/go/types/typexpr.go:510 +0x2d3
go/types.(*Checker).typInternal(0xc0002de200, {0xd76ec8, 0xc001bd5560}, 0x0)
        /usr/lib/go/src/go/types/typexpr.go:299 +0x49d
go/types.(*Checker).definedType(0xc0002de200, {0xd76ec8, 0xc001bd5560}, 0xc000053328?)
        /usr/lib/go/src/go/types/typexpr.go:180 +0x37
go/types.(*Checker).varType(0xc0002de200, {0xd76ec8, 0xc001bd5560})
        /usr/lib/go/src/go/types/typexpr.go:145 +0x25
go/types.(*Checker).structType(0xc0002de200, 0xc001bfec90, 0xc001bfec90?)
        /usr/lib/go/src/go/types/struct.go:113 +0x19f
go/types.(*Checker).typInternal(0xc0002de200, {0xd76e38, 0xc001bb2ae0}, 0xc001e82410)
        /usr/lib/go/src/go/types/typexpr.go:316 +0x1345
go/types.(*Checker).definedType(0xc0002de200, {0xd76e38, 0xc001bb2ae0}, 0xc56387?)
        /usr/lib/go/src/go/types/typexpr.go:180 +0x37
go/types.(*Checker).typeDecl(0xc0002de200, 0xc001e82410, 0xc001be34c0, 0x0)
        /usr/lib/go/src/go/types/decl.go:615 +0x44d
go/types.(*Checker).objDecl(0xc0002de200, {0xd7faa0, 0xc001e82410}, 0x0)
        /usr/lib/go/src/go/types/decl.go:197 +0xa7f
go/types.(*Checker).packageObjects(0xc0002de200)
        /usr/lib/go/src/go/types/resolver.go:681 +0x425
go/types.(*Checker).checkFiles(0xc0002de200, {0xc001a51b00, 0x3, 0x3})
        /usr/lib/go/src/go/types/check.go:408 +0x1a5
go/types.(*Checker).Files(...)
        /usr/lib/go/src/go/types/check.go:372
sigs.k8s.io/controller-tools/pkg/loader.(*loader).typeCheck(0xc0001e94d0, 0xc001a60080)
        /home/anna/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:283 +0x35b
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0xc001a60080)
        /home/anna/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:96 +0x39
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0xc0010a9b30, 0xc001a60080)
        /home/anna/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:263 +0x2b7
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x22?)
        /home/anna/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:257 +0x53
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 130
        /home/anna/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:255 +0x1c5
make: *** [Makefile:68: generate] Error 2

I don't really know what am I doing wrong, as I have followed the build guide.

It would be very nice if you could publish a SNAPSHOT version for testing instead.

@kane8n
Copy link
Contributor

kane8n commented Aug 22, 2024

@annappropriate
Sorry for the late reply.
I think it is because you still have an old version of controller-gen in /workspaces/gatling-operator/bin/.
The tools under /workspaces/gatling-operator/bin/ are installed with go-install-tool defined in the Makefile. Try deleting /workspaces/gatling-operator/bin/ and then running the make command.

@annappropriate
Copy link
Author

Hi @kane8n. I have tried your suggestion to no avail:

in gatling-operator on  gatling-3.11-upgrade 
❯ rm -rf workspaces/gatling-operator/bin/

in gatling-operator on  gatling-3.11-upgrade 
❯ make build
/home/anna/gatling-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x9d57cf]

goroutine 118 [running]:
go/types.(*Checker).handleBailout(0xc000289a00, 0xc0017f9d40)
        /usr/lib/go/src/go/types/check.go:367 +0x88
panic({0xb91320?, 0x1245830?})
        /usr/lib/go/src/runtime/panic.go:770 +0x132
go/types.(*StdSizes).Sizeof(0x0, {0xd74168, 0x124de60})
        /usr/lib/go/src/go/types/sizes.go:228 +0x30f
go/types.(*Config).sizeof(...)
        /usr/lib/go/src/go/types/sizes.go:333
go/types.representableConst.func1({0xd74168?, 0x124de60?})
        /usr/lib/go/src/go/types/const.go:76 +0x9e
go/types.representableConst({0xd7a580, 0x121a7e0}, 0xc000289a00, 0x124de60, 0x0)
        /usr/lib/go/src/go/types/const.go:92 +0x192
go/types.(*Checker).arrayLength(0xc000289a00, {0xd787b8, 0xc001ad4820?})
        /usr/lib/go/src/go/types/typexpr.go:510 +0x2d3
go/types.(*Checker).typInternal(0xc000289a00, {0xd76ec8, 0xc001ac7b00}, 0x0)
        /usr/lib/go/src/go/types/typexpr.go:299 +0x49d
go/types.(*Checker).definedType(0xc000289a00, {0xd76ec8, 0xc001ac7b00}, 0xc0017f9328?)
        /usr/lib/go/src/go/types/typexpr.go:180 +0x37
go/types.(*Checker).varType(0xc000289a00, {0xd76ec8, 0xc001ac7b00})
        /usr/lib/go/src/go/types/typexpr.go:145 +0x25
go/types.(*Checker).structType(0xc000289a00, 0xc0009c0ba0, 0xc0009c0ba0?)
        /usr/lib/go/src/go/types/struct.go:113 +0x19f
go/types.(*Checker).typInternal(0xc000289a00, {0xd76e38, 0xc00115af90}, 0xc0009c30e0)
        /usr/lib/go/src/go/types/typexpr.go:316 +0x1345
go/types.(*Checker).definedType(0xc000289a00, {0xd76e38, 0xc00115af90}, 0xc56387?)
        /usr/lib/go/src/go/types/typexpr.go:180 +0x37
go/types.(*Checker).typeDecl(0xc000289a00, 0xc0009c30e0, 0xc001ac2d40, 0x0)
        /usr/lib/go/src/go/types/decl.go:615 +0x44d
go/types.(*Checker).objDecl(0xc000289a00, {0xd7faa0, 0xc0009c30e0}, 0x0)
        /usr/lib/go/src/go/types/decl.go:197 +0xa7f
go/types.(*Checker).packageObjects(0xc000289a00)
        /usr/lib/go/src/go/types/resolver.go:681 +0x425
go/types.(*Checker).checkFiles(0xc000289a00, {0xc000480600, 0x3, 0x3})
        /usr/lib/go/src/go/types/check.go:408 +0x1a5
go/types.(*Checker).Files(...)
        /usr/lib/go/src/go/types/check.go:372
sigs.k8s.io/controller-tools/pkg/loader.(*loader).typeCheck(0xc0001e54d0, 0xc000763da0)
        /home/anna/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:283 +0x35b
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0xc000763da0)
        /home/anna/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:96 +0x39
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0xc001119b30, 0xc000763da0)
        /home/anna/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:263 +0x2b7
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x45?)
        /home/anna/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:257 +0x53
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 156
        /home/anna/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:255 +0x1c5
make: *** [Makefile:68: generate] Error 2

I really feel like at this point it might be better for you to try your hand at it. Unfortunately, I am completely lost on this, and it might be faster for you to check if you can build it. I would be really happy to test this once there is a build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants