This is an automated email from the ASF dual-hosted git repository.
kichan pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/trafficserver-ingress-controller.git
The following commit(s) were added to refs/heads/master by this push:
new 6c56b85 Crd version update and test update (#309)
6c56b85 is described below
commit 6c56b858c9caf253308ac6e56618c9311654476e
Author: saurabh-saraswat <[email protected]>
AuthorDate: Fri Nov 14 06:21:03 2025 +0530
Crd version update and test update (#309)
* Updated the version for CRD and updated to test to avoid failure due to
late notificaiton from Kubernetes
* updated teardown
* Added comment
* Added missing for caching deployment
* Added caching-app. Updated lua code to consider caching.
* Delete k8s/images/caching-app/node_modules directory
* Update pluginats/connect_redis.lua
Co-authored-by: Copilot <[email protected]>
* Update pluginats/connect_redis.lua
Co-authored-by: Copilot <[email protected]>
* Update tests/suite/test_ingress.py
Co-authored-by: Copilot <[email protected]>
* Update pluginats/connect_redis_test.lua
Co-authored-by: Copilot <[email protected]>
* Update tests/suite/test_ingress.py
Co-authored-by: Copilot <[email protected]>
* Update tests/data/caching-app/cache-test.yaml
Co-authored-by: Copilot <[email protected]>
* Update tests/suite/test_ingress.py
Corrected file path
Co-authored-by: Copilot <[email protected]>
* Update ats_caching/atscachingpolicy.yaml
Used correct namespace.
Co-authored-by: Copilot <[email protected]>
* Updated path of files for ats_caching
* Update k8s/images/caching-app/package.json
Co-authored-by: Copilot <[email protected]>
---------
Co-authored-by: Kit Chan <[email protected]>
Co-authored-by: Copilot <[email protected]>
---
.github/workflows/build.yml | 5 +
ats_caching/atscachingpolicy.yaml | 16 +-
ats_caching/crd-atscachingpolicy.yaml | 3 +-
k8s/images/caching-app/.dockerignore | 3 +
k8s/images/caching-app/Dockerfile | 30 ++
k8s/images/caching-app/hello-updated.html | 15 +
k8s/images/caching-app/hello.html | 15 +
k8s/images/caching-app/package-lock.json | 715 ++++++++++++++++++++++++++++++
k8s/images/caching-app/package.json | 15 +
k8s/images/caching-app/server.js | 33 ++
pluginats/connect_redis.lua | 37 +-
pluginats/connect_redis_test.lua | 52 ++-
tests/data/caching-app/cache-test.yaml | 69 +++
tests/suite/test_ingress.py | 42 +-
watcher/handlerCache_test.go | 2 +-
watcher/watcher.go | 2 +-
watcher/watcher_test.go | 18 +-
17 files changed, 1022 insertions(+), 50 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index adb2df6..87e6551 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -59,6 +59,11 @@ jobs:
eval $(minikube -p minikube docker-env)
docker build -t node-app-2 k8s/images/node-app-2/
+ - name: Build Caching App
+ run: |
+ eval $(minikube -p minikube docker-env)
+ docker build -t caching-app k8s/images/caching-app/
+
- name: Install dependencies
run: |
cd tests
diff --git a/ats_caching/atscachingpolicy.yaml
b/ats_caching/atscachingpolicy.yaml
index f2b65e1..29e2db4 100644
--- a/ats_caching/atscachingpolicy.yaml
+++ b/ats_caching/atscachingpolicy.yaml
@@ -1,19 +1,19 @@
-apiVersion: k8s.trafficserver.apache.com/v1
+apiVersion: k8s.trafficserver.apache.com/v1alpha1
kind: ATSCachingPolicy
metadata:
name: my-app-caching
- namespace: trafficserver-test
+ namespace: cache-test-ns
spec:
rules:
- - name: home-endpoint
+ - name: static-assets
primarySpecifier:
type: url_regex
- pattern: ".*/app1"
+ pattern: "^/app2"
action: cache
- ttl: "12s"
- - name: static-assets
+ ttl: "23s"
+ - name: cache-endpoint
primarySpecifier:
type: url_regex
- pattern: "^/app2"
+ pattern: ".*/cache-test"
action: cache
- ttl: "20s"
+ ttl: "12s"
diff --git a/ats_caching/crd-atscachingpolicy.yaml
b/ats_caching/crd-atscachingpolicy.yaml
index 5ef1f17..8401aa9 100644
--- a/ats_caching/crd-atscachingpolicy.yaml
+++ b/ats_caching/crd-atscachingpolicy.yaml
@@ -12,7 +12,7 @@ spec:
shortNames:
- atscp
versions:
- - name: v1
+ - name: v1alpha1
served: true
storage: true
schema:
@@ -65,4 +65,3 @@ spec:
ttl:
type: string
description: Cache time to live (e.g., "10s", "1h")
-
diff --git a/k8s/images/caching-app/.dockerignore
b/k8s/images/caching-app/.dockerignore
new file mode 100644
index 0000000..29d6828
--- /dev/null
+++ b/k8s/images/caching-app/.dockerignore
@@ -0,0 +1,3 @@
+node_modules
+npm-debug.log
+
diff --git a/k8s/images/caching-app/Dockerfile
b/k8s/images/caching-app/Dockerfile
new file mode 100644
index 0000000..5e3ab97
--- /dev/null
+++ b/k8s/images/caching-app/Dockerfile
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
+FROM node:8
+
+WORKDIR /usr/src/app
+
+COPY package*.json ./
+
+RUN npm install
+
+COPY . .
+
+EXPOSE 8080
+
+CMD ["npm", "start"]
+
diff --git a/k8s/images/caching-app/hello-updated.html
b/k8s/images/caching-app/hello-updated.html
new file mode 100644
index 0000000..e473499
--- /dev/null
+++ b/k8s/images/caching-app/hello-updated.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<HTML>
+
+<HEAD>
+ <TITLE>
+ Hello from cache-test - Request to path /app2
+ </TITLE>
+</HEAD>
+
+<BODY>
+ <H1>Hi</H1>
+ <P>This is very minimal "hello world" HTML document.</P>
+</BODY>
+
+</HTML>
diff --git a/k8s/images/caching-app/hello.html
b/k8s/images/caching-app/hello.html
new file mode 100644
index 0000000..783e1e2
--- /dev/null
+++ b/k8s/images/caching-app/hello.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<HTML>
+
+<HEAD>
+ <TITLE>
+ Hello from cache-test
+ </TITLE>
+</HEAD>
+
+<BODY>
+ <H1>Hi</H1>
+ <P>This is very minimal "hello world" HTML document.</P>
+</BODY>
+
+</HTML>
diff --git a/k8s/images/caching-app/package-lock.json
b/k8s/images/caching-app/package-lock.json
new file mode 100644
index 0000000..948d9c2
--- /dev/null
+++ b/k8s/images/caching-app/package-lock.json
@@ -0,0 +1,715 @@
+{
+ "name": "dockernode",
+ "version": "1.0.0",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "dockernode",
+ "version": "1.0.0",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "express": "^4.21.2"
+ }
+ },
+ "node_modules/accepts": {
+ "version": "1.3.8",
+ "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
+ "integrity":
"sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
+ "dependencies": {
+ "mime-types": "~2.1.34",
+ "negotiator": "0.6.3"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/array-flatten": {
+ "version": "1.1.1",
+ "resolved":
"https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
+ "integrity":
"sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
+ },
+ "node_modules/body-parser": {
+ "version": "1.20.3",
+ "resolved":
"https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz",
+ "integrity":
"sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==",
+ "dependencies": {
+ "bytes": "3.1.2",
+ "content-type": "~1.0.5",
+ "debug": "2.6.9",
+ "depd": "2.0.0",
+ "destroy": "1.2.0",
+ "http-errors": "2.0.0",
+ "iconv-lite": "0.4.24",
+ "on-finished": "2.4.1",
+ "qs": "6.13.0",
+ "raw-body": "2.5.2",
+ "type-is": "~1.6.18",
+ "unpipe": "1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8",
+ "npm": "1.2.8000 || >= 1.4.16"
+ }
+ },
+ "node_modules/bytes": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
+ "integrity":
"sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/call-bind": {
+ "version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz",
+ "integrity":
"sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==",
+ "dependencies": {
+ "es-define-property": "^1.0.0",
+ "es-errors": "^1.3.0",
+ "function-bind": "^1.1.2",
+ "get-intrinsic": "^1.2.4",
+ "set-function-length": "^1.2.1"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/content-disposition": {
+ "version": "0.5.4",
+ "resolved":
"https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
+ "integrity":
"sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
+ "dependencies": {
+ "safe-buffer": "5.2.1"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/content-type": {
+ "version": "1.0.5",
+ "resolved":
"https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
+ "integrity":
"sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/cookie": {
+ "version": "0.7.1",
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz",
+ "integrity":
"sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/cookie-signature": {
+ "version": "1.0.6",
+ "resolved":
"https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
+ "integrity":
"sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
+ },
+ "node_modules/debug": {
+ "version": "2.6.9",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
+ "integrity":
"sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+ "dependencies": {
+ "ms": "2.0.0"
+ }
+ },
+ "node_modules/define-data-property": {
+ "version": "1.1.4",
+ "resolved":
"https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
+ "integrity":
"sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
+ "dependencies": {
+ "es-define-property": "^1.0.0",
+ "es-errors": "^1.3.0",
+ "gopd": "^1.0.1"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/depd": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
+ "integrity":
"sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/destroy": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
+ "integrity":
"sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
+ "engines": {
+ "node": ">= 0.8",
+ "npm": "1.2.8000 || >= 1.4.16"
+ }
+ },
+ "node_modules/ee-first": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
+ "integrity":
"sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
+ },
+ "node_modules/encodeurl": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
+ "integrity":
"sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/es-define-property": {
+ "version": "1.0.0",
+ "resolved":
"https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
+ "integrity":
"sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
+ "dependencies": {
+ "get-intrinsic": "^1.2.4"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/es-errors": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
+ "integrity":
"sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/escape-html": {
+ "version": "1.0.3",
+ "resolved":
"https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
+ "integrity":
"sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="
+ },
+ "node_modules/etag": {
+ "version": "1.8.1",
+ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
+ "integrity":
"sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/express": {
+ "version": "4.21.2",
+ "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz",
+ "integrity":
"sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==",
+ "dependencies": {
+ "accepts": "~1.3.8",
+ "array-flatten": "1.1.1",
+ "body-parser": "1.20.3",
+ "content-disposition": "0.5.4",
+ "content-type": "~1.0.4",
+ "cookie": "0.7.1",
+ "cookie-signature": "1.0.6",
+ "debug": "2.6.9",
+ "depd": "2.0.0",
+ "encodeurl": "~2.0.0",
+ "escape-html": "~1.0.3",
+ "etag": "~1.8.1",
+ "finalhandler": "1.3.1",
+ "fresh": "0.5.2",
+ "http-errors": "2.0.0",
+ "merge-descriptors": "1.0.3",
+ "methods": "~1.1.2",
+ "on-finished": "2.4.1",
+ "parseurl": "~1.3.3",
+ "path-to-regexp": "0.1.12",
+ "proxy-addr": "~2.0.7",
+ "qs": "6.13.0",
+ "range-parser": "~1.2.1",
+ "safe-buffer": "5.2.1",
+ "send": "0.19.0",
+ "serve-static": "1.16.2",
+ "setprototypeof": "1.2.0",
+ "statuses": "2.0.1",
+ "type-is": "~1.6.18",
+ "utils-merge": "1.0.1",
+ "vary": "~1.1.2"
+ },
+ "engines": {
+ "node": ">= 0.10.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/finalhandler": {
+ "version": "1.3.1",
+ "resolved":
"https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz",
+ "integrity":
"sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==",
+ "dependencies": {
+ "debug": "2.6.9",
+ "encodeurl": "~2.0.0",
+ "escape-html": "~1.0.3",
+ "on-finished": "2.4.1",
+ "parseurl": "~1.3.3",
+ "statuses": "2.0.1",
+ "unpipe": "~1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/forwarded": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
+ "integrity":
"sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/fresh": {
+ "version": "0.5.2",
+ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
+ "integrity":
"sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/function-bind": {
+ "version": "1.1.2",
+ "resolved":
"https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
+ "integrity":
"sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/get-intrinsic": {
+ "version": "1.2.4",
+ "resolved":
"https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
+ "integrity":
"sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
+ "dependencies": {
+ "es-errors": "^1.3.0",
+ "function-bind": "^1.1.2",
+ "has-proto": "^1.0.1",
+ "has-symbols": "^1.0.3",
+ "hasown": "^2.0.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/gopd": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
+ "integrity":
"sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/has-property-descriptors": {
+ "version": "1.0.2",
+ "resolved":
"https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
+ "integrity":
"sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
+ "dependencies": {
+ "es-define-property": "^1.0.0"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/has-proto": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.1.0.tgz",
+ "integrity":
"sha512-QLdzI9IIO1Jg7f9GT1gXpPpXArAn6cS31R1eEZqz08Gc+uQ8/XiqHWt17Fiw+2p6oTTIq5GXEpQkAlA88YRl/Q==",
+ "dependencies": {
+ "call-bind": "^1.0.7"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/has-symbols": {
+ "version": "1.1.0",
+ "resolved":
"https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
+ "integrity":
"sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/hasown": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
+ "integrity":
"sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
+ "dependencies": {
+ "function-bind": "^1.1.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/http-errors": {
+ "version": "2.0.0",
+ "resolved":
"https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
+ "integrity":
"sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
+ "dependencies": {
+ "depd": "2.0.0",
+ "inherits": "2.0.4",
+ "setprototypeof": "1.2.0",
+ "statuses": "2.0.1",
+ "toidentifier": "1.0.1"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/iconv-lite": {
+ "version": "0.4.24",
+ "resolved":
"https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
+ "integrity":
"sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
+ "dependencies": {
+ "safer-buffer": ">= 2.1.2 < 3"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/inherits": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+ "integrity":
"sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
+ },
+ "node_modules/ipaddr.js": {
+ "version": "1.9.1",
+ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
+ "integrity":
"sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
+ "node_modules/media-typer": {
+ "version": "0.3.0",
+ "resolved":
"https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
+ "integrity":
"sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/merge-descriptors": {
+ "version": "1.0.3",
+ "resolved":
"https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
+ "integrity":
"sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/methods": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
+ "integrity":
"sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/mime": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
+ "integrity":
"sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
+ "bin": {
+ "mime": "cli.js"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
+ "node_modules/mime-db": {
+ "version": "1.52.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
+ "integrity":
"sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/mime-types": {
+ "version": "2.1.35",
+ "resolved":
"https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
+ "integrity":
"sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
+ "dependencies": {
+ "mime-db": "1.52.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/ms": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity":
"sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
+ },
+ "node_modules/negotiator": {
+ "version": "0.6.3",
+ "resolved":
"https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
+ "integrity":
"sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/object-inspect": {
+ "version": "1.13.3",
+ "resolved":
"https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.3.tgz",
+ "integrity":
"sha512-kDCGIbxkDSXE3euJZZXzc6to7fCrKHNI/hSRQnRuQ+BWjFNzZwiFF8fj/6o2t2G9/jTj8PSIYTfCLelLZEeRpA==",
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/on-finished": {
+ "version": "2.4.1",
+ "resolved":
"https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
+ "integrity":
"sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
+ "dependencies": {
+ "ee-first": "1.1.1"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/parseurl": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
+ "integrity":
"sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/path-to-regexp": {
+ "version": "0.1.12",
+ "resolved":
"https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
+ "integrity":
"sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ=="
+ },
+ "node_modules/proxy-addr": {
+ "version": "2.0.7",
+ "resolved":
"https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
+ "integrity":
"sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
+ "dependencies": {
+ "forwarded": "0.2.0",
+ "ipaddr.js": "1.9.1"
+ },
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
+ "node_modules/qs": {
+ "version": "6.13.0",
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz",
+ "integrity":
"sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==",
+ "dependencies": {
+ "side-channel": "^1.0.6"
+ },
+ "engines": {
+ "node": ">=0.6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/range-parser": {
+ "version": "1.2.1",
+ "resolved":
"https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
+ "integrity":
"sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/raw-body": {
+ "version": "2.5.2",
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
+ "integrity":
"sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
+ "dependencies": {
+ "bytes": "3.1.2",
+ "http-errors": "2.0.0",
+ "iconv-lite": "0.4.24",
+ "unpipe": "1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/safe-buffer": {
+ "version": "5.2.1",
+ "resolved":
"https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
+ "integrity":
"sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/feross"
+ },
+ {
+ "type": "patreon",
+ "url": "https://www.patreon.com/feross"
+ },
+ {
+ "type": "consulting",
+ "url": "https://feross.org/support"
+ }
+ ]
+ },
+ "node_modules/safer-buffer": {
+ "version": "2.1.2",
+ "resolved":
"https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
+ "integrity":
"sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
+ },
+ "node_modules/send": {
+ "version": "0.19.0",
+ "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz",
+ "integrity":
"sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==",
+ "dependencies": {
+ "debug": "2.6.9",
+ "depd": "2.0.0",
+ "destroy": "1.2.0",
+ "encodeurl": "~1.0.2",
+ "escape-html": "~1.0.3",
+ "etag": "~1.8.1",
+ "fresh": "0.5.2",
+ "http-errors": "2.0.0",
+ "mime": "1.6.0",
+ "ms": "2.1.3",
+ "on-finished": "2.4.1",
+ "range-parser": "~1.2.1",
+ "statuses": "2.0.1"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/send/node_modules/encodeurl": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
+ "integrity":
"sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/send/node_modules/ms": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
+ "integrity":
"sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
+ },
+ "node_modules/serve-static": {
+ "version": "1.16.2",
+ "resolved":
"https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz",
+ "integrity":
"sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==",
+ "dependencies": {
+ "encodeurl": "~2.0.0",
+ "escape-html": "~1.0.3",
+ "parseurl": "~1.3.3",
+ "send": "0.19.0"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/set-function-length": {
+ "version": "1.2.2",
+ "resolved":
"https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
+ "integrity":
"sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==",
+ "dependencies": {
+ "define-data-property": "^1.1.4",
+ "es-errors": "^1.3.0",
+ "function-bind": "^1.1.2",
+ "get-intrinsic": "^1.2.4",
+ "gopd": "^1.0.1",
+ "has-property-descriptors": "^1.0.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/setprototypeof": {
+ "version": "1.2.0",
+ "resolved":
"https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
+ "integrity":
"sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
+ },
+ "node_modules/side-channel": {
+ "version": "1.0.6",
+ "resolved":
"https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz",
+ "integrity":
"sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==",
+ "dependencies": {
+ "call-bind": "^1.0.7",
+ "es-errors": "^1.3.0",
+ "get-intrinsic": "^1.2.4",
+ "object-inspect": "^1.13.1"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/statuses": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
+ "integrity":
"sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/toidentifier": {
+ "version": "1.0.1",
+ "resolved":
"https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
+ "integrity":
"sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
+ "engines": {
+ "node": ">=0.6"
+ }
+ },
+ "node_modules/type-is": {
+ "version": "1.6.18",
+ "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
+ "integrity":
"sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
+ "dependencies": {
+ "media-typer": "0.3.0",
+ "mime-types": "~2.1.24"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/unpipe": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
+ "integrity":
"sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/utils-merge": {
+ "version": "1.0.1",
+ "resolved":
"https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
+ "integrity":
"sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
+ "engines": {
+ "node": ">= 0.4.0"
+ }
+ },
+ "node_modules/vary": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
+ "integrity":
"sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ }
+ }
+}
diff --git a/k8s/images/caching-app/package.json
b/k8s/images/caching-app/package.json
new file mode 100644
index 0000000..1fb41ae
--- /dev/null
+++ b/k8s/images/caching-app/package.json
@@ -0,0 +1,15 @@
+{
+ "name": "dockernode",
+ "version": "1.0.0",
+ "description": "docker-ize a very simple express.js app",
+ "main": "server.js",
+ "scripts": {
+ "start": "node server.js",
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "author": "Apache Software Foundation",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "express": "^4.21.2"
+ }
+}
diff --git a/k8s/images/caching-app/server.js b/k8s/images/caching-app/server.js
new file mode 100644
index 0000000..0938868
--- /dev/null
+++ b/k8s/images/caching-app/server.js
@@ -0,0 +1,33 @@
+// 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.
+
+'use strict';
+
+const express = require('express');
+
+// Constants
+const PORT = 8080;
+const HOST = '0.0.0.0';
+
+// App
+const app = express();
+app.get('/', (req, res) => {
+ res.send('Hello world\n');
+});
+
+app.get('/cache-test', (req, res) => { // lgtm[js/missing-rate-limiting]
+ res.sendFile('hello.html', {root: __dirname });
+})
+
+
+app.listen(PORT, HOST);
+console.log(`Running on http://${HOST}:${PORT}`);
diff --git a/pluginats/connect_redis.lua b/pluginats/connect_redis.lua
index 16dbdcd..29d4262 100644
--- a/pluginats/connect_redis.lua
+++ b/pluginats/connect_redis.lua
@@ -104,7 +104,17 @@ function get_wildcard_domain(req_host)
return "*" .. string.sub (req_host, pos)
end
----------------------------------------------
+function cache_lookup()
+ local cache = ts.http.get_cache_lookup_url()
+
+ if (cache == nil or #cache == 0) then
+ ts.debug("Cache lookup is empty")
+ else
+ ts.debug("Cache lookup using the get cache lookup url " .. cache)
+ end
+
+end
+
----------------- DO_REMAP ------------------
---------------------------------------------
function do_global_read_request()
@@ -116,13 +126,24 @@ function do_global_read_request()
ts.debug("In 'not response: '", response)
return 0
end
-
+
-- We only care about host, path, and port#
local req_scheme = ts.client_request.get_url_scheme() or 'http'
local req_host = ts.client_request.get_url_host() or ''
local req_path = ts.client_request.get_uri() or ''
local req_port = ts.client_request.get_url_port() or ''
-
+
+ -- Checking the http version
+ local ver = ts.client_request.get_version()
+ ts.debug("Requested http version is: " .. ver)
+ if (ver == "1.1" and req_scheme == "http") then
+ ts.client_request.set_url_host(req_host)
+ ts.debug("Host for http version 1.1 is: " .. req_host)
+ end
+ -- ts.client_request.set_url_host(req_host)
+ -- Extracting original url
+ local url = ts.client_request.get_pristine_url()
+ ts.debug("Pristine url is: " .. url)
local wildcard_req_host = get_wildcard_domain(req_host)
ts.debug("-----Request-----")
ts.debug("req_scheme: "..req_scheme)
@@ -131,7 +152,8 @@ function do_global_read_request()
ts.debug("req_path: " .. req_path)
ts.debug("wildcard_req_host: " .. (wildcard_req_host or 'invalid domain
name'))
ts.debug("-----------------")
-
+ ts.hook(TS_LUA_HOOK_CACHE_LOOKUP_COMPLETE, cache_lookup)
+
-- check for path exact match
local svcs = check_path_exact_match(req_scheme, req_host, req_path)
@@ -186,12 +208,17 @@ function do_global_read_request()
ts.error("Redis Lookup Failure: wrong format - "..ipport)
return 0
end
+
+ -- Setting up cache key
+ ts.debug("setting up the cache url key using the set_cache_url " .. url)
+ ts.http.set_cache_url(url)
ts.http.skip_remapping_set(1)
ts.client_request.set_url_scheme(values[3])
ts.client_request.set_uri(req_path)
ts.client_request.set_url_host(values[1])
ts.client_request.set_url_port(values[2])
+
end
end
@@ -216,7 +243,7 @@ function do_global_read_request()
ts.error("Redis Lookup Failure: snippet == nil for hostpath")
return 0
end
-
+ ts.debug("Snippet in the Connect Redis lua file " .. snippet)
local f = loadstring(snippet)
f()
end
diff --git a/pluginats/connect_redis_test.lua b/pluginats/connect_redis_test.lua
index f785486..d8e7316 100644
--- a/pluginats/connect_redis_test.lua
+++ b/pluginats/connect_redis_test.lua
@@ -112,7 +112,7 @@ describe("Unit tests - Lua", function()
client:select(0)
client:sadd("trafficserver-test-2:appsvc1:8080","172.17.0.3#8080#http","172.17.0.5#8080#http")
--require 'pl.pretty'.dump(client)
-
+
stub(ts, "add_package_cpath")
stub(ts, "add_package_path")
stub(ts, "debug")
@@ -123,8 +123,54 @@ describe("Unit tests - Lua", function()
stub(ts.client_request, "set_uri")
stub(ts.http, "skip_remapping_set")
stub(ts.http, "set_resp")
+
+ -- calling get_version on client request
+ stub(ts.client_request, "get_version").returns("1.1")
+
+ -- calling get_pristine_url on client request
+ stub(ts.client_request,
"get_pristine_url").returns("http://test.edge.com/app1")
+
+ -- Used for setting the cache url
+ stub(ts.http, "set_cache_url")
+
+ _G.TS_LUA_HOOK_SEND_RESPONSE_HDR = "TS_LUA_HOOK_SEND_RESPONSE_HDR"
+ stub(ts, "hook")
end)
+ -- Test - Verify caching for Http/1.1 -------------------------
+
+ it("Test - Verify caching for Http/1.1", function()
+ require("connect_redis")
+ local result = do_global_read_request()
+
+ -- Verifies the HTTP version check and host set for 1.1
+ assert.stub(ts.client_request.get_version).was.called()
+
assert.stub(ts.client_request.set_url_host).was.called_with("test.edge.com")
+
+ -- Verifies that pristine URL is used to set up cache
+
assert.stub(ts.http.set_cache_url).was.called_with("http://test.edge.com/app1")
+ end)
+
+ -- Test - Verify caching for Http/2.0 -------------------
+
+ it("Test - Verify caching for Http/2.0", function()
+ -- Clear cached module first
+ package.loaded["connect_redis"] = nil
+
+ -- Re-stub get_version to return "2" before requiring
+ stub(ts.client_request, "get_version").returns("2.0")
+
+ -- Reload module
+ require("connect_redis")
+
+ -- Execute target function
+ do_global_read_request()
+
+ -- Assertions
+ assert.stub(ts.client_request.get_version).was.called()
+
assert.stub(ts.http.set_cache_url).was.called_with("http://test.edge.com/app1")
+ end)
+
it("Test - Redirect to correct IP", function()
require("connect_redis")
local result = do_global_read_request()
@@ -139,7 +185,7 @@ describe("Unit tests - Lua", function()
client:sadd("E+http://test.edge.com/app1","$trafficserver-test-3/app-ingress/411990")
snippet = "ts.debug('Debug msg example')\nts.error('Error msg
example')\n-- ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, function()\n--
ts.client_response.header['Location'] = 'https://test.edge.com/app2'\n--
end)\nts.http.skip_remapping_set(0)\nts.http.set_resp(301,
'Redirect')\nts.debug('Uncomment the above lines to redirect http request to
https')\nts.debug('Modification for testing')\n"
client:sadd("$trafficserver-test-3/app-ingress/411990",snippet)
-
+
--require 'pl.pretty'.dump(client)
require "connect_redis"
local input_args = {"snippet"}
@@ -151,5 +197,7 @@ describe("Unit tests - Lua", function()
assert.stub(ts.http.set_resp).was.called_with(301,"Redirect")
end)
+
end)
end)
+
diff --git a/tests/data/caching-app/cache-test.yaml
b/tests/data/caching-app/cache-test.yaml
new file mode 100644
index 0000000..3982a99
--- /dev/null
+++ b/tests/data/caching-app/cache-test.yaml
@@ -0,0 +1,69 @@
+
+apiVersion: v1
+kind: Namespace
+metadata:
+ name: cache-test-ns
+---
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: cache-test
+ namespace: cache-test-ns
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: cache-test
+ template:
+ metadata:
+ labels:
+ app: cache-test
+ spec:
+ containers:
+ - name: cache-test
+ image: caching-app:latest
+ imagePullPolicy: IfNotPresent
+ env:
+ - name: AUTHOR
+ value: cache-test
+ ports:
+ - containerPort: 8080
+ name: http
+ protocol: TCP
+
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: cachingsvc
+ namespace: cache-test-ns
+spec:
+ ports:
+ - port: 8080
+ name: "cachingsvchttp"
+ protocol: TCP
+ targetPort: 8080
+
+ selector:
+ app: cache-test
+
+---
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+ name: app-ingress
+ namespace: cache-test-ns
+spec:
+ #ingressClassName: ats
+ rules:
+ - host: test.media.com
+ http:
+ paths:
+ - path: /cache-test
+ pathType: Exact
+ backend:
+ service:
+ name: cachingsvc
+ port:
+ number: 8080
diff --git a/tests/suite/test_ingress.py b/tests/suite/test_ingress.py
index d0d19b3..7c63fec 100644
--- a/tests/suite/test_ingress.py
+++ b/tests/suite/test_ingress.py
@@ -37,16 +37,22 @@ def misc_command(command):
def setup_module(module):
misc_command('openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048
-keyout tls.key -out tls.crt -subj "/CN=atssvc/O=atssvc"')
+
kubectl_create('namespace trafficserver-test')
kubectl_create('secret tls tls-secret --key tls.key --cert tls.crt -n
trafficserver-test --dry-run=client -o yaml | kubectl apply -f -')
kubectl_apply('data/setup/configmaps/')
kubectl_apply('data/setup/traffic-server/')
kubectl_apply('data/setup/apps/')
kubectl_apply('data/setup/ingresses/')
- time.sleep(90)
+
+ #Applying here as it takes some time for controller to get notification
from kubernetes.
kubectl_apply('../ats_caching/ats-cachingpolicy-role.yaml')
kubectl_apply('../ats_caching/ats-cachingpolicy-binding.yaml')
- time.sleep(5)
+ kubectl_apply('../ats_caching/crd-atscachingpolicy.yaml')
+ kubectl_apply('../ats_caching/atscachingpolicy.yaml')
+ kubectl_apply('data/caching-app/')
+
+ time.sleep(90)
misc_command('kubectl get all -A')
misc_command('kubectl get pod -A -o wide')
misc_command('kubectl logs $(kubectl get pod -n trafficserver-test-2 -o
name | head -1) -n trafficserver-test-2')
@@ -62,10 +68,14 @@ def setup_module(module):
# misc_command('kubectl exec $(kubectl get pod -n trafficserver-test -o
name) -n trafficserver-test -- curl -v $(kubectl get service/appsvc2 -n
trafficserver-test-2 -o jsonpath={.spec.clusterIP}):8080/app1')
def teardown_module(module):
+
+ kubectl_delete('crd atscachingpolicies.k8s.trafficserver.apache.com')
+ kubectl_delete('-f ../ats_caching/ats-cachingpolicy-role.yaml')
+ kubectl_delete('-f ../ats_caching/ats-cachingpolicy-binding.yaml')
kubectl_delete('namespace trafficserver-test-3')
kubectl_delete('namespace trafficserver-test-2')
kubectl_delete('namespace trafficserver-test')
-
+ kubectl_delete('namespace cache-test-ns')
def get_expected_response_app1():
resp = """<!DOCTYPE html>
<HTML>
@@ -168,11 +178,7 @@ class TestIngress:
assert ' '.join(resp.text.split()) == get_expected_response_app2()
def test_cache_app1(self, minikubeip):
- kubectl_apply('../ats_caching/crd-atscachingpolicy.yaml')
- kubectl_apply('../ats_caching/atscachingpolicy.yaml')
- time.sleep(15)
-
- command = f'curl -i -v -H "Host: test.media.com"
http://{minikubeip}:30080/app1'
+ command = f'curl -i -v -H "Host: test.media.com"
http://{minikubeip}:30080/cache-test'
response_1 = subprocess.run(command, shell=True, capture_output=True,
text=True)
response1 = response_1.stdout.strip()
response1_list = response1.split('\n')
@@ -185,7 +191,6 @@ class TestIngress:
response_2 = subprocess.run(command, shell=True, capture_output=True,
text=True)
response2 = response_2.stdout.strip()
response2_list = response2.split('\n')
- kubectl_delete('crd atscachingpolicies.k8s.trafficserver.apache.com')
for resp in response2_list:
if resp.__contains__("Age"):
age2 = resp
@@ -194,11 +199,10 @@ class TestIngress:
assert mod_time1 == mod_time2 and age1 != age2, "Expected Date
provided by both responses to be same and the Age mentioned in second response
to be more than 0"
def test_cache_app1_beyond_ttl(self, minikubeip):
- kubectl_apply('../ats_caching/crd-atscachingpolicy.yaml')
- kubectl_apply('../ats_caching/atscachingpolicy.yaml')
- time.sleep(15)
+ # waiting for cache from previous test case to expire
+ time.sleep(13)
- command = f'curl -i -v -H "Host: test.media.com"
http://{minikubeip}:30080/app1'
+ command = f'curl -i -v -H "Host: test.media.com"
http://{minikubeip}:30080/cache-test'
response_1 = subprocess.run(command, shell=True, capture_output=True,
text=True)
response1 = response_1.stdout.strip()
response1_list = response1.split('\n')
@@ -216,15 +220,11 @@ class TestIngress:
age2 = resp
if resp.__contains__("Date"):
mod_time2 = resp
- kubectl_delete('crd atscachingpolicies.k8s.trafficserver.apache.com')
expected_age = "Age: 0"
- assert mod_time1 != mod_time2 and age1 == age2 and age2 ==
expected_age, "Expected Date provided by both responses to be different and the
Age mentioned in both responses to be 0"
+ assert mod_time1 != mod_time2 and age1 == age2 and age2 ==
expected_age, "Expected Date provided by both responses should be different and
the Age mentioned in both responses should be 0"
def test_cache_app2(self, minikubeip):
- kubectl_apply('../ats_caching/crd-atscachingpolicy.yaml')
- kubectl_apply('../ats_caching/atscachingpolicy.yaml')
- time.sleep(15)
-
+ # here caching will not work because url will not match with
information in caching crd
command = f'curl -i -v -H "Host: test.edge.com"
http://{minikubeip}:30080/app2'
response_1 = subprocess.run(command, shell=True, capture_output=True,
text=True)
response1 = response_1.stdout.strip()
@@ -243,7 +243,6 @@ class TestIngress:
age2 = resp
if resp.__contains__("Date"):
mod_time2 = resp
- kubectl_delete('crd atscachingpolicies.k8s.trafficserver.apache.com')
assert mod_time1 != mod_time2 and age1 == age2, "Expected Date
provided by both the responses to be different and the Age to be 0 in both the
responses"
@@ -285,4 +284,5 @@ class TestIngress:
assert resp.status_code == 301,\
f"Expected: 301 response code for test_snippet_edge_app2"
assert resp.headers['Location'] == 'https://test.edge.com/app2'
-
+
+
diff --git a/watcher/handlerCache_test.go b/watcher/handlerCache_test.go
index 496cbdb..44e83e5 100644
--- a/watcher/handlerCache_test.go
+++ b/watcher/handlerCache_test.go
@@ -37,7 +37,7 @@ func newTestHandler(t *testing.T) (*AtsCacheHandler, string) {
func newCachingPolicy(name string, rules []interface{})
*unstructured.Unstructured {
u := &unstructured.Unstructured{
Object: map[string]interface{}{
- "apiVersion": "example.com/v1",
+ "apiVersion": "example.com/v1alpha1",
"kind": "ATSCachingPolicy",
"metadata": map[string]interface{}{
"name": name,
diff --git a/watcher/watcher.go b/watcher/watcher.go
index a64d504..1c1b956 100644
--- a/watcher/watcher.go
+++ b/watcher/watcher.go
@@ -172,7 +172,7 @@ func (w *Watcher) inNamespacesWatchFor(h EventHandler, c
cache.Getter,
}
func (w *Watcher) WatchAtsCachingPolicy(path string) error {
- gvr := schema.GroupVersionResource{Group:
"k8s.trafficserver.apache.com", Version: "v1", Resource: "atscachingpolicies"}
+ gvr := schema.GroupVersionResource{Group:
"k8s.trafficserver.apache.com", Version: "v1alpha1", Resource:
"atscachingpolicies"}
dynamicFactory :=
dynamicinformer.NewFilteredDynamicSharedInformerFactory(w.DynamicClient,
w.ResyncPeriod, metav1.NamespaceAll, nil)
informer := dynamicFactory.ForResource(gvr).Informer()
cachehandler := NewAtsCacheHandler("atscaching", w.Ep, path)
diff --git a/watcher/watcher_test.go b/watcher/watcher_test.go
index 173a714..0e8ebf9 100644
--- a/watcher/watcher_test.go
+++ b/watcher/watcher_test.go
@@ -21,8 +21,6 @@ import (
framework "k8s.io/client-go/tools/cache/testing"
)
-// --- Existing endpoint/configmap/endpoint-watcher tests left intact ---
-
func TestAllNamespacesWatchFor_Add(t *testing.T) {
w, fc := getTestWatcher()
@@ -397,7 +395,7 @@ func getTestWatcherForCache() (Watcher,
*framework.FakeControllerSource) {
gvr := schema.GroupVersionResource{
Group: "k8s.trafficserver.apache.com",
- Version: "v1",
+ Version: "v1alpha1",
Resource: "atscachingpolicies",
}
@@ -411,7 +409,7 @@ func getTestWatcherForCache() (Watcher,
*framework.FakeControllerSource) {
clientset := fake.NewSimpleClientset()
fc := framework.NewFakeControllerSource()
- exampleEndpoint := createExampleEndpointWithFakeATS()
+ exampleEndpoint := createExampleEndpointWithFakeATSCache()
stopChan := make(chan struct{})
ingressWatcher := Watcher{
@@ -456,7 +454,7 @@ func TestWatchAtsCachingPolicy_Add(t *testing.T) {
gvr := schema.GroupVersionResource{
Group: "k8s.trafficserver.apache.com",
- Version: "v1",
+ Version: "v1alpha1",
Resource: "atscachingpolicies",
}
dynClient := w.DynamicClient.Resource(gvr).Namespace("default")
@@ -464,7 +462,7 @@ func TestWatchAtsCachingPolicy_Add(t *testing.T) {
// Create a new caching policy
policy := &unstructured.Unstructured{
Object: map[string]interface{}{
- "apiVersion": "k8s.trafficserver.apache.com/v1",
+ "apiVersion": "k8s.trafficserver.apache.com/v1alpha1",
"kind": "ATSCachingPolicy",
"metadata": map[string]interface{}{
"name": "policy-add",
@@ -509,7 +507,7 @@ func TestWatchAtsCachingPolicy_Update(t *testing.T) {
gvr := schema.GroupVersionResource{
Group: "k8s.trafficserver.apache.com",
- Version: "v1",
+ Version: "v1alpha1",
Resource: "atscachingpolicies",
}
dynClient := w.DynamicClient.Resource(gvr).Namespace("default")
@@ -517,7 +515,7 @@ func TestWatchAtsCachingPolicy_Update(t *testing.T) {
// Create a policy first
policy := &unstructured.Unstructured{
Object: map[string]interface{}{
- "apiVersion": "k8s.trafficserver.apache.com/v1",
+ "apiVersion": "k8s.trafficserver.apache.com/v1alpha1",
"kind": "ATSCachingPolicy",
"metadata": map[string]interface{}{
"name": "policy-update",
@@ -577,7 +575,7 @@ func TestWatchAtsCachingPolicy_Delete(t *testing.T) {
gvr := schema.GroupVersionResource{
Group: "k8s.trafficserver.apache.com",
- Version: "v1",
+ Version: "v1alpha1",
Resource: "atscachingpolicies",
}
dynClient := w.DynamicClient.Resource(gvr).Namespace("default")
@@ -585,7 +583,7 @@ func TestWatchAtsCachingPolicy_Delete(t *testing.T) {
// Create a policy first
policy := &unstructured.Unstructured{
Object: map[string]interface{}{
- "apiVersion": "k8s.trafficserver.apache.com/v1",
+ "apiVersion": "k8s.trafficserver.apache.com/v1alpha1",
"kind": "ATSCachingPolicy",
"metadata": map[string]interface{}{
"name": "policy-delete",