Skip to content

Commit

Permalink
Update tag 4.27.0-20241127 in docs and files
Browse files Browse the repository at this point in the history
  • Loading branch information
selenium-ci committed Nov 27, 2024
1 parent 4e20283 commit c5e10a7
Show file tree
Hide file tree
Showing 28 changed files with 239 additions and 231 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ body:
attributes:
label: Docker Selenium version (image tag)
description: What version of Docker Selenium are you using?
placeholder: 4.26.0-20241101? Please use the full tag, avoid "latest"
placeholder: 4.27.0-20241127? Please use the full tag, avoid "latest"
validations:
required: true
- type: input
Expand Down
12 changes: 6 additions & 6 deletions .keda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ The stable implementation will be merged to the upstream KEDA repository frequen
Replace the image registry and tag of these KEDA components with the patched image tag:

```bash
docker pull selenium/keda:2.15.1-selenium-grid-20241101
docker pull selenium/keda-metrics-apiserver:2.15.1-selenium-grid-20241101
docker pull selenium/keda-admission-webhooks:2.15.1-selenium-grid-20241101
docker pull selenium/keda:2.16.0-selenium-grid-20241127
docker pull selenium/keda-metrics-apiserver:2.16.0-selenium-grid-20241127
docker pull selenium/keda-admission-webhooks:2.16.0-selenium-grid-20241127
```

Besides that, you also can use image tag `latest` or `nightly`.
Expand All @@ -27,15 +27,15 @@ If you are deploying KEDA core using their official Helm [chart](https://github.
keda:
registry: selenium
repository: keda
tag: "2.15.1-selenium-grid-20241101"
tag: "2.16.0-selenium-grid-20241127"
metricsApiServer:
registry: selenium
repository: keda-metrics-apiserver
tag: "2.15.1-selenium-grid-20241101"
tag: "2.16.0-selenium-grid-20241127"
webhooks:
registry: selenium
repository: keda-admission-webhooks
tag: "2.15.1-selenium-grid-20241101"
tag: "2.16.0-selenium-grid-20241127"
```
If you are deployment Selenium Grid chart with `autoscaling.enabled` is `true` (implies installing KEDA sub-chart), KEDA images registry and tag already set in the `values.yaml`. Refer to list [configuration](../charts/selenium-grid/CONFIGURATION.md).
Expand Down
43 changes: 24 additions & 19 deletions .keda/scalers/selenium-grid-scaler.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,25 @@ triggers:
**Parameter list:**
- `url` - Graphql url of your Selenium Grid (Required). Refer to the Selenium Grid's documentation [here](https://www.selenium.dev/documentation/en/grid/grid_4/graphql_support/) to for more info. If endpoint requires authentication, you can use `TriggerAuthentication` to provide the credentials instead of embedding in the URL.
- `browserName` - Name of browser that usually gets passed in the browser capability (Required). Refer to the [Selenium Grid's](https://www.selenium.dev/documentation/en/getting_started_with_webdriver/browsers/) and [WebdriverIO's](https://webdriver.io/docs/options/#capabilities) documentation for more info.
- `url` - Graphql url of your Selenium Grid. Refer to the Selenium Grid's documentation [here](https://www.selenium.dev/documentation/en/grid/grid_4/graphql_support/) to for more info. If endpoint requires authentication, you can use `TriggerAuthentication` to provide the credentials instead of embedding in the URL.
- `browserName` - Name of browser that usually gets passed in the browser capability. Refer to the [Selenium Grid's](https://www.selenium.dev/documentation/en/getting_started_with_webdriver/browsers/) and [WebdriverIO's](https://webdriver.io/docs/options/#capabilities) documentation for more info.
- `sessionBrowserName` - Name of the browser when it is an active session, only set if `BrowserName` changes between the queue and the active session. See the Edge example below for further detail. (Optional)
- `browserVersion` - Version of browser that usually gets passed in the browser capability. Refer to the [Selenium Grid's](https://www.selenium.dev/documentation/en/getting_started_with_webdriver/browsers/) and [WebdriverIO's](https://webdriver.io/docs/options/#capabilities) documentation for more info. (Optional)
- `unsafeSsl` - Skip certificate validation when connecting over HTTPS. (Values: `true`, `false`, Default: `false`, Optional)
- `activationThreshold` - Target value for activating the scaler. Learn more about activation [here](./../concepts/scaling-deployments.md#activating-and-scaling-thresholds). (Default: `0`, Optional)
- `platformName` - Name of the browser platform. Refer to the [Selenium Grid's](https://www.selenium.dev/documentation/en/getting_started_with_webdriver/browsers/) and [WebdriverIO's](https://webdriver.io/docs/options/#capabilities) documentation for more info. (Default: `Linux`, Optional)
- `nodeMaxSessions` - Number of maximum sessions that can run in parallel on a Node. (Default: `1`, Optional). Update this parameter align with node config `--max-sessions` (`SE_NODE_MAX_SESSIONS`) to have the correct scaling behavior.
- `nodeMaxSessions` - Number of maximum sessions that can run in parallel on a Node. Update this parameter align with node config `--max-sessions` (`SE_NODE_MAX_SESSIONS`) to have the correct scaling behavior. (Default: `1`, Optional).
- `targetQueueLength` - The target number of queued sessions to scale on. (Default: `1`, Optional).

**Trigger Authentication**
- `username` - Username for basic authentication in GraphQL endpoint instead of embedding in the URL. (Optional)
- `password` - Password for basic authentication in GraphQL endpoint instead of embedding in the URL. (Optional)
- `authType` - Type of authentication to be used. (Optional). This can be set to `Bearer` or `OAuth2` in case Selenium Grid behind an Ingress proxy with other authentication types.
- `accessToken` - Access token (Optional). This is required when `authType` is set a value.
- `authType` - Type of authentication to be used. This can be set to `Bearer` or `OAuth2` in case Selenium Grid behind an Ingress proxy with other authentication types. (Optional)
- `accessToken` - Access token. This is required when `authType` is set a value. (Optional)

### How does it work?

The scaler will query the Hub GraphQL response to get the number of queued sessions in the specified combination of browser name, version, and platform. If the number of queued sessions is **equal to or greater than** the `targetQueueLength`, the scaler will scale up.

### Example

Expand All @@ -55,11 +60,11 @@ metadata:
name: selenium-grid-chrome-scaledobject
namespace: keda
labels:
deploymentName: selenium-node-chrome
deploymentName: selenium-chrome-node
spec:
maxReplicaCount: 8
scaleTargetRef:
name: selenium-node-chrome
name: selenium-chrome-node
triggers:
- type: selenium-grid
metadata:
Expand All @@ -78,11 +83,11 @@ metadata:
name: selenium-grid-firefox-scaledobject
namespace: keda
labels:
deploymentName: selenium-node-firefox
deploymentName: selenium-firefox-node
spec:
maxReplicaCount: 8
scaleTargetRef:
name: selenium-node-firefox
name: selenium-firefox-node
triggers:
- type: selenium-grid
metadata:
Expand All @@ -99,11 +104,11 @@ metadata:
name: selenium-grid-edge-scaledobject
namespace: keda
labels:
deploymentName: selenium-node-edge
deploymentName: selenium-edge-node
spec:
maxReplicaCount: 8
scaleTargetRef:
name: selenium-node-edge
name: selenium-edge-node
triggers:
- type: selenium-grid
metadata:
Expand All @@ -121,11 +126,11 @@ metadata:
name: selenium-grid-chrome-scaledobject
namespace: keda
labels:
deploymentName: selenium-node-chrome
deploymentName: selenium-chrome-node
spec:
maxReplicaCount: 8
scaleTargetRef:
name: selenium-node-chrome
name: selenium-chrome-node
triggers:
- type: selenium-grid
metadata:
Expand All @@ -143,11 +148,11 @@ metadata:
name: selenium-grid-chrome-91-scaledobject
namespace: keda
labels:
deploymentName: selenium-node-chrome-91
deploymentName: selenium-chrome-node-91
spec:
maxReplicaCount: 8
scaleTargetRef:
name: selenium-node-chrome-91
name: selenium-chrome-node-91
triggers:
- type: selenium-grid
metadata:
Expand All @@ -163,11 +168,11 @@ metadata:
name: selenium-grid-chrome-90-scaledobject
namespace: keda
labels:
deploymentName: selenium-node-chrome-90
deploymentName: selenium-chrome-node-90
spec:
maxReplicaCount: 8
scaleTargetRef:
name: selenium-node-chrome-90
name: selenium-chrome-node-90
triggers:
- type: selenium-grid
metadata:
Expand Down Expand Up @@ -219,11 +224,11 @@ metadata:
name: selenium-grid-chrome-scaledobject
namespace: keda
labels:
deploymentName: selenium-node-chrome
deploymentName: selenium-chrome-node
spec:
maxReplicaCount: 8
scaleTargetRef:
name: selenium-node-chrome
name: selenium-chrome-node
triggers:
- type: selenium-grid
metadata:
Expand Down
35 changes: 19 additions & 16 deletions .keda/scalers/selenium_grid_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ type seleniumGridScalerMetadata struct {
BrowserName string `keda:"name=browserName, order=triggerMetadata"`
SessionBrowserName string `keda:"name=sessionBrowserName, order=triggerMetadata, optional"`
ActivationThreshold int64 `keda:"name=activationThreshold, order=triggerMetadata, optional"`
BrowserVersion string `keda:"name=browserVersion, order=triggerMetadata, optional, default=latest"`
UnsafeSsl bool `keda:"name=unsafeSsl, order=triggerMetadata, optional, default=false"`
PlatformName string `keda:"name=platformName, order=triggerMetadata, optional, default=linux"`
NodeMaxSessions int `keda:"name=nodeMaxSessions, order=triggerMetadata, optional, default=1"`

TargetValue int64
BrowserVersion string `keda:"name=browserVersion, order=triggerMetadata, default=latest"`
UnsafeSsl bool `keda:"name=unsafeSsl, order=triggerMetadata, default=false"`
PlatformName string `keda:"name=platformName, order=triggerMetadata, default=linux"`
NodeMaxSessions int `keda:"name=nodeMaxSessions, order=triggerMetadata, default=1"`
TargetQueueLength int64 `keda:"name=targetQueueLength, order=triggerMetadata;resolvedEnv, default=1"`
}

type SeleniumResponse struct {
Expand Down Expand Up @@ -107,7 +106,8 @@ type Stereotypes []struct {
}

const (
DefaultBrowserVersion string = "latest"
DefaultBrowserVersion string = "latest"
DefaultTargetQueueLength int64 = 1
)

func NewSeleniumGridScaler(config *scalersconfig.ScalerConfig) (Scaler, error) {
Expand Down Expand Up @@ -135,9 +135,7 @@ func NewSeleniumGridScaler(config *scalersconfig.ScalerConfig) (Scaler, error) {
}

func parseSeleniumGridScalerMetadata(config *scalersconfig.ScalerConfig) (*seleniumGridScalerMetadata, error) {
meta := &seleniumGridScalerMetadata{
TargetValue: 1,
}
meta := &seleniumGridScalerMetadata{}

if err := config.TypedConfig(meta); err != nil {
return nil, fmt.Errorf("error parsing prometheus metadata: %w", err)
Expand All @@ -148,6 +146,10 @@ func parseSeleniumGridScalerMetadata(config *scalersconfig.ScalerConfig) (*selen
if meta.SessionBrowserName == "" {
meta.SessionBrowserName = meta.BrowserName
}

if meta.TargetQueueLength < 1 {
meta.TargetQueueLength = DefaultTargetQueueLength
}
return meta, nil
}

Expand All @@ -160,31 +162,32 @@ func (s *seleniumGridScaler) Close(context.Context) error {
}

func (s *seleniumGridScaler) GetMetricsAndActivity(ctx context.Context, metricName string) ([]external_metrics.ExternalMetricValue, bool, error) {
sessions, err := s.getSessionsCount(ctx, s.logger)
queueLen, err := s.getSessionsQueueLength(ctx, s.logger)
if err != nil {
return []external_metrics.ExternalMetricValue{}, false, fmt.Errorf("error requesting selenium grid endpoint: %w", err)
}

metric := GenerateMetricInMili(metricName, float64(sessions))
metric := GenerateMetricInMili(metricName, float64(queueLen))

return []external_metrics.ExternalMetricValue{metric}, sessions > s.metadata.ActivationThreshold, nil
// If the number of sessions queued is equal to or greater than the targetQueueLength, the scaler will scale up.
return []external_metrics.ExternalMetricValue{metric}, queueLen >= s.metadata.TargetQueueLength, nil
}

func (s *seleniumGridScaler) GetMetricSpecForScaling(context.Context) []v2.MetricSpec {
metricName := kedautil.NormalizeString(fmt.Sprintf("seleniumgrid-%s", s.metadata.BrowserName))
metricName := kedautil.NormalizeString(fmt.Sprintf("selenium-grid-%s-%s-%s", s.metadata.BrowserName, s.metadata.BrowserVersion, s.metadata.PlatformName))
externalMetric := &v2.ExternalMetricSource{
Metric: v2.MetricIdentifier{
Name: GenerateMetricNameWithIndex(s.metadata.triggerIndex, metricName),
},
Target: GetMetricTarget(s.metricType, s.metadata.TargetValue),
Target: GetMetricTarget(s.metricType, s.metadata.TargetQueueLength),
}
metricSpec := v2.MetricSpec{
External: externalMetric, Type: externalMetricType,
}
return []v2.MetricSpec{metricSpec}
}

func (s *seleniumGridScaler) getSessionsCount(ctx context.Context, logger logr.Logger) (int64, error) {
func (s *seleniumGridScaler) getSessionsQueueLength(ctx context.Context, logger logr.Logger) (int64, error) {
body, err := json.Marshal(map[string]string{
"query": "{ grid { sessionCount, maxSession, totalSlots }, nodesInfo { nodes { id, status, sessionCount, maxSession, slotCount, stereotypes, sessions { id, capabilities, slot { id, stereotype } } } }, sessionsInfo { sessionQueueRequests } }",
})
Expand Down
24 changes: 12 additions & 12 deletions .keda/scalers/selenium_grid_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
URL: "http://selenium-hub:4444/graphql",
BrowserName: "chrome",
SessionBrowserName: "chrome",
TargetValue: 1,
TargetQueueLength: 1,
BrowserVersion: "latest",
PlatformName: "linux",
NodeMaxSessions: 1,
Expand All @@ -1772,7 +1772,7 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
URL: "http://selenium-hub:4444/graphql",
BrowserName: "MicrosoftEdge",
SessionBrowserName: "msedge",
TargetValue: 1,
TargetQueueLength: 1,
BrowserVersion: "latest",
PlatformName: "linux",
NodeMaxSessions: 1,
Expand Down Expand Up @@ -1800,7 +1800,7 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
Password: "password",
BrowserName: "MicrosoftEdge",
SessionBrowserName: "msedge",
TargetValue: 1,
TargetQueueLength: 1,
BrowserVersion: "latest",
PlatformName: "linux",
NodeMaxSessions: 1,
Expand All @@ -1826,7 +1826,7 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
URL: "http://selenium-hub:4444/graphql",
BrowserName: "MicrosoftEdge",
SessionBrowserName: "msedge",
TargetValue: 1,
TargetQueueLength: 1,
BrowserVersion: "latest",
PlatformName: "linux",
Username: "username",
Expand All @@ -1851,7 +1851,7 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
URL: "http://selenium-hub:4444/graphql",
BrowserName: "chrome",
SessionBrowserName: "chrome",
TargetValue: 1,
TargetQueueLength: 1,
BrowserVersion: "91.0",
UnsafeSsl: false,
PlatformName: "linux",
Expand All @@ -1876,7 +1876,7 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
URL: "http://selenium-hub:4444/graphql",
BrowserName: "chrome",
SessionBrowserName: "chrome",
TargetValue: 1,
TargetQueueLength: 1,
ActivationThreshold: 10,
BrowserVersion: "91.0",
UnsafeSsl: true,
Expand Down Expand Up @@ -1917,7 +1917,7 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
URL: "http://selenium-hub:4444/graphql",
BrowserName: "chrome",
SessionBrowserName: "chrome",
TargetValue: 1,
TargetQueueLength: 1,
ActivationThreshold: 10,
BrowserVersion: "91.0",
UnsafeSsl: true,
Expand All @@ -1944,7 +1944,7 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
URL: "http://selenium-hub:4444/graphql",
BrowserName: "chrome",
SessionBrowserName: "chrome",
TargetValue: 1,
TargetQueueLength: 1,
ActivationThreshold: 10,
BrowserVersion: "91.0",
UnsafeSsl: true,
Expand Down Expand Up @@ -1978,7 +1978,7 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
Password: "password",
BrowserName: "chrome",
SessionBrowserName: "chrome",
TargetValue: 1,
TargetQueueLength: 1,
ActivationThreshold: 10,
BrowserVersion: "91.0",
UnsafeSsl: true,
Expand Down Expand Up @@ -2013,7 +2013,7 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
Password: "password",
BrowserName: "chrome",
SessionBrowserName: "chrome",
TargetValue: 1,
TargetQueueLength: 1,
ActivationThreshold: 10,
BrowserVersion: "91.0",
UnsafeSsl: true,
Expand Down Expand Up @@ -2048,7 +2048,7 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
AccessToken: "my-access-token",
BrowserName: "chrome",
SessionBrowserName: "chrome",
TargetValue: 1,
TargetQueueLength: 1,
ActivationThreshold: 10,
BrowserVersion: "91.0",
UnsafeSsl: true,
Expand Down Expand Up @@ -2082,7 +2082,7 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
AccessToken: "my-access-token",
BrowserName: "chrome",
SessionBrowserName: "chrome",
TargetValue: 1,
TargetQueueLength: 1,
ActivationThreshold: 10,
BrowserVersion: "91.0",
UnsafeSsl: true,
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ PLATFORMS := $(or $(PLATFORMS),$(shell echo $$PLATFORMS),$(CURRENT_PLATFORM))
SEL_PASSWD := $(or $(SEL_PASSWD),$(SEL_PASSWD),secret)
CHROMIUM_VERSION := $(or $(CHROMIUM_VERSION),$(CHROMIUM_VERSION),latest)
SBOM_OUTPUT := $(or $(SBOM_OUTPUT),$(SBOM_OUTPUT),package_versions.txt)
KEDA_TAG_PREV_VERSION := $(or $(KEDA_TAG_PREV_VERSION),$(KEDA_TAG_PREV_VERSION),2.15.1-selenium-grid)
KEDA_TAG_PREV_VERSION := $(or $(KEDA_TAG_PREV_VERSION),$(KEDA_TAG_PREV_VERSION),2.16.0-selenium-grid)
KEDA_TAG_VERSION := $(or $(KEDA_TAG_VERSION),$(KEDA_TAG_VERSION),2.16.0-selenium-grid)
KEDA_BASED_NAME := $(or $(KEDA_BASED_NAME),$(KEDA_BASED_NAME),ndviet)
KEDA_BASED_TAG := $(or $(KEDA_BASED_TAG),$(KEDA_BASED_TAG),2.16.0-selenium-grid-20241127)
Expand Down
8 changes: 4 additions & 4 deletions NodeDocker/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Configs have a mapping between the Docker image to use and the capabilities that need to be matched to
# start a container with the given image.
configs = [
"selenium/standalone-firefox:4.26.0-20241101", '{"browserName": "firefox", "platformName": "linux"}',
"selenium/standalone-chrome:4.26.0-20241101", '{"browserName": "chrome", "platformName": "linux"}',
"selenium/standalone-edge:4.26.0-20241101", '{"browserName": "MicrosoftEdge", "platformName": "linux"}'
"selenium/standalone-firefox:4.27.0-20241127", '{"browserName": "firefox", "platformName": "linux"}',
"selenium/standalone-chrome:4.27.0-20241127", '{"browserName": "chrome", "platformName": "linux"}',
"selenium/standalone-edge:4.27.0-20241127", '{"browserName": "MicrosoftEdge", "platformName": "linux"}'
]

# URL for connecting to the docker daemon
Expand All @@ -14,7 +14,7 @@ configs = [
# socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock
url = "http://127.0.0.1:2375"
# Docker image used for video recording
video-image = "selenium/video:ffmpeg-7.1-20241101"
video-image = "selenium/video:ffmpeg-7.1-20241127"

# Uncomment the following section if you are running the node on a separate VM
# Fill out the placeholders with appropriate values
Expand Down
Loading

0 comments on commit c5e10a7

Please sign in to comment.