mirror of
https://github.com/kubeshark/kubeshark.git
synced 2026-06-06 08:23:19 +00:00
Compare commits
13 Commits
29.0-dev0
...
29.0-dev13
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5af0c5a9e9 | ||
|
|
8217ac3ed0 | ||
|
|
de769131de | ||
|
|
5f8a5a3a29 | ||
|
|
7f4cb6dfd4 | ||
|
|
3b063c3bb5 | ||
|
|
b9f5475e3a | ||
|
|
346e904e77 | ||
|
|
c5471c501b | ||
|
|
1597321e24 | ||
|
|
a3111dee35 | ||
|
|
f37abfff88 | ||
|
|
817c17ad32 |
12
.github/workflows/acceptance_tests.yml
vendored
12
.github/workflows/acceptance_tests.yml
vendored
@@ -22,7 +22,17 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Setup acceptance test
|
- name: Setup acceptance test
|
||||||
run: source ./acceptanceTests/setup.sh
|
run: ./acceptanceTests/setup.sh
|
||||||
|
|
||||||
|
- name: Create k8s users and change context
|
||||||
|
env:
|
||||||
|
USERNAME_UNRESTRICTED: user-with-clusterwide-access
|
||||||
|
USERNAME_RESTRICTED: user-with-restricted-access
|
||||||
|
run: |
|
||||||
|
./acceptanceTests/create_user.sh "${USERNAME_UNRESTRICTED}"
|
||||||
|
./acceptanceTests/create_user.sh "${USERNAME_RESTRICTED}"
|
||||||
|
kubectl apply -f cli/cmd/permissionFiles/permissions-all-namespaces-tap.yaml
|
||||||
|
kubectl config use-context ${USERNAME_UNRESTRICTED}
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: make acceptance-test
|
run: make acceptance-test
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -30,7 +30,7 @@ build
|
|||||||
pprof/*
|
pprof/*
|
||||||
|
|
||||||
# Database Files
|
# Database Files
|
||||||
*.bin
|
*.db
|
||||||
*.gob
|
*.gob
|
||||||
|
|
||||||
# Nohup Files - https://man7.org/linux/man-pages/man1/nohup.1p.html
|
# Nohup Files - https://man7.org/linux/man-pages/man1/nohup.1p.html
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ RUN go build -ldflags="-extldflags=-static -s -w \
|
|||||||
-X 'github.com/up9inc/mizu/agent/pkg/version.Ver=${VER}'" -o mizuagent .
|
-X 'github.com/up9inc/mizu/agent/pkg/version.Ver=${VER}'" -o mizuagent .
|
||||||
|
|
||||||
# Download Basenine executable, verify the sha1sum
|
# Download Basenine executable, verify the sha1sum
|
||||||
ADD https://github.com/up9inc/basenine/releases/download/v0.4.17/basenine_linux_${GOARCH} ./basenine_linux_${GOARCH}
|
ADD https://github.com/up9inc/basenine/releases/download/v0.5.4/basenine_linux_${GOARCH} ./basenine_linux_${GOARCH}
|
||||||
ADD https://github.com/up9inc/basenine/releases/download/v0.4.17/basenine_linux_${GOARCH}.sha256 ./basenine_linux_${GOARCH}.sha256
|
ADD https://github.com/up9inc/basenine/releases/download/v0.5.4/basenine_linux_${GOARCH}.sha256 ./basenine_linux_${GOARCH}.sha256
|
||||||
RUN shasum -a 256 -c basenine_linux_${GOARCH}.sha256
|
RUN shasum -a 256 -c basenine_linux_${GOARCH}.sha256
|
||||||
RUN chmod +x ./basenine_linux_${GOARCH}
|
RUN chmod +x ./basenine_linux_${GOARCH}
|
||||||
RUN mv ./basenine_linux_${GOARCH} ./basenine
|
RUN mv ./basenine_linux_${GOARCH} ./basenine
|
||||||
|
|||||||
7
Makefile
7
Makefile
@@ -31,9 +31,6 @@ cli: ## Build CLI.
|
|||||||
cli-debug: ## Build CLI.
|
cli-debug: ## Build CLI.
|
||||||
@echo "building cli"; cd cli && $(MAKE) build-debug
|
@echo "building cli"; cd cli && $(MAKE) build-debug
|
||||||
|
|
||||||
build-cli-ci: ## Build CLI for CI.
|
|
||||||
@echo "building cli for ci"; cd cli && $(MAKE) build GIT_BRANCH=ci SUFFIX=ci
|
|
||||||
|
|
||||||
agent: ## Build agent.
|
agent: ## Build agent.
|
||||||
@(echo "building mizu agent .." )
|
@(echo "building mizu agent .." )
|
||||||
@(cd agent; go build -o build/mizuagent main.go)
|
@(cd agent; go build -o build/mizuagent main.go)
|
||||||
@@ -57,10 +54,6 @@ push-docker: ## Build and publish agent docker image.
|
|||||||
@echo "publishing Docker image .. "
|
@echo "publishing Docker image .. "
|
||||||
devops/build-push-featurebranch.sh
|
devops/build-push-featurebranch.sh
|
||||||
|
|
||||||
build-docker-ci: ## Build agent docker image for CI.
|
|
||||||
@echo "building docker image for ci"
|
|
||||||
devops/build-agent-ci.sh
|
|
||||||
|
|
||||||
push-cli: ## Build and publish CLI.
|
push-cli: ## Build and publish CLI.
|
||||||
@echo "publishing CLI .. "
|
@echo "publishing CLI .. "
|
||||||
@cd cli; $(MAKE) build-all
|
@cd cli; $(MAKE) build-all
|
||||||
|
|||||||
@@ -23,19 +23,19 @@ func TestConfigRegenerate(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
configPath, configPathErr := getConfigPath()
|
configPath, configPathErr := GetConfigPath()
|
||||||
if configPathErr != nil {
|
if configPathErr != nil {
|
||||||
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
configCmdArgs := getDefaultConfigCommandArgs()
|
configCmdArgs := GetDefaultConfigCommandArgs()
|
||||||
|
|
||||||
configCmdArgs = append(configCmdArgs, "-r")
|
configCmdArgs = append(configCmdArgs, "-r")
|
||||||
|
|
||||||
@@ -74,13 +74,13 @@ func TestConfigGuiPort(t *testing.T) {
|
|||||||
|
|
||||||
for _, guiPort := range tests {
|
for _, guiPort := range tests {
|
||||||
t.Run(fmt.Sprintf("%d", guiPort), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%d", guiPort), func(t *testing.T) {
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
configPath, configPathErr := getConfigPath()
|
configPath, configPathErr := GetConfigPath()
|
||||||
if configPathErr != nil {
|
if configPathErr != nil {
|
||||||
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
@@ -100,16 +100,16 @@ func TestConfigGuiPort(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,9 +123,9 @@ func TestConfigGuiPort(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(guiPort)
|
apiServerUrl := GetApiServerUrl(guiPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -147,13 +147,13 @@ func TestConfigSetGuiPort(t *testing.T) {
|
|||||||
|
|
||||||
for _, guiPortStruct := range tests {
|
for _, guiPortStruct := range tests {
|
||||||
t.Run(fmt.Sprintf("%d", guiPortStruct.SetGuiPort), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%d", guiPortStruct.SetGuiPort), func(t *testing.T) {
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
configPath, configPathErr := getConfigPath()
|
configPath, configPathErr := GetConfigPath()
|
||||||
if configPathErr != nil {
|
if configPathErr != nil {
|
||||||
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
@@ -173,9 +173,9 @@ func TestConfigSetGuiPort(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmdArgs = append(tapCmdArgs, "--set", fmt.Sprintf("tap.gui-port=%v", guiPortStruct.SetGuiPort))
|
tapCmdArgs = append(tapCmdArgs, "--set", fmt.Sprintf("tap.gui-port=%v", guiPortStruct.SetGuiPort))
|
||||||
@@ -184,7 +184,7 @@ func TestConfigSetGuiPort(t *testing.T) {
|
|||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,9 +198,9 @@ func TestConfigSetGuiPort(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(guiPortStruct.SetGuiPort)
|
apiServerUrl := GetApiServerUrl(guiPortStruct.SetGuiPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -222,13 +222,13 @@ func TestConfigFlagGuiPort(t *testing.T) {
|
|||||||
|
|
||||||
for _, guiPortStruct := range tests {
|
for _, guiPortStruct := range tests {
|
||||||
t.Run(fmt.Sprintf("%d", guiPortStruct.FlagGuiPort), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%d", guiPortStruct.FlagGuiPort), func(t *testing.T) {
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
configPath, configPathErr := getConfigPath()
|
configPath, configPathErr := GetConfigPath()
|
||||||
if configPathErr != nil {
|
if configPathErr != nil {
|
||||||
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
t.Errorf("failed to get config path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
@@ -248,9 +248,9 @@ func TestConfigFlagGuiPort(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmdArgs = append(tapCmdArgs, "-p", fmt.Sprintf("%v", guiPortStruct.FlagGuiPort))
|
tapCmdArgs = append(tapCmdArgs, "-p", fmt.Sprintf("%v", guiPortStruct.FlagGuiPort))
|
||||||
@@ -259,7 +259,7 @@ func TestConfigFlagGuiPort(t *testing.T) {
|
|||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,9 +273,9 @@ func TestConfigFlagGuiPort(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(guiPortStruct.FlagGuiPort)
|
apiServerUrl := GetApiServerUrl(guiPortStruct.FlagGuiPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
37
acceptanceTests/create_user.sh
Executable file
37
acceptanceTests/create_user.sh
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Create a user in Minikube cluster "minikube"
|
||||||
|
# Create context for user
|
||||||
|
# Usage:
|
||||||
|
# ./create_user.sh <username>
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
NEW_USERNAME=$1
|
||||||
|
CERT_DIR="${HOME}/certs"
|
||||||
|
KEY_FILE="${CERT_DIR}/${NEW_USERNAME}.key"
|
||||||
|
CRT_FILE="${CERT_DIR}/${NEW_USERNAME}.crt"
|
||||||
|
MINIKUBE_KEY_FILE="${HOME}/.minikube/ca.key"
|
||||||
|
MINIKUBE_CRT_FILE="${HOME}/.minikube/ca.crt"
|
||||||
|
DAYS=1
|
||||||
|
|
||||||
|
echo "Creating user and context for username \"${NEW_USERNAME}\" in Minikube cluster"
|
||||||
|
|
||||||
|
if ! command -v openssl &> /dev/null
|
||||||
|
then
|
||||||
|
echo "Installing openssl"
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install openssl
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Creating certificate for user \"${NEW_USERNAME}\""
|
||||||
|
mkdir -p ${CERT_DIR}
|
||||||
|
echo "Generating key \"${KEY_FILE}\""
|
||||||
|
openssl genrsa -out "${KEY_FILE}" 2048
|
||||||
|
echo "Generating crt \"${CRT_FILE}\""
|
||||||
|
openssl req -new -key "${KEY_FILE}" -out "${CRT_FILE}" -subj "/CN=${NEW_USERNAME}/O=group1"
|
||||||
|
openssl x509 -req -in "${CRT_FILE}" -CA "${MINIKUBE_CRT_FILE}" -CAkey "${MINIKUBE_KEY_FILE}" -CAcreateserial -out "${CRT_FILE}" -days $DAYS
|
||||||
|
|
||||||
|
echo "Creating context for user \"${NEW_USERNAME}\""
|
||||||
|
kubectl config set-credentials "${NEW_USERNAME}" --client-certificate="${CRT_FILE}" --client-key="${KEY_FILE}"
|
||||||
|
kubectl config set-context "${NEW_USERNAME}" --cluster=minikube --user="${NEW_USERNAME}"
|
||||||
@@ -1,15 +1,24 @@
|
|||||||
import {findLineAndCheck, getExpectedDetailsDict} from "../testHelpers/StatusBarHelper";
|
import {findLineAndCheck, getExpectedDetailsDict} from "../testHelpers/StatusBarHelper";
|
||||||
import {
|
import {
|
||||||
|
leftOnHoverCheck,
|
||||||
leftTextCheck,
|
leftTextCheck,
|
||||||
resizeToHugeMizu,
|
resizeToHugeMizu,
|
||||||
resizeToNormalMizu,
|
resizeToNormalMizu,
|
||||||
rightOnHoverCheck,
|
rightOnHoverCheck,
|
||||||
leftOnHoverCheck,
|
|
||||||
rightTextCheck,
|
rightTextCheck,
|
||||||
verifyMinimumEntries
|
verifyMinimumEntries
|
||||||
} from "../testHelpers/TrafficHelper";
|
} from "../testHelpers/TrafficHelper";
|
||||||
|
|
||||||
const refreshWaitTimeout = 10000;
|
const refreshWaitTimeout = 10000;
|
||||||
|
|
||||||
|
|
||||||
|
const fullParam = Cypress.env('arrayDict'); // "Name:fooNamespace:barName:foo1Namespace:bar1"
|
||||||
|
const podsArray = fullParam.split('Name:').slice(1); // ["fooNamespace:bar", "foo1Namespace:bar1"]
|
||||||
|
podsArray.forEach((podStr, index) => {
|
||||||
|
const podAndNamespaceArr = podStr.split('Namespace:'); // [foo, bar] / [foo1, bar1]
|
||||||
|
podsArray[index] = getExpectedDetailsDict(podAndNamespaceArr[0], podAndNamespaceArr[1]);
|
||||||
|
});
|
||||||
|
|
||||||
it('opening mizu', function () {
|
it('opening mizu', function () {
|
||||||
cy.visit(Cypress.env('testUrl'));
|
cy.visit(Cypress.env('testUrl'));
|
||||||
});
|
});
|
||||||
@@ -17,16 +26,13 @@ it('opening mizu', function () {
|
|||||||
verifyMinimumEntries();
|
verifyMinimumEntries();
|
||||||
|
|
||||||
it('top bar check', function () {
|
it('top bar check', function () {
|
||||||
const podName1 = 'httpbin', namespace1 = 'mizu-tests';
|
|
||||||
const podName2 = 'httpbin2', namespace2 = 'mizu-tests';
|
|
||||||
|
|
||||||
cy.get('.podsCount').trigger('mouseover');
|
cy.get('.podsCount').trigger('mouseover');
|
||||||
findLineAndCheck(getExpectedDetailsDict(podName1, namespace1));
|
podsArray.map(findLineAndCheck);
|
||||||
findLineAndCheck(getExpectedDetailsDict(podName2, namespace2));
|
|
||||||
cy.reload();
|
cy.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('filtering guide check', function () {
|
it('filtering guide check', function () {
|
||||||
|
cy.reload();
|
||||||
cy.get('[title="Open Filtering Guide (Cheatsheet)"]').click();
|
cy.get('[title="Open Filtering Guide (Cheatsheet)"]').click();
|
||||||
cy.get('#modal-modal-title').should('be.visible');
|
cy.get('#modal-modal-title').should('be.visible');
|
||||||
cy.get('[lang="en"]').click(0, 0);
|
cy.get('[lang="en"]').click(0, 0);
|
||||||
@@ -64,8 +70,6 @@ it('right side sanity test', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
serviceMapCheck();
|
|
||||||
|
|
||||||
checkIllegalFilter('invalid filter');
|
checkIllegalFilter('invalid filter');
|
||||||
|
|
||||||
checkFilter({
|
checkFilter({
|
||||||
@@ -86,14 +90,27 @@ checkFilter({
|
|||||||
applyByEnter: false
|
applyByEnter: false
|
||||||
});
|
});
|
||||||
|
|
||||||
checkFilter({
|
if (Cypress.env('shouldCheckSrcAndDest')) {
|
||||||
name: 'src.name == ""',
|
serviceMapCheck();
|
||||||
leftSidePath: '[title="Source Name"]',
|
|
||||||
leftSideExpectedText: '[Unresolved]',
|
checkFilter({
|
||||||
rightSidePath: '> :nth-child(2) [title="Source Name"]',
|
name: 'src.name == ""',
|
||||||
rightSideExpectedText: '[Unresolved]',
|
leftSidePath: '[title="Source Name"]',
|
||||||
applyByEnter: false
|
leftSideExpectedText: '[Unresolved]',
|
||||||
});
|
rightSidePath: '> :nth-child(2) [title="Source Name"]',
|
||||||
|
rightSideExpectedText: '[Unresolved]',
|
||||||
|
applyByEnter: false
|
||||||
|
});
|
||||||
|
|
||||||
|
checkFilter({
|
||||||
|
name: `dst.name == "httpbin.mizu-tests"`,
|
||||||
|
leftSidePath: '> :nth-child(3) > :nth-child(2) > :nth-child(3) > :nth-child(2)',
|
||||||
|
leftSideExpectedText: 'httpbin.mizu-tests',
|
||||||
|
rightSidePath: '> :nth-child(2) > :nth-child(2) > :nth-child(2) > :nth-child(3) > :nth-child(2)',
|
||||||
|
rightSideExpectedText: 'httpbin.mizu-tests',
|
||||||
|
applyByEnter: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
checkFilter({
|
checkFilter({
|
||||||
name: 'method == "GET"',
|
name: 'method == "GET"',
|
||||||
@@ -113,15 +130,6 @@ checkFilter({
|
|||||||
applyByEnter: false
|
applyByEnter: false
|
||||||
});
|
});
|
||||||
|
|
||||||
checkFilter({
|
|
||||||
name: 'dst.name == "httpbin.mizu-tests"',
|
|
||||||
leftSidePath: '> :nth-child(3) > :nth-child(2) > :nth-child(3) > :nth-child(2)',
|
|
||||||
leftSideExpectedText: 'httpbin.mizu-tests',
|
|
||||||
rightSidePath: '> :nth-child(2) > :nth-child(2) > :nth-child(2) > :nth-child(3) > :nth-child(2)',
|
|
||||||
rightSideExpectedText: 'httpbin.mizu-tests',
|
|
||||||
applyByEnter: false
|
|
||||||
});
|
|
||||||
|
|
||||||
checkFilter({
|
checkFilter({
|
||||||
name: 'src.ip == "127.0.0.1"',
|
name: 'src.ip == "127.0.0.1"',
|
||||||
leftSidePath: '[title="Source IP"]',
|
leftSidePath: '[title="Source IP"]',
|
||||||
@@ -169,6 +177,7 @@ function shouldNotExist(entryNum) {
|
|||||||
|
|
||||||
function checkIllegalFilter(illegalFilterName) {
|
function checkIllegalFilter(illegalFilterName) {
|
||||||
it(`should show red search bar with the input: ${illegalFilterName}`, function () {
|
it(`should show red search bar with the input: ${illegalFilterName}`, function () {
|
||||||
|
cy.reload();
|
||||||
cy.get('#total-entries').then(number => {
|
cy.get('#total-entries').then(number => {
|
||||||
const totalEntries = number.text();
|
const totalEntries = number.text();
|
||||||
|
|
||||||
|
|||||||
@@ -15,22 +15,22 @@ func TestRedis(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -40,16 +40,22 @@ func TestRedis(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(DefaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
redisExternalIp, err := getServiceExternalIp(ctx, defaultNamespaceName, "redis")
|
kubernetesProvider, err := NewKubernetesProvider()
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("failed to create k8s provider, err %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
redisExternalIp, err := kubernetesProvider.GetServiceExternalIp(ctx, DefaultNamespaceName, "redis")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to get redis external ip, err: %v", err)
|
t.Errorf("failed to get redis external ip, err: %v", err)
|
||||||
return
|
return
|
||||||
@@ -59,7 +65,7 @@ func TestRedis(t *testing.T) {
|
|||||||
Addr: fmt.Sprintf("%v:6379", redisExternalIp),
|
Addr: fmt.Sprintf("%v:6379", redisExternalIp),
|
||||||
})
|
})
|
||||||
|
|
||||||
for i := 0; i < defaultEntriesCount/5; i++ {
|
for i := 0; i < DefaultEntriesCount/5; i++ {
|
||||||
requestErr := rdb.Ping(ctx).Err()
|
requestErr := rdb.Ping(ctx).Err()
|
||||||
if requestErr != nil {
|
if requestErr != nil {
|
||||||
t.Errorf("failed to send redis request, err: %v", requestErr)
|
t.Errorf("failed to send redis request, err: %v", requestErr)
|
||||||
@@ -67,7 +73,7 @@ func TestRedis(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < defaultEntriesCount/5; i++ {
|
for i := 0; i < DefaultEntriesCount/5; i++ {
|
||||||
requestErr := rdb.Set(ctx, "key", "value", -1).Err()
|
requestErr := rdb.Set(ctx, "key", "value", -1).Err()
|
||||||
if requestErr != nil {
|
if requestErr != nil {
|
||||||
t.Errorf("failed to send redis request, err: %v", requestErr)
|
t.Errorf("failed to send redis request, err: %v", requestErr)
|
||||||
@@ -75,7 +81,7 @@ func TestRedis(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < defaultEntriesCount/5; i++ {
|
for i := 0; i < DefaultEntriesCount/5; i++ {
|
||||||
requestErr := rdb.Exists(ctx, "key").Err()
|
requestErr := rdb.Exists(ctx, "key").Err()
|
||||||
if requestErr != nil {
|
if requestErr != nil {
|
||||||
t.Errorf("failed to send redis request, err: %v", requestErr)
|
t.Errorf("failed to send redis request, err: %v", requestErr)
|
||||||
@@ -83,7 +89,7 @@ func TestRedis(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < defaultEntriesCount/5; i++ {
|
for i := 0; i < DefaultEntriesCount/5; i++ {
|
||||||
requestErr := rdb.Get(ctx, "key").Err()
|
requestErr := rdb.Get(ctx, "key").Err()
|
||||||
if requestErr != nil {
|
if requestErr != nil {
|
||||||
t.Errorf("failed to send redis request, err: %v", requestErr)
|
t.Errorf("failed to send redis request, err: %v", requestErr)
|
||||||
@@ -91,7 +97,7 @@ func TestRedis(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < defaultEntriesCount/5; i++ {
|
for i := 0; i < DefaultEntriesCount/5; i++ {
|
||||||
requestErr := rdb.Del(ctx, "key").Err()
|
requestErr := rdb.Del(ctx, "key").Err()
|
||||||
if requestErr != nil {
|
if requestErr != nil {
|
||||||
t.Errorf("failed to send redis request, err: %v", requestErr)
|
t.Errorf("failed to send redis request, err: %v", requestErr)
|
||||||
@@ -99,7 +105,7 @@ func TestRedis(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/Redis.js\"")
|
RunCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/Redis.js\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAmqp(t *testing.T) {
|
func TestAmqp(t *testing.T) {
|
||||||
@@ -107,22 +113,22 @@ func TestAmqp(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -132,16 +138,22 @@ func TestAmqp(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(DefaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
rabbitmqExternalIp, err := getServiceExternalIp(ctx, defaultNamespaceName, "rabbitmq")
|
kubernetesProvider, err := NewKubernetesProvider()
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("failed to create k8s provider, err %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
rabbitmqExternalIp, err := kubernetesProvider.GetServiceExternalIp(ctx, DefaultNamespaceName, "rabbitmq")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to get RabbitMQ external ip, err: %v", err)
|
t.Errorf("failed to get RabbitMQ external ip, err: %v", err)
|
||||||
return
|
return
|
||||||
@@ -157,7 +169,7 @@ func TestAmqp(t *testing.T) {
|
|||||||
// Temporary fix for missing amqp entries
|
// Temporary fix for missing amqp entries
|
||||||
time.Sleep(10 * time.Second)
|
time.Sleep(10 * time.Second)
|
||||||
|
|
||||||
for i := 0; i < defaultEntriesCount/5; i++ {
|
for i := 0; i < DefaultEntriesCount/5; i++ {
|
||||||
ch, err := conn.Channel()
|
ch, err := conn.Channel()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to open a channel, err: %v", err)
|
t.Errorf("failed to open a channel, err: %v", err)
|
||||||
@@ -224,5 +236,5 @@ func TestAmqp(t *testing.T) {
|
|||||||
ch.Close()
|
ch.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/Rabbit.js\"")
|
RunCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/Rabbit.js\"")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,22 +11,22 @@ func TestLogs(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -36,14 +36,14 @@ func TestLogs(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(DefaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logsCmdArgs := getDefaultLogsCommandArgs()
|
logsCmdArgs := GetDefaultLogsCommandArgs()
|
||||||
|
|
||||||
logsCmd := exec.Command(cliPath, logsCmdArgs...)
|
logsCmd := exec.Command(cliPath, logsCmdArgs...)
|
||||||
t.Logf("running command: %v", logsCmd.String())
|
t.Logf("running command: %v", logsCmd.String())
|
||||||
@@ -58,7 +58,7 @@ func TestLogs(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logsPath, logsPathErr := getLogsPath()
|
logsPath, logsPathErr := GetLogsPath()
|
||||||
if logsPathErr != nil {
|
if logsPathErr != nil {
|
||||||
t.Errorf("failed to get logs path, err: %v", logsPathErr)
|
t.Errorf("failed to get logs path, err: %v", logsPathErr)
|
||||||
return
|
return
|
||||||
@@ -112,22 +112,22 @@ func TestLogsPath(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -137,14 +137,14 @@ func TestLogsPath(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(DefaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logsCmdArgs := getDefaultLogsCommandArgs()
|
logsCmdArgs := GetDefaultLogsCommandArgs()
|
||||||
|
|
||||||
logsPath := "../logs.zip"
|
logsPath := "../logs.zip"
|
||||||
logsCmdArgs = append(logsCmdArgs, "-f", logsPath)
|
logsCmdArgs = append(logsCmdArgs, "-f", logsPath)
|
||||||
|
|||||||
10
acceptanceTests/setup.sh
Normal file → Executable file
10
acceptanceTests/setup.sh
Normal file → Executable file
@@ -57,14 +57,14 @@ kubectl expose deployment rabbitmq --type=LoadBalancer --port=5672 -n mizu-tests
|
|||||||
echo "Starting proxy"
|
echo "Starting proxy"
|
||||||
kubectl proxy --port=8080 &
|
kubectl proxy --port=8080 &
|
||||||
|
|
||||||
echo "Starting tunnel"
|
|
||||||
minikube tunnel &
|
|
||||||
|
|
||||||
echo "Setting minikube docker env"
|
echo "Setting minikube docker env"
|
||||||
eval $(minikube docker-env)
|
eval $(minikube docker-env)
|
||||||
|
|
||||||
echo "Build agent image"
|
echo "Build agent image"
|
||||||
make build-docker-ci
|
docker build -t mizu/ci:0.0 .
|
||||||
|
|
||||||
echo "Build cli"
|
echo "Build cli"
|
||||||
make build-cli-ci
|
cd cli && make build GIT_BRANCH=ci SUFFIX=ci
|
||||||
|
|
||||||
|
echo "Starting tunnel"
|
||||||
|
minikube tunnel &
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestTap(t *testing.T) {
|
func TestTap(t *testing.T) {
|
||||||
|
basicTapTest(t, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func basicTapTest(t *testing.T, shouldCheckSrcAndDest bool, extraArgs... string) {
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
@@ -22,22 +26,24 @@ func TestTap(t *testing.T) {
|
|||||||
|
|
||||||
for _, entriesCount := range tests {
|
for _, entriesCount := range tests {
|
||||||
t.Run(fmt.Sprintf("%d", entriesCount), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%d", entriesCount), func(t *testing.T) {
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
|
tapCmdArgs = append(tapCmdArgs, extraArgs...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -47,22 +53,33 @@ func TestTap(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(DefaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyUrl := getProxyUrl(defaultNamespaceName, defaultServiceName)
|
proxyUrl := GetProxyUrl(DefaultNamespaceName, DefaultServiceName)
|
||||||
for i := 0; i < entriesCount; i++ {
|
for i := 0; i < entriesCount; i++ {
|
||||||
if _, requestErr := executeHttpGetRequest(fmt.Sprintf("%v/get", proxyUrl)); requestErr != nil {
|
if _, requestErr := ExecuteHttpGetRequest(fmt.Sprintf("%v/get", proxyUrl)); requestErr != nil {
|
||||||
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/UiTest.js\" --env entriesCount=%d", entriesCount))
|
expectedPods := []PodDescriptor{
|
||||||
|
{Name: "httpbin", Namespace: "mizu-tests"},
|
||||||
|
{Name: "httpbin2", Namespace: "mizu-tests"},
|
||||||
|
}
|
||||||
|
|
||||||
|
var expectedPodsStr string
|
||||||
|
for i := 0; i < len(expectedPods); i++ {
|
||||||
|
expectedPodsStr += fmt.Sprintf("Name:%vNamespace:%v", expectedPods[i].Name, expectedPods[i].Namespace)
|
||||||
|
}
|
||||||
|
|
||||||
|
RunCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/UiTest.js\" --env entriesCount=%d,arrayDict=%v,shouldCheckSrcAndDest=%v",
|
||||||
|
entriesCount, expectedPodsStr, shouldCheckSrcAndDest))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,15 +93,15 @@ func TestTapGuiPort(t *testing.T) {
|
|||||||
|
|
||||||
for _, guiPort := range tests {
|
for _, guiPort := range tests {
|
||||||
t.Run(fmt.Sprintf("%d", guiPort), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%d", guiPort), func(t *testing.T) {
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmdArgs = append(tapCmdArgs, "-p", fmt.Sprintf("%d", guiPort))
|
tapCmdArgs = append(tapCmdArgs, "-p", fmt.Sprintf("%d", guiPort))
|
||||||
@@ -93,7 +110,7 @@ func TestTapGuiPort(t *testing.T) {
|
|||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -103,22 +120,22 @@ func TestTapGuiPort(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(guiPort)
|
apiServerUrl := GetApiServerUrl(guiPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyUrl := getProxyUrl(defaultNamespaceName, defaultServiceName)
|
proxyUrl := GetProxyUrl(DefaultNamespaceName, DefaultServiceName)
|
||||||
for i := 0; i < defaultEntriesCount; i++ {
|
for i := 0; i < DefaultEntriesCount; i++ {
|
||||||
if _, requestErr := executeHttpGetRequest(fmt.Sprintf("%v/get", proxyUrl)); requestErr != nil {
|
if _, requestErr := ExecuteHttpGetRequest(fmt.Sprintf("%v/get", proxyUrl)); requestErr != nil {
|
||||||
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/GuiPort.js\" --env name=%v,namespace=%v,port=%d",
|
RunCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/GuiPort.js\" --env name=%v,namespace=%v,port=%d",
|
||||||
"httpbin", "mizu-tests", guiPort))
|
"httpbin", "mizu-tests", guiPort))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -135,20 +152,20 @@ func TestTapAllNamespaces(t *testing.T) {
|
|||||||
{Name: "httpbin", Namespace: "mizu-tests2"},
|
{Name: "httpbin", Namespace: "mizu-tests2"},
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
tapCmdArgs = append(tapCmdArgs, "-A")
|
tapCmdArgs = append(tapCmdArgs, "-A")
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -158,14 +175,14 @@ func TestTapAllNamespaces(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(DefaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/MultipleNamespaces.js\" --env name1=%v,name2=%v,name3=%v,namespace1=%v,namespace2=%v,namespace3=%v",
|
RunCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/MultipleNamespaces.js\" --env name1=%v,name2=%v,name3=%v,namespace1=%v,namespace2=%v,namespace3=%v",
|
||||||
expectedPods[0].Name, expectedPods[1].Name, expectedPods[2].Name, expectedPods[0].Namespace, expectedPods[1].Namespace, expectedPods[2].Namespace))
|
expectedPods[0].Name, expectedPods[1].Name, expectedPods[2].Name, expectedPods[0].Namespace, expectedPods[1].Namespace, expectedPods[2].Namespace))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,13 +197,13 @@ func TestTapMultipleNamespaces(t *testing.T) {
|
|||||||
{Name: "httpbin", Namespace: "mizu-tests2"},
|
{Name: "httpbin", Namespace: "mizu-tests2"},
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
var namespacesCmd []string
|
var namespacesCmd []string
|
||||||
for _, expectedPod := range expectedPods {
|
for _, expectedPod := range expectedPods {
|
||||||
namespacesCmd = append(namespacesCmd, "-n", expectedPod.Namespace)
|
namespacesCmd = append(namespacesCmd, "-n", expectedPod.Namespace)
|
||||||
@@ -197,7 +214,7 @@ func TestTapMultipleNamespaces(t *testing.T) {
|
|||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -207,14 +224,14 @@ func TestTapMultipleNamespaces(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(DefaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/MultipleNamespaces.js\" --env name1=%v,name2=%v,name3=%v,namespace1=%v,namespace2=%v,namespace3=%v",
|
RunCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/MultipleNamespaces.js\" --env name1=%v,name2=%v,name3=%v,namespace1=%v,namespace2=%v,namespace3=%v",
|
||||||
expectedPods[0].Name, expectedPods[1].Name, expectedPods[2].Name, expectedPods[0].Namespace, expectedPods[1].Namespace, expectedPods[2].Namespace))
|
expectedPods[0].Name, expectedPods[1].Name, expectedPods[2].Name, expectedPods[0].Namespace, expectedPods[1].Namespace, expectedPods[2].Namespace))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,22 +245,22 @@ func TestTapRegex(t *testing.T) {
|
|||||||
{Name: regexPodName, Namespace: "mizu-tests"},
|
{Name: regexPodName, Namespace: "mizu-tests"},
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgsWithRegex(regexPodName)
|
tapCmdArgs := GetDefaultTapCommandArgsWithRegex(regexPodName)
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -253,14 +270,14 @@ func TestTapRegex(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(DefaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/Regex.js\" --env name=%v,namespace=%v",
|
RunCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/Regex.js\" --env name=%v,namespace=%v",
|
||||||
expectedPods[0].Name, expectedPods[0].Namespace))
|
expectedPods[0].Name, expectedPods[0].Namespace))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,15 +286,15 @@ func TestTapDryRun(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmdArgs = append(tapCmdArgs, "--dry-run")
|
tapCmdArgs = append(tapCmdArgs, "--dry-run")
|
||||||
@@ -301,7 +318,7 @@ func TestTapDryRun(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(shortRetriesCount * time.Second)
|
time.Sleep(ShortRetriesCount * time.Second)
|
||||||
resultChannel <- "fail"
|
resultChannel <- "fail"
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -316,22 +333,22 @@ func TestTapRedact(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
tapCmd := exec.Command(cliPath, tapCmdArgs...)
|
||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -341,24 +358,24 @@ func TestTapRedact(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(DefaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyUrl := getProxyUrl(defaultNamespaceName, defaultServiceName)
|
proxyUrl := GetProxyUrl(DefaultNamespaceName, DefaultServiceName)
|
||||||
requestHeaders := map[string]string{"User-Header": "Mizu"}
|
requestHeaders := map[string]string{"User-Header": "Mizu"}
|
||||||
requestBody := map[string]string{"User": "Mizu"}
|
requestBody := map[string]string{"User": "Mizu"}
|
||||||
for i := 0; i < defaultEntriesCount; i++ {
|
for i := 0; i < DefaultEntriesCount; i++ {
|
||||||
if _, requestErr := executeHttpPostRequestWithHeaders(fmt.Sprintf("%v/post", proxyUrl), requestHeaders, requestBody); requestErr != nil {
|
if _, requestErr := ExecuteHttpPostRequestWithHeaders(fmt.Sprintf("%v/post", proxyUrl), requestHeaders, requestBody); requestErr != nil {
|
||||||
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/Redact.js\"")
|
RunCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/Redact.js\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTapNoRedact(t *testing.T) {
|
func TestTapNoRedact(t *testing.T) {
|
||||||
@@ -366,15 +383,15 @@ func TestTapNoRedact(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmdArgs = append(tapCmdArgs, "--no-redact")
|
tapCmdArgs = append(tapCmdArgs, "--no-redact")
|
||||||
@@ -383,7 +400,7 @@ func TestTapNoRedact(t *testing.T) {
|
|||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -393,24 +410,24 @@ func TestTapNoRedact(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(DefaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyUrl := getProxyUrl(defaultNamespaceName, defaultServiceName)
|
proxyUrl := GetProxyUrl(DefaultNamespaceName, DefaultServiceName)
|
||||||
requestHeaders := map[string]string{"User-Header": "Mizu"}
|
requestHeaders := map[string]string{"User-Header": "Mizu"}
|
||||||
requestBody := map[string]string{"User": "Mizu"}
|
requestBody := map[string]string{"User": "Mizu"}
|
||||||
for i := 0; i < defaultEntriesCount; i++ {
|
for i := 0; i < DefaultEntriesCount; i++ {
|
||||||
if _, requestErr := executeHttpPostRequestWithHeaders(fmt.Sprintf("%v/post", proxyUrl), requestHeaders, requestBody); requestErr != nil {
|
if _, requestErr := ExecuteHttpPostRequestWithHeaders(fmt.Sprintf("%v/post", proxyUrl), requestHeaders, requestBody); requestErr != nil {
|
||||||
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/NoRedact.js\"")
|
RunCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/NoRedact.js\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTapRegexMasking(t *testing.T) {
|
func TestTapRegexMasking(t *testing.T) {
|
||||||
@@ -418,15 +435,15 @@ func TestTapRegexMasking(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmdArgs = append(tapCmdArgs, "-r", "Mizu")
|
tapCmdArgs = append(tapCmdArgs, "-r", "Mizu")
|
||||||
@@ -435,7 +452,7 @@ func TestTapRegexMasking(t *testing.T) {
|
|||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -445,23 +462,23 @@ func TestTapRegexMasking(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(DefaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyUrl := getProxyUrl(defaultNamespaceName, defaultServiceName)
|
proxyUrl := GetProxyUrl(DefaultNamespaceName, DefaultServiceName)
|
||||||
for i := 0; i < defaultEntriesCount; i++ {
|
for i := 0; i < DefaultEntriesCount; i++ {
|
||||||
response, requestErr := http.Post(fmt.Sprintf("%v/post", proxyUrl), "text/plain", bytes.NewBufferString("Mizu"))
|
response, requestErr := http.Post(fmt.Sprintf("%v/post", proxyUrl), "text/plain", bytes.NewBufferString("Mizu"))
|
||||||
if _, requestErr = executeHttpRequest(response, requestErr); requestErr != nil {
|
if _, requestErr = ExecuteHttpRequest(response, requestErr); requestErr != nil {
|
||||||
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/RegexMasking.js\"")
|
RunCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/RegexMasking.js\"")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,15 +487,15 @@ func TestTapIgnoredUserAgents(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
ignoredUserAgentValue := "ignore"
|
ignoredUserAgentValue := "ignore"
|
||||||
@@ -488,7 +505,7 @@ func TestTapIgnoredUserAgents(t *testing.T) {
|
|||||||
t.Logf("running command: %v", tapCmd.String())
|
t.Logf("running command: %v", tapCmd.String())
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Logf("failed to cleanup tap command, err: %v", err)
|
t.Logf("failed to cleanup tap command, err: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -498,32 +515,32 @@ func TestTapIgnoredUserAgents(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(DefaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyUrl := getProxyUrl(defaultNamespaceName, defaultServiceName)
|
proxyUrl := GetProxyUrl(DefaultNamespaceName, DefaultServiceName)
|
||||||
|
|
||||||
ignoredUserAgentCustomHeader := "Ignored-User-Agent"
|
ignoredUserAgentCustomHeader := "Ignored-User-Agent"
|
||||||
headers := map[string]string{"User-Agent": ignoredUserAgentValue, ignoredUserAgentCustomHeader: ""}
|
headers := map[string]string{"User-Agent": ignoredUserAgentValue, ignoredUserAgentCustomHeader: ""}
|
||||||
for i := 0; i < defaultEntriesCount; i++ {
|
for i := 0; i < DefaultEntriesCount; i++ {
|
||||||
if _, requestErr := executeHttpGetRequestWithHeaders(fmt.Sprintf("%v/get", proxyUrl), headers); requestErr != nil {
|
if _, requestErr := ExecuteHttpGetRequestWithHeaders(fmt.Sprintf("%v/get", proxyUrl), headers); requestErr != nil {
|
||||||
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < defaultEntriesCount; i++ {
|
for i := 0; i < DefaultEntriesCount; i++ {
|
||||||
if _, requestErr := executeHttpGetRequest(fmt.Sprintf("%v/get", proxyUrl)); requestErr != nil {
|
if _, requestErr := ExecuteHttpGetRequest(fmt.Sprintf("%v/get", proxyUrl)); requestErr != nil {
|
||||||
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/IgnoredUserAgents.js\"")
|
RunCypressTests(t, "npx cypress run --spec \"cypress/integration/tests/IgnoredUserAgents.js\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTapDumpLogs(t *testing.T) {
|
func TestTapDumpLogs(t *testing.T) {
|
||||||
@@ -531,15 +548,15 @@ func TestTapDumpLogs(t *testing.T) {
|
|||||||
t.Skip("ignored acceptance test")
|
t.Skip("ignored acceptance test")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPath, cliPathErr := getCliPath()
|
cliPath, cliPathErr := GetCliPath()
|
||||||
if cliPathErr != nil {
|
if cliPathErr != nil {
|
||||||
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
t.Errorf("failed to get cli path, err: %v", cliPathErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tapCmdArgs := getDefaultTapCommandArgs()
|
tapCmdArgs := GetDefaultTapCommandArgs()
|
||||||
|
|
||||||
tapNamespace := getDefaultTapNamespace()
|
tapNamespace := GetDefaultTapNamespace()
|
||||||
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
tapCmdArgs = append(tapCmdArgs, tapNamespace...)
|
||||||
|
|
||||||
tapCmdArgs = append(tapCmdArgs, "--set", "dump-logs=true")
|
tapCmdArgs = append(tapCmdArgs, "--set", "dump-logs=true")
|
||||||
@@ -552,19 +569,19 @@ func TestTapDumpLogs(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServerUrl := getApiServerUrl(defaultApiServerPort)
|
apiServerUrl := GetApiServerUrl(DefaultApiServerPort)
|
||||||
|
|
||||||
if err := waitTapPodsReady(apiServerUrl); err != nil {
|
if err := WaitTapPodsReady(apiServerUrl); err != nil {
|
||||||
t.Errorf("failed to start tap pods on time, err: %v", err)
|
t.Errorf("failed to start tap pods on time, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cleanupCommand(tapCmd); err != nil {
|
if err := CleanupCommand(tapCmd); err != nil {
|
||||||
t.Errorf("failed to cleanup tap command, err: %v", err)
|
t.Errorf("failed to cleanup tap command, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mizuFolderPath, mizuPathErr := getMizuFolderPath()
|
mizuFolderPath, mizuPathErr := GetMizuFolderPath()
|
||||||
if mizuPathErr != nil {
|
if mizuPathErr != nil {
|
||||||
t.Errorf("failed to get mizu folder path, err: %v", mizuPathErr)
|
t.Errorf("failed to get mizu folder path, err: %v", mizuPathErr)
|
||||||
return
|
return
|
||||||
@@ -632,3 +649,44 @@ func TestTapDumpLogs(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIpResolving(t *testing.T) {
|
||||||
|
namespace := AllNamespaces
|
||||||
|
|
||||||
|
t.Log("add permissions for ip-resolution for current user")
|
||||||
|
if err := ApplyKubeFilesForTest(
|
||||||
|
t,
|
||||||
|
"minikube",
|
||||||
|
namespace,
|
||||||
|
"../cli/cmd/permissionFiles/permissions-all-namespaces-ip-resolution-optional.yaml",
|
||||||
|
); err != nil {
|
||||||
|
t.Errorf("failed to create k8s permissions, %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
basicTapTest(t, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRestrictedMode(t *testing.T) {
|
||||||
|
namespace := "mizu-tests"
|
||||||
|
|
||||||
|
t.Log("creating permissions for restricted user")
|
||||||
|
if err := ApplyKubeFilesForTest(
|
||||||
|
t,
|
||||||
|
"minikube",
|
||||||
|
namespace,
|
||||||
|
"../cli/cmd/permissionFiles/permissions-ns-tap.yaml",
|
||||||
|
); err != nil {
|
||||||
|
t.Errorf("failed to create k8s permissions, %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Log("switching k8s context to user")
|
||||||
|
if err := SwitchKubeContextForTest(t, "user-with-restricted-access"); err != nil {
|
||||||
|
t.Errorf("failed to switch k8s context, %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
extraArgs := []string{"--set", fmt.Sprintf("mizu-resources-namespace=%s", namespace)}
|
||||||
|
t.Run("basic tap", func (testingT *testing.T) {basicTapTest(testingT, false, extraArgs...)})
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,13 +24,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
longRetriesCount = 100
|
LongRetriesCount = 100
|
||||||
shortRetriesCount = 10
|
ShortRetriesCount = 10
|
||||||
defaultApiServerPort = shared.DefaultApiServerPort
|
DefaultApiServerPort = shared.DefaultApiServerPort
|
||||||
defaultNamespaceName = "mizu-tests"
|
DefaultNamespaceName = "mizu-tests"
|
||||||
defaultServiceName = "httpbin"
|
DefaultServiceName = "httpbin"
|
||||||
defaultEntriesCount = 50
|
DefaultEntriesCount = 50
|
||||||
waitAfterTapPodsReady = 3 * time.Second
|
WaitAfterTapPodsReady = 3 * time.Second
|
||||||
|
AllNamespaces = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
type PodDescriptor struct {
|
type PodDescriptor struct {
|
||||||
@@ -38,7 +39,7 @@ type PodDescriptor struct {
|
|||||||
Namespace string
|
Namespace string
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCliPath() (string, error) {
|
func GetCliPath() (string, error) {
|
||||||
dir, filePathErr := os.Getwd()
|
dir, filePathErr := os.Getwd()
|
||||||
if filePathErr != nil {
|
if filePathErr != nil {
|
||||||
return "", filePathErr
|
return "", filePathErr
|
||||||
@@ -48,7 +49,7 @@ func getCliPath() (string, error) {
|
|||||||
return cliPath, nil
|
return cliPath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMizuFolderPath() (string, error) {
|
func GetMizuFolderPath() (string, error) {
|
||||||
home, homeDirErr := os.UserHomeDir()
|
home, homeDirErr := os.UserHomeDir()
|
||||||
if homeDirErr != nil {
|
if homeDirErr != nil {
|
||||||
return "", homeDirErr
|
return "", homeDirErr
|
||||||
@@ -57,8 +58,8 @@ func getMizuFolderPath() (string, error) {
|
|||||||
return path.Join(home, ".mizu"), nil
|
return path.Join(home, ".mizu"), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getConfigPath() (string, error) {
|
func GetConfigPath() (string, error) {
|
||||||
mizuFolderPath, mizuPathError := getMizuFolderPath()
|
mizuFolderPath, mizuPathError := GetMizuFolderPath()
|
||||||
if mizuPathError != nil {
|
if mizuPathError != nil {
|
||||||
return "", mizuPathError
|
return "", mizuPathError
|
||||||
}
|
}
|
||||||
@@ -66,15 +67,15 @@ func getConfigPath() (string, error) {
|
|||||||
return path.Join(mizuFolderPath, "config.yaml"), nil
|
return path.Join(mizuFolderPath, "config.yaml"), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getProxyUrl(namespace string, service string) string {
|
func GetProxyUrl(namespace string, service string) string {
|
||||||
return fmt.Sprintf("http://localhost:8080/api/v1/namespaces/%v/services/%v/proxy", namespace, service)
|
return fmt.Sprintf("http://localhost:8080/api/v1/namespaces/%v/services/%v/proxy", namespace, service)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getApiServerUrl(port uint16) string {
|
func GetApiServerUrl(port uint16) string {
|
||||||
return fmt.Sprintf("http://localhost:%v", port)
|
return fmt.Sprintf("http://localhost:%v", port)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getServiceExternalIp(ctx context.Context, namespace string, service string) (string, error) {
|
func NewKubernetesProvider() (*KubernetesProvider, error) {
|
||||||
home := homedir.HomeDir()
|
home := homedir.HomeDir()
|
||||||
configLoadingRules := &clientcmd.ClientConfigLoadingRules{ExplicitPath: filepath.Join(home, ".kube", "config")}
|
configLoadingRules := &clientcmd.ClientConfigLoadingRules{ExplicitPath: filepath.Join(home, ".kube", "config")}
|
||||||
clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
||||||
@@ -86,15 +87,23 @@ func getServiceExternalIp(ctx context.Context, namespace string, service string)
|
|||||||
|
|
||||||
restClientConfig, err := clientConfig.ClientConfig()
|
restClientConfig, err := clientConfig.ClientConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
clientSet, err := kubernetes.NewForConfig(restClientConfig)
|
clientSet, err := kubernetes.NewForConfig(restClientConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceObj, err := clientSet.CoreV1().Services(namespace).Get(ctx, service, metav1.GetOptions{})
|
return &KubernetesProvider{clientSet}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type KubernetesProvider struct {
|
||||||
|
clientSet *kubernetes.Clientset
|
||||||
|
}
|
||||||
|
|
||||||
|
func (kp *KubernetesProvider) GetServiceExternalIp(ctx context.Context, namespace string, service string) (string, error) {
|
||||||
|
serviceObj, err := kp.clientSet.CoreV1().Services(namespace).Get(ctx, service, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@@ -103,65 +112,164 @@ func getServiceExternalIp(ctx context.Context, namespace string, service string)
|
|||||||
return externalIp, nil
|
return externalIp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SwitchKubeContextForTest(t *testing.T, newContextName string) error {
|
||||||
|
prevKubeContextName, err := GetKubeCurrentContextName()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := SetKubeCurrentContext(newContextName); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Cleanup(func() {
|
||||||
|
if err := SetKubeCurrentContext(prevKubeContextName); err != nil {
|
||||||
|
t.Errorf("failed to set Kubernetes context to %s, err: %v", prevKubeContextName, err)
|
||||||
|
t.Errorf("cleanup failed, subsequent tests may be affected")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetKubeCurrentContextName() (string, error) {
|
||||||
|
cmd := exec.Command("kubectl", "config", "current-context")
|
||||||
|
|
||||||
|
output, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("%v, %s", err, string(output))
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(bytes.TrimSpace(output)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKubeCurrentContext(contextName string) error {
|
||||||
|
cmd := exec.Command("kubectl", "config", "use-context", contextName)
|
||||||
|
|
||||||
|
if output, err := cmd.CombinedOutput(); err != nil {
|
||||||
|
return fmt.Errorf("%v, %s", err, string(output))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ApplyKubeFilesForTest(t *testing.T, kubeContext string, namespace string, filename ...string) error {
|
||||||
|
for i := range filename {
|
||||||
|
fname := filename[i]
|
||||||
|
if err := ApplyKubeFile(kubeContext, namespace, fname); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Cleanup(func() {
|
||||||
|
if err := DeleteKubeFile(kubeContext, namespace, fname); err != nil {
|
||||||
|
t.Errorf(
|
||||||
|
"failed to delete Kubernetes resources in namespace %s from filename %s, err: %v",
|
||||||
|
namespace,
|
||||||
|
fname,
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ApplyKubeFile(kubeContext string, namespace string, filename string) (error) {
|
||||||
|
cmdArgs := []string{
|
||||||
|
"apply",
|
||||||
|
"--context", kubeContext,
|
||||||
|
"-f", filename,
|
||||||
|
}
|
||||||
|
if namespace != AllNamespaces {
|
||||||
|
cmdArgs = append(cmdArgs, "-n", namespace)
|
||||||
|
}
|
||||||
|
cmd := exec.Command("kubectl", cmdArgs...)
|
||||||
|
|
||||||
|
if output, err := cmd.CombinedOutput(); err != nil {
|
||||||
|
return fmt.Errorf("%v, %s", err, string(output))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteKubeFile(kubeContext string, namespace string, filename string) error {
|
||||||
|
cmdArgs := []string{
|
||||||
|
"delete",
|
||||||
|
"--context", kubeContext,
|
||||||
|
"-f", filename,
|
||||||
|
}
|
||||||
|
if namespace != AllNamespaces {
|
||||||
|
cmdArgs = append(cmdArgs, "-n", namespace)
|
||||||
|
}
|
||||||
|
cmd := exec.Command("kubectl", cmdArgs...)
|
||||||
|
|
||||||
|
if output, err := cmd.CombinedOutput(); err != nil {
|
||||||
|
return fmt.Errorf("%v, %s", err, string(output))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func getDefaultCommandArgs() []string {
|
func getDefaultCommandArgs() []string {
|
||||||
setFlag := "--set"
|
setFlag := "--set"
|
||||||
telemetry := "telemetry=false"
|
telemetry := "telemetry=false"
|
||||||
agentImage := "agent-image=gcr.io/up9-docker-hub/mizu/ci:0.0"
|
agentImage := "agent-image=mizu/ci:0.0"
|
||||||
imagePullPolicy := "image-pull-policy=IfNotPresent"
|
imagePullPolicy := "image-pull-policy=IfNotPresent"
|
||||||
headless := "headless=true"
|
headless := "headless=true"
|
||||||
|
|
||||||
return []string{setFlag, telemetry, setFlag, agentImage, setFlag, imagePullPolicy, setFlag, headless}
|
return []string{setFlag, telemetry, setFlag, agentImage, setFlag, imagePullPolicy, setFlag, headless}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDefaultTapCommandArgs() []string {
|
func GetDefaultTapCommandArgs() []string {
|
||||||
tapCommand := "tap"
|
tapCommand := "tap"
|
||||||
defaultCmdArgs := getDefaultCommandArgs()
|
defaultCmdArgs := getDefaultCommandArgs()
|
||||||
|
|
||||||
return append([]string{tapCommand}, defaultCmdArgs...)
|
return append([]string{tapCommand}, defaultCmdArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDefaultTapCommandArgsWithRegex(regex string) []string {
|
func GetDefaultTapCommandArgsWithRegex(regex string) []string {
|
||||||
tapCommand := "tap"
|
tapCommand := "tap"
|
||||||
defaultCmdArgs := getDefaultCommandArgs()
|
defaultCmdArgs := getDefaultCommandArgs()
|
||||||
|
|
||||||
return append([]string{tapCommand, regex}, defaultCmdArgs...)
|
return append([]string{tapCommand, regex}, defaultCmdArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDefaultLogsCommandArgs() []string {
|
func GetDefaultLogsCommandArgs() []string {
|
||||||
logsCommand := "logs"
|
logsCommand := "logs"
|
||||||
defaultCmdArgs := getDefaultCommandArgs()
|
defaultCmdArgs := getDefaultCommandArgs()
|
||||||
|
|
||||||
return append([]string{logsCommand}, defaultCmdArgs...)
|
return append([]string{logsCommand}, defaultCmdArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDefaultTapNamespace() []string {
|
func GetDefaultTapNamespace() []string {
|
||||||
return []string{"-n", "mizu-tests"}
|
return []string{"-n", "mizu-tests"}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDefaultConfigCommandArgs() []string {
|
func GetDefaultConfigCommandArgs() []string {
|
||||||
configCommand := "config"
|
configCommand := "config"
|
||||||
defaultCmdArgs := getDefaultCommandArgs()
|
defaultCmdArgs := getDefaultCommandArgs()
|
||||||
|
|
||||||
return append([]string{configCommand}, defaultCmdArgs...)
|
return append([]string{configCommand}, defaultCmdArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runCypressTests(t *testing.T, cypressRunCmd string) {
|
func RunCypressTests(t *testing.T, cypressRunCmd string) {
|
||||||
cypressCmd := exec.Command("bash", "-c", cypressRunCmd)
|
cypressCmd := exec.Command("bash", "-c", cypressRunCmd)
|
||||||
t.Logf("running command: %v", cypressCmd.String())
|
t.Logf("running command: %v", cypressCmd.String())
|
||||||
out, err := cypressCmd.Output()
|
out, err := cypressCmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("error running cypress, error: %v", err)
|
t.Errorf("error running cypress, error: %v, output: %v", err, string(out))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Logf("%s", out)
|
t.Logf("%s", out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func retriesExecute(retriesCount int, executeFunc func() error) error {
|
func RetriesExecute(retriesCount int, executeFunc func() error) error {
|
||||||
var lastError interface{}
|
var lastError interface{}
|
||||||
|
|
||||||
for i := 0; i < retriesCount; i++ {
|
for i := 0; i < retriesCount; i++ {
|
||||||
if err := tryExecuteFunc(executeFunc); err != nil {
|
if err := TryExecuteFunc(executeFunc); err != nil {
|
||||||
lastError = err
|
lastError = err
|
||||||
|
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
@@ -174,7 +282,7 @@ func retriesExecute(retriesCount int, executeFunc func() error) error {
|
|||||||
return fmt.Errorf("reached max retries count, retries count: %v, last err: %v", retriesCount, lastError)
|
return fmt.Errorf("reached max retries count, retries count: %v, last err: %v", retriesCount, lastError)
|
||||||
}
|
}
|
||||||
|
|
||||||
func tryExecuteFunc(executeFunc func() error) (err interface{}) {
|
func TryExecuteFunc(executeFunc func() error) (err interface{}) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if panicErr := recover(); panicErr != nil {
|
if panicErr := recover(); panicErr != nil {
|
||||||
err = panicErr
|
err = panicErr
|
||||||
@@ -184,10 +292,10 @@ func tryExecuteFunc(executeFunc func() error) (err interface{}) {
|
|||||||
return executeFunc()
|
return executeFunc()
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitTapPodsReady(apiServerUrl string) error {
|
func WaitTapPodsReady(apiServerUrl string) error {
|
||||||
resolvingUrl := fmt.Sprintf("%v/status/connectedTappersCount", apiServerUrl)
|
resolvingUrl := fmt.Sprintf("%v/status/connectedTappersCount", apiServerUrl)
|
||||||
tapPodsReadyFunc := func() error {
|
tapPodsReadyFunc := func() error {
|
||||||
requestResult, requestErr := executeHttpGetRequest(resolvingUrl)
|
requestResult, requestErr := ExecuteHttpGetRequest(resolvingUrl)
|
||||||
if requestErr != nil {
|
if requestErr != nil {
|
||||||
return requestErr
|
return requestErr
|
||||||
}
|
}
|
||||||
@@ -196,14 +304,14 @@ func waitTapPodsReady(apiServerUrl string) error {
|
|||||||
if connectedTappersCount == 0 {
|
if connectedTappersCount == 0 {
|
||||||
return fmt.Errorf("no connected tappers running")
|
return fmt.Errorf("no connected tappers running")
|
||||||
}
|
}
|
||||||
time.Sleep(waitAfterTapPodsReady)
|
time.Sleep(WaitAfterTapPodsReady)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return retriesExecute(longRetriesCount, tapPodsReadyFunc)
|
return RetriesExecute(LongRetriesCount, tapPodsReadyFunc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func jsonBytesToInterface(jsonBytes []byte) (interface{}, error) {
|
func JsonBytesToInterface(jsonBytes []byte) (interface{}, error) {
|
||||||
var result interface{}
|
var result interface{}
|
||||||
if parseErr := json.Unmarshal(jsonBytes, &result); parseErr != nil {
|
if parseErr := json.Unmarshal(jsonBytes, &result); parseErr != nil {
|
||||||
return nil, parseErr
|
return nil, parseErr
|
||||||
@@ -212,7 +320,7 @@ func jsonBytesToInterface(jsonBytes []byte) (interface{}, error) {
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeHttpRequest(response *http.Response, requestErr error) (interface{}, error) {
|
func ExecuteHttpRequest(response *http.Response, requestErr error) (interface{}, error) {
|
||||||
if requestErr != nil {
|
if requestErr != nil {
|
||||||
return nil, requestErr
|
return nil, requestErr
|
||||||
} else if response.StatusCode != 200 {
|
} else if response.StatusCode != 200 {
|
||||||
@@ -226,10 +334,10 @@ func executeHttpRequest(response *http.Response, requestErr error) (interface{},
|
|||||||
return nil, readErr
|
return nil, readErr
|
||||||
}
|
}
|
||||||
|
|
||||||
return jsonBytesToInterface(data)
|
return JsonBytesToInterface(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeHttpGetRequestWithHeaders(url string, headers map[string]string) (interface{}, error) {
|
func ExecuteHttpGetRequestWithHeaders(url string, headers map[string]string) (interface{}, error) {
|
||||||
request, err := http.NewRequest(http.MethodGet, url, nil)
|
request, err := http.NewRequest(http.MethodGet, url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -241,15 +349,15 @@ func executeHttpGetRequestWithHeaders(url string, headers map[string]string) (in
|
|||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
response, requestErr := client.Do(request)
|
response, requestErr := client.Do(request)
|
||||||
return executeHttpRequest(response, requestErr)
|
return ExecuteHttpRequest(response, requestErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeHttpGetRequest(url string) (interface{}, error) {
|
func ExecuteHttpGetRequest(url string) (interface{}, error) {
|
||||||
response, requestErr := http.Get(url)
|
response, requestErr := http.Get(url)
|
||||||
return executeHttpRequest(response, requestErr)
|
return ExecuteHttpRequest(response, requestErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeHttpPostRequestWithHeaders(url string, headers map[string]string, body interface{}) (interface{}, error) {
|
func ExecuteHttpPostRequestWithHeaders(url string, headers map[string]string, body interface{}) (interface{}, error) {
|
||||||
requestBody, jsonErr := json.Marshal(body)
|
requestBody, jsonErr := json.Marshal(body)
|
||||||
if jsonErr != nil {
|
if jsonErr != nil {
|
||||||
return nil, jsonErr
|
return nil, jsonErr
|
||||||
@@ -267,10 +375,10 @@ func executeHttpPostRequestWithHeaders(url string, headers map[string]string, bo
|
|||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
response, requestErr := client.Do(request)
|
response, requestErr := client.Do(request)
|
||||||
return executeHttpRequest(response, requestErr)
|
return ExecuteHttpRequest(response, requestErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func cleanupCommand(cmd *exec.Cmd) error {
|
func CleanupCommand(cmd *exec.Cmd) error {
|
||||||
if err := cmd.Process.Signal(syscall.SIGQUIT); err != nil {
|
if err := cmd.Process.Signal(syscall.SIGQUIT); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -282,7 +390,7 @@ func cleanupCommand(cmd *exec.Cmd) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLogsPath() (string, error) {
|
func GetLogsPath() (string, error) {
|
||||||
dir, filePathErr := os.Getwd()
|
dir, filePathErr := os.Getwd()
|
||||||
if filePathErr != nil {
|
if filePathErr != nil {
|
||||||
return "", filePathErr
|
return "", filePathErr
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ go 1.17
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/antelman107/net-wait-go v0.0.0-20210623112055-cf684aebda7b
|
github.com/antelman107/net-wait-go v0.0.0-20210623112055-cf684aebda7b
|
||||||
github.com/chanced/openapi v0.0.7
|
github.com/chanced/openapi v0.0.8
|
||||||
github.com/djherbis/atime v1.1.0
|
github.com/djherbis/atime v1.1.0
|
||||||
github.com/elastic/go-elasticsearch/v7 v7.17.0
|
github.com/elastic/go-elasticsearch/v7 v7.17.0
|
||||||
github.com/getkin/kin-openapi v0.89.0
|
github.com/getkin/kin-openapi v0.89.0
|
||||||
@@ -22,7 +22,7 @@ require (
|
|||||||
github.com/ory/kratos-client-go v0.8.2-alpha.1
|
github.com/ory/kratos-client-go v0.8.2-alpha.1
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||||
github.com/stretchr/testify v1.7.0
|
github.com/stretchr/testify v1.7.0
|
||||||
github.com/up9inc/basenine/client/go v0.0.0-20220220204122-0ef8cb24fab1
|
github.com/up9inc/basenine/client/go v0.0.0-20220302182733-74dc40dc2ef0
|
||||||
github.com/up9inc/mizu/shared v0.0.0
|
github.com/up9inc/mizu/shared v0.0.0
|
||||||
github.com/up9inc/mizu/tap v0.0.0
|
github.com/up9inc/mizu/tap v0.0.0
|
||||||
github.com/up9inc/mizu/tap/api v0.0.0
|
github.com/up9inc/mizu/tap/api v0.0.0
|
||||||
|
|||||||
10
agent/go.sum
10
agent/go.sum
@@ -132,8 +132,8 @@ github.com/chanced/cmpjson v0.0.0-20210415035445-da9262c1f20a/go.mod h1:yhcmlFk1
|
|||||||
github.com/chanced/dynamic v0.0.0-20210502140838-c010b5fc3e44/go.mod h1:XVNfXN5kgZST4PQ0W/oBAHJku2OteCeHxjAbvfd0ARM=
|
github.com/chanced/dynamic v0.0.0-20210502140838-c010b5fc3e44/go.mod h1:XVNfXN5kgZST4PQ0W/oBAHJku2OteCeHxjAbvfd0ARM=
|
||||||
github.com/chanced/dynamic v0.0.0-20211210164248-f8fadb1d735b h1:nQWfVfhByCAYUjDxWNMyMtq3VZ8AGOxF7wZlDnC5cTc=
|
github.com/chanced/dynamic v0.0.0-20211210164248-f8fadb1d735b h1:nQWfVfhByCAYUjDxWNMyMtq3VZ8AGOxF7wZlDnC5cTc=
|
||||||
github.com/chanced/dynamic v0.0.0-20211210164248-f8fadb1d735b/go.mod h1:XVNfXN5kgZST4PQ0W/oBAHJku2OteCeHxjAbvfd0ARM=
|
github.com/chanced/dynamic v0.0.0-20211210164248-f8fadb1d735b/go.mod h1:XVNfXN5kgZST4PQ0W/oBAHJku2OteCeHxjAbvfd0ARM=
|
||||||
github.com/chanced/openapi v0.0.7 h1:OmOBHCg/5ViUg0gaGxXBeEFoVBE8C2pHK4BO/AiD6k8=
|
github.com/chanced/openapi v0.0.8 h1:pOqKTvZEET2odGE+kJBrAdXvgpTKFPk+XRz5NTuMvrM=
|
||||||
github.com/chanced/openapi v0.0.7/go.mod h1:SxE2VMLPw+T7Vq8nwbVVhDF2PigvRF4n5XyqsVpRJGU=
|
github.com/chanced/openapi v0.0.8/go.mod h1:SxE2VMLPw+T7Vq8nwbVVhDF2PigvRF4n5XyqsVpRJGU=
|
||||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||||
@@ -855,6 +855,12 @@ github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ
|
|||||||
github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw=
|
github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw=
|
||||||
github.com/up9inc/basenine/client/go v0.0.0-20220220204122-0ef8cb24fab1 h1:0XN8s3HtwUBr9hbWRAFulFMsu1f2cabfJbwpz/sOoLA=
|
github.com/up9inc/basenine/client/go v0.0.0-20220220204122-0ef8cb24fab1 h1:0XN8s3HtwUBr9hbWRAFulFMsu1f2cabfJbwpz/sOoLA=
|
||||||
github.com/up9inc/basenine/client/go v0.0.0-20220220204122-0ef8cb24fab1/go.mod h1:SvJGPoa/6erhUQV7kvHBwM/0x5LyO6XaG2lUaCaKiUI=
|
github.com/up9inc/basenine/client/go v0.0.0-20220220204122-0ef8cb24fab1/go.mod h1:SvJGPoa/6erhUQV7kvHBwM/0x5LyO6XaG2lUaCaKiUI=
|
||||||
|
github.com/up9inc/basenine/client/go v0.0.0-20220301135911-d2111357b14e h1:nv/A/AeF8PcU91aHAj6o2cU8fl/46v0ZLj7wgIKjv+o=
|
||||||
|
github.com/up9inc/basenine/client/go v0.0.0-20220301135911-d2111357b14e/go.mod h1:SvJGPoa/6erhUQV7kvHBwM/0x5LyO6XaG2lUaCaKiUI=
|
||||||
|
github.com/up9inc/basenine/client/go v0.0.0-20220302073458-c32e0adf1500 h1:T1QHxt65NMete/GobVSvcHnwZAQibvahhrMTCgtnSS4=
|
||||||
|
github.com/up9inc/basenine/client/go v0.0.0-20220302073458-c32e0adf1500/go.mod h1:SvJGPoa/6erhUQV7kvHBwM/0x5LyO6XaG2lUaCaKiUI=
|
||||||
|
github.com/up9inc/basenine/client/go v0.0.0-20220302182733-74dc40dc2ef0 h1:mSqZuJJV4UZyaAoC8x7/AO7DLidlXepFyU18Vm3rFiA=
|
||||||
|
github.com/up9inc/basenine/client/go v0.0.0-20220302182733-74dc40dc2ef0/go.mod h1:SvJGPoa/6erhUQV7kvHBwM/0x5LyO6XaG2lUaCaKiUI=
|
||||||
github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
|
github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
|
||||||
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 h1:gga7acRE695APm9hlsSMoOoE65U4/TcqNj90mc69Rlg=
|
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 h1:gga7acRE695APm9hlsSMoOoE65U4/TcqNj90mc69Rlg=
|
||||||
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ func hostApi(socketHarOutputChannel chan<- *tapApi.OutputChannelItem) *gin.Engin
|
|||||||
app := gin.Default()
|
app := gin.Default()
|
||||||
|
|
||||||
app.GET("/echo", func(c *gin.Context) {
|
app.GET("/echo", func(c *gin.Context) {
|
||||||
c.String(http.StatusOK, "Here is Mizu agent")
|
c.JSON(http.StatusOK, "Here is Mizu agent")
|
||||||
})
|
})
|
||||||
|
|
||||||
eventHandlers := api.RoutesEventHandlers{
|
eventHandlers := api.RoutesEventHandlers{
|
||||||
@@ -140,7 +140,7 @@ func runInApiServerMode(namespace string) *gin.Engine {
|
|||||||
if err := config.LoadConfig(); err != nil {
|
if err := config.LoadConfig(); err != nil {
|
||||||
logger.Log.Fatalf("Error loading config file %v", err)
|
logger.Log.Fatalf("Error loading config file %v", err)
|
||||||
}
|
}
|
||||||
app.ConfigureBasenineServer(shared.BasenineHost, shared.BaseninePort, config.Config.MaxDBSizeBytes, config.Config.LogLevel)
|
app.ConfigureBasenineServer(shared.BasenineHost, shared.BaseninePort, config.Config.MaxDBSizeBytes, config.Config.LogLevel, config.Config.InsertionFilter)
|
||||||
startTime = time.Now().UnixNano() / int64(time.Millisecond)
|
startTime = time.Now().UnixNano() / int64(time.Millisecond)
|
||||||
api.StartResolving(namespace)
|
api.StartResolving(namespace)
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ func LoadExtensions() {
|
|||||||
controllers.InitExtensionsMap(ExtensionsMap)
|
controllers.InitExtensionsMap(ExtensionsMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConfigureBasenineServer(host string, port string, dbSize int64, logLevel logging.Level) {
|
func ConfigureBasenineServer(host string, port string, dbSize int64, logLevel logging.Level, insertionFilter string) {
|
||||||
if !wait.New(
|
if !wait.New(
|
||||||
wait.WithProto("tcp"),
|
wait.WithProto("tcp"),
|
||||||
wait.WithWait(200*time.Millisecond),
|
wait.WithWait(200*time.Millisecond),
|
||||||
@@ -86,6 +86,11 @@ func ConfigureBasenineServer(host string, port string, dbSize int64, logLevel lo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the insertion filter that comes from the config
|
||||||
|
if err := basenine.InsertionFilter(host, port, insertionFilter); err != nil {
|
||||||
|
logger.Log.Errorf("Error while setting the insertion filter: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetEntryInputChannel() chan *tapApi.OutputChannelItem {
|
func GetEntryInputChannel() chan *tapApi.OutputChannelItem {
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/elastic/go-elasticsearch/v7"
|
"github.com/elastic/go-elasticsearch/v7"
|
||||||
"github.com/up9inc/mizu/shared"
|
"github.com/up9inc/mizu/shared"
|
||||||
"github.com/up9inc/mizu/shared/logger"
|
"github.com/up9inc/mizu/shared/logger"
|
||||||
"github.com/up9inc/mizu/tap/api"
|
"github.com/up9inc/mizu/tap/api"
|
||||||
"net/http"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type client struct {
|
type client struct {
|
||||||
@@ -31,6 +32,9 @@ func GetInstance() *client {
|
|||||||
|
|
||||||
func (client *client) Configure(config shared.ElasticConfig) {
|
func (client *client) Configure(config shared.ElasticConfig) {
|
||||||
if config.Url == "" || config.User == "" || config.Password == "" {
|
if config.Url == "" || config.User == "" || config.Password == "" {
|
||||||
|
if client.es != nil {
|
||||||
|
client.es = nil
|
||||||
|
}
|
||||||
logger.Log.Infof("No elastic configuration was supplied, elastic exporter disabled")
|
logger.Log.Infof("No elastic configuration was supplied, elastic exporter disabled")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -46,13 +50,13 @@ func (client *client) Configure(config shared.ElasticConfig) {
|
|||||||
|
|
||||||
es, err := elasticsearch.NewClient(cfg)
|
es, err := elasticsearch.NewClient(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Log.Fatalf("Failed to initialize elastic client %v", err)
|
logger.Log.Errorf("Failed to initialize elastic client %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Have the client instance return a response
|
// Have the client instance return a response
|
||||||
res, err := es.Info()
|
res, err := es.Info()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Log.Fatalf("Elastic client.Info() ERROR: %v", err)
|
logger.Log.Errorf("Elastic client.Info() ERROR: %v", err)
|
||||||
} else {
|
} else {
|
||||||
client.es = es
|
client.es = es
|
||||||
client.index = "mizu_traffic_http_" + time.Now().Format("2006_01_02_15_04")
|
client.index = "mizu_traffic_http_" + time.Now().Format("2006_01_02_15_04")
|
||||||
|
|||||||
@@ -33,10 +33,23 @@ func (g *oasGenerator) Start() {
|
|||||||
g.entriesChan = make(chan EntryWithSource, 100) // buffer up to 100 entries for OAS processing
|
g.entriesChan = make(chan EntryWithSource, 100) // buffer up to 100 entries for OAS processing
|
||||||
g.ServiceSpecs = &sync.Map{}
|
g.ServiceSpecs = &sync.Map{}
|
||||||
g.started = true
|
g.started = true
|
||||||
go instance.runGeneretor()
|
go instance.runGenerator()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *oasGenerator) runGeneretor() {
|
func (g *oasGenerator) Stop() {
|
||||||
|
if !g.started {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
g.cancel()
|
||||||
|
g.Reset()
|
||||||
|
g.started = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *oasGenerator) IsStarted() bool {
|
||||||
|
return g.started
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *oasGenerator) runGenerator() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-g.ctx.Done():
|
case <-g.ctx.Done():
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ func (g *SpecGen) handlePathObj(entryWithSource *EntryWithSource) (string, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
if entry.Request.Method == "OPTIONS" {
|
if entry.Request.Method == "OPTIONS" {
|
||||||
logger.Log.Debugf("Dropped traffic entry due to its method: %s", urlParsed.Path)
|
logger.Log.Debugf("Dropped traffic entry due to its method: %s %s", entry.Request.Method, urlParsed.Path)
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,24 @@ func TestEntries(t *testing.T) {
|
|||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
GetOasGeneratorInstance().Start()
|
GetOasGeneratorInstance().Start()
|
||||||
loadStartingOAS()
|
loadStartingOAS("test_artifacts/catalogue.json", "catalogue")
|
||||||
|
loadStartingOAS("test_artifacts/trcc.json", "trcc-api-service")
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
GetOasGeneratorInstance().ServiceSpecs.Range(func(key, val interface{}) bool {
|
||||||
|
svc := key.(string)
|
||||||
|
t.Logf("Getting spec for %s", svc)
|
||||||
|
gen := val.(*SpecGen)
|
||||||
|
_, err := gen.GetSpec()
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
cnt, err := feedEntries(files, true)
|
cnt, err := feedEntries(files, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -154,6 +171,13 @@ func TestFileSingle(t *testing.T) {
|
|||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if os.Getenv("MIZU_OAS_WRITE_FILES") != "" {
|
||||||
|
err = ioutil.WriteFile(file+".spec.json", []byte(specText), 0644)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if len(diff) > 0 {
|
if len(diff) > 0 {
|
||||||
t.Errorf("Generated spec does not match expected:\n%s", diff.String())
|
t.Errorf("Generated spec does not match expected:\n%s", diff.String())
|
||||||
}
|
}
|
||||||
@@ -175,8 +199,7 @@ func waitQueueProcessed() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadStartingOAS() {
|
func loadStartingOAS(file string, label string) {
|
||||||
file := "test_artifacts/catalogue.json"
|
|
||||||
fd, err := os.Open(file)
|
fd, err := os.Open(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -195,10 +218,10 @@ func loadStartingOAS() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
gen := NewGen("catalogue")
|
gen := NewGen(label)
|
||||||
gen.StartFromSpec(doc)
|
gen.StartFromSpec(doc)
|
||||||
|
|
||||||
GetOasGeneratorInstance().ServiceSpecs.Store("catalogue", gen)
|
GetOasGeneratorInstance().ServiceSpecs.Store(label, gen)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEntriesNegative(t *testing.T) {
|
func TestEntriesNegative(t *testing.T) {
|
||||||
|
|||||||
@@ -538,6 +538,252 @@
|
|||||||
"wait": -1,
|
"wait": -1,
|
||||||
"receive": 1
|
"receive": 1
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"startedDateTime": "2019-09-06T06:16:22.000000+00:00",
|
||||||
|
"time": 1,
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://httpbin.org/param-patterns/prefix-gibberish-fine/234324",
|
||||||
|
"httpVersion": "",
|
||||||
|
"cookies": [],
|
||||||
|
"headers": [
|
||||||
|
],
|
||||||
|
"queryString": [],
|
||||||
|
"headersSize": -1,
|
||||||
|
"bodySize": -1,
|
||||||
|
"postData": {
|
||||||
|
"mimeType": "",
|
||||||
|
"text": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"status": 200,
|
||||||
|
"statusText": "OK",
|
||||||
|
"httpVersion": "",
|
||||||
|
"cookies": [],
|
||||||
|
"headers": [
|
||||||
|
],
|
||||||
|
"content": {
|
||||||
|
"size": 0,
|
||||||
|
"mimeType": "",
|
||||||
|
"text": ""
|
||||||
|
},
|
||||||
|
"redirectURL": "",
|
||||||
|
"headersSize": -1,
|
||||||
|
"bodySize": 0
|
||||||
|
},
|
||||||
|
"cache": {},
|
||||||
|
"timings": {
|
||||||
|
"send": -1,
|
||||||
|
"wait": -1,
|
||||||
|
"receive": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"startedDateTime": "2019-09-06T06:16:22.000001+00:00",
|
||||||
|
"time": 1,
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://httpbin.org/param-patterns/prefix-gibberish-sfdlasdfkadf87sd93284q24r/1",
|
||||||
|
"httpVersion": "",
|
||||||
|
"cookies": [],
|
||||||
|
"headers": [
|
||||||
|
],
|
||||||
|
"queryString": [],
|
||||||
|
"headersSize": -1,
|
||||||
|
"bodySize": -1,
|
||||||
|
"postData": {
|
||||||
|
"mimeType": "",
|
||||||
|
"text": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"status": 200,
|
||||||
|
"statusText": "OK",
|
||||||
|
"httpVersion": "",
|
||||||
|
"cookies": [],
|
||||||
|
"headers": [
|
||||||
|
],
|
||||||
|
"content": {
|
||||||
|
"size": 0,
|
||||||
|
"mimeType": "",
|
||||||
|
"text": ""
|
||||||
|
},
|
||||||
|
"redirectURL": "",
|
||||||
|
"headersSize": -1,
|
||||||
|
"bodySize": 0
|
||||||
|
},
|
||||||
|
"cache": {},
|
||||||
|
"timings": {
|
||||||
|
"send": -1,
|
||||||
|
"wait": -1,
|
||||||
|
"receive": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"startedDateTime": "2019-09-06T06:16:22.000002+00:00",
|
||||||
|
"time": 1,
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://httpbin.org/param-patterns/prefix-gibberish-adslkfasdf89sa7dfasddafa8a98sd7kansdf/static",
|
||||||
|
"httpVersion": "",
|
||||||
|
"cookies": [],
|
||||||
|
"headers": [
|
||||||
|
],
|
||||||
|
"queryString": [],
|
||||||
|
"headersSize": -1,
|
||||||
|
"bodySize": -1,
|
||||||
|
"postData": {
|
||||||
|
"mimeType": "",
|
||||||
|
"text": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"status": 200,
|
||||||
|
"statusText": "OK",
|
||||||
|
"httpVersion": "",
|
||||||
|
"cookies": [],
|
||||||
|
"headers": [
|
||||||
|
],
|
||||||
|
"content": {
|
||||||
|
"size": 0,
|
||||||
|
"mimeType": "",
|
||||||
|
"text": ""
|
||||||
|
},
|
||||||
|
"redirectURL": "",
|
||||||
|
"headersSize": -1,
|
||||||
|
"bodySize": 0
|
||||||
|
},
|
||||||
|
"cache": {},
|
||||||
|
"timings": {
|
||||||
|
"send": -1,
|
||||||
|
"wait": -1,
|
||||||
|
"receive": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"startedDateTime": "2019-09-06T06:16:22.000003+00:00",
|
||||||
|
"time": 1,
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://httpbin.org/param-patterns/prefix-gibberish-4jk5l2345h2452l4352435jlk45",
|
||||||
|
"httpVersion": "",
|
||||||
|
"cookies": [],
|
||||||
|
"headers": [
|
||||||
|
],
|
||||||
|
"queryString": [],
|
||||||
|
"headersSize": -1,
|
||||||
|
"bodySize": -1,
|
||||||
|
"postData": {
|
||||||
|
"mimeType": "",
|
||||||
|
"text": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"status": 200,
|
||||||
|
"statusText": "OK",
|
||||||
|
"httpVersion": "",
|
||||||
|
"cookies": [],
|
||||||
|
"headers": [
|
||||||
|
],
|
||||||
|
"content": {
|
||||||
|
"size": 0,
|
||||||
|
"mimeType": "",
|
||||||
|
"text": ""
|
||||||
|
},
|
||||||
|
"redirectURL": "",
|
||||||
|
"headersSize": -1,
|
||||||
|
"bodySize": 0
|
||||||
|
},
|
||||||
|
"cache": {},
|
||||||
|
"timings": {
|
||||||
|
"send": -1,
|
||||||
|
"wait": -1,
|
||||||
|
"receive": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"startedDateTime": "2019-09-06T06:16:22.000004+00:00",
|
||||||
|
"time": 1,
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://httpbin.org/param-patterns/prefix-gibberish-84395h2j4k35hj243j5h2kl34h54k",
|
||||||
|
"httpVersion": "",
|
||||||
|
"cookies": [],
|
||||||
|
"headers": [
|
||||||
|
],
|
||||||
|
"queryString": [],
|
||||||
|
"headersSize": -1,
|
||||||
|
"bodySize": -1,
|
||||||
|
"postData": {
|
||||||
|
"mimeType": "",
|
||||||
|
"text": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"status": 200,
|
||||||
|
"statusText": "OK",
|
||||||
|
"httpVersion": "",
|
||||||
|
"cookies": [],
|
||||||
|
"headers": [
|
||||||
|
],
|
||||||
|
"content": {
|
||||||
|
"size": 0,
|
||||||
|
"mimeType": "",
|
||||||
|
"text": ""
|
||||||
|
},
|
||||||
|
"redirectURL": "",
|
||||||
|
"headersSize": -1,
|
||||||
|
"bodySize": 0
|
||||||
|
},
|
||||||
|
"cache": {},
|
||||||
|
"timings": {
|
||||||
|
"send": -1,
|
||||||
|
"wait": -1,
|
||||||
|
"receive": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"startedDateTime": "2019-09-06T06:16:22.000002+00:00",
|
||||||
|
"time": 1,
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://httpbin.org/param-patterns/prefix-gibberish-afterwards/23421",
|
||||||
|
"httpVersion": "",
|
||||||
|
"cookies": [],
|
||||||
|
"headers": [
|
||||||
|
],
|
||||||
|
"queryString": [],
|
||||||
|
"headersSize": -1,
|
||||||
|
"bodySize": -1,
|
||||||
|
"postData": {
|
||||||
|
"mimeType": "",
|
||||||
|
"text": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"status": 200,
|
||||||
|
"statusText": "OK",
|
||||||
|
"httpVersion": "",
|
||||||
|
"cookies": [],
|
||||||
|
"headers": [
|
||||||
|
],
|
||||||
|
"content": {
|
||||||
|
"size": 0,
|
||||||
|
"mimeType": "",
|
||||||
|
"text": ""
|
||||||
|
},
|
||||||
|
"redirectURL": "",
|
||||||
|
"headersSize": -1,
|
||||||
|
"bodySize": 0
|
||||||
|
},
|
||||||
|
"cache": {},
|
||||||
|
"timings": {
|
||||||
|
"send": -1,
|
||||||
|
"wait": -1,
|
||||||
|
"receive": 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"openapi": "3.1.0",
|
"openapi": "3.1.0",
|
||||||
"info": {
|
"info": {
|
||||||
"title": "https://httpbin.org",
|
"title": "https://httpbin.org",
|
||||||
"description": "Mizu observed 13 entries (0 failed), at 0.155 hits/s, average response time is 0.251 seconds",
|
"description": "Mizu observed 19 entries (0 failed), at 0.10 hits/s, average response time is 0.17 seconds",
|
||||||
"version": "1.0"
|
"version": "1.0"
|
||||||
},
|
},
|
||||||
"servers": [
|
"servers": [
|
||||||
@@ -14,8 +14,8 @@
|
|||||||
"/appears-once": {
|
"/appears-once": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "/appears-once",
|
"summary": "/appears-once",
|
||||||
"description": "Mizu observed 1 entries (0 failed), at 0.000 hits/s, average response time is 0.630 seconds",
|
"description": "Mizu observed 1 entries (0 failed), at 0.00 hits/s, average response time is 0.63 seconds",
|
||||||
"operationId": "89aa39f6-78d0-411b-b701-a33bd77868b0",
|
"operationId": "<UUID4>",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Successful call with status 200",
|
"description": "Successful call with status 200",
|
||||||
@@ -26,33 +26,33 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-last-seen-ts": 1567750580.0471218,
|
|
||||||
"x-counters-total": {
|
|
||||||
"entries": 1,
|
|
||||||
"failures": 0,
|
|
||||||
"firstSeen": 1567750580.0471218,
|
|
||||||
"lastSeen": 1567750580.0471218,
|
|
||||||
"sumRT": 0.63,
|
|
||||||
"sumDuration": 0
|
|
||||||
},
|
|
||||||
"x-counters-per-source": {
|
"x-counters-per-source": {
|
||||||
"": {
|
"": {
|
||||||
"entries": 1,
|
"entries": 1,
|
||||||
"failures": 0,
|
"failures": 0,
|
||||||
"firstSeen": 1567750580.0471218,
|
"firstSeen": 1567750580.04,
|
||||||
"lastSeen": 1567750580.0471218,
|
"lastSeen": 1567750580.04,
|
||||||
"sumRT": 0.63,
|
"sumRT": 0.63,
|
||||||
"sumDuration": 0
|
"sumDuration": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"x-counters-total": {
|
||||||
|
"entries": 1,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750580.04,
|
||||||
|
"lastSeen": 1567750580.04,
|
||||||
|
"sumRT": 0.63,
|
||||||
|
"sumDuration": 0
|
||||||
|
},
|
||||||
|
"x-last-seen-ts": 1567750580.04,
|
||||||
"x-sample-entry": 0
|
"x-sample-entry": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/appears-twice": {
|
"/appears-twice": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "/appears-twice",
|
"summary": "/appears-twice",
|
||||||
"description": "Mizu observed 2 entries (0 failed), at 0.500 hits/s, average response time is 0.630 seconds",
|
"description": "Mizu observed 2 entries (0 failed), at 0.50 hits/s, average response time is 0.63 seconds",
|
||||||
"operationId": "f5e2b5a2-e01a-45f4-bde1-15a7e7a06d3c",
|
"operationId": "<UUID4>",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Successful call with status 200",
|
"description": "Successful call with status 200",
|
||||||
@@ -63,33 +63,33 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-counters-total": {
|
|
||||||
"entries": 2,
|
|
||||||
"failures": 0,
|
|
||||||
"firstSeen": 1567750580.7471218,
|
|
||||||
"lastSeen": 1567750581.7471218,
|
|
||||||
"sumRT": 1.26,
|
|
||||||
"sumDuration": 1
|
|
||||||
},
|
|
||||||
"x-counters-per-source": {
|
"x-counters-per-source": {
|
||||||
"": {
|
"": {
|
||||||
"entries": 2,
|
"entries": 2,
|
||||||
"failures": 0,
|
"failures": 0,
|
||||||
"firstSeen": 1567750580.7471218,
|
"firstSeen": 1567750580.74,
|
||||||
"lastSeen": 1567750581.7471218,
|
"lastSeen": 1567750581.74,
|
||||||
"sumRT": 1.26,
|
"sumRT": 1.26,
|
||||||
"sumDuration": 1
|
"sumDuration": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-sample-entry": 0,
|
"x-counters-total": {
|
||||||
"x-last-seen-ts": 1567750581.7471218
|
"entries": 2,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750580.74,
|
||||||
|
"lastSeen": 1567750581.74,
|
||||||
|
"sumRT": 1.26,
|
||||||
|
"sumDuration": 1
|
||||||
|
},
|
||||||
|
"x-last-seen-ts": 1567750581.74,
|
||||||
|
"x-sample-entry": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/body-optional": {
|
"/body-optional": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "/body-optional",
|
"summary": "/body-optional",
|
||||||
"description": "Mizu observed 3 entries (0 failed), at 0.003 hits/s, average response time is 0.001 seconds",
|
"description": "Mizu observed 3 entries (0 failed), at 0.00 hits/s, average response time is 0.00 seconds",
|
||||||
"operationId": "14d5b1c2-dc03-4ee5-baaa-5c7992acc82e",
|
"operationId": "<UUID4>",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Successful call with status 200",
|
"description": "Successful call with status 200",
|
||||||
@@ -98,26 +98,26 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-counters-total": {
|
|
||||||
"entries": 3,
|
|
||||||
"failures": 0,
|
|
||||||
"firstSeen": 1567750581.7471218,
|
|
||||||
"lastSeen": 1567750581.757122,
|
|
||||||
"sumRT": 0.003,
|
|
||||||
"sumDuration": 0.010000228881835938
|
|
||||||
},
|
|
||||||
"x-sample-entry": 0,
|
|
||||||
"x-counters-per-source": {
|
"x-counters-per-source": {
|
||||||
"": {
|
"": {
|
||||||
"entries": 3,
|
"entries": 3,
|
||||||
"failures": 0,
|
"failures": 0,
|
||||||
"firstSeen": 1567750581.7471218,
|
"firstSeen": 1567750581.74,
|
||||||
"lastSeen": 1567750581.757122,
|
"lastSeen": 1567750581.75,
|
||||||
"sumRT": 0.003,
|
"sumRT": 0.00,
|
||||||
"sumDuration": 0.010000228881835938
|
"sumDuration": 0.01
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-last-seen-ts": 1567750581.757122,
|
"x-counters-total": {
|
||||||
|
"entries": 3,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750581.74,
|
||||||
|
"lastSeen": 1567750581.75,
|
||||||
|
"sumRT": 0.00,
|
||||||
|
"sumDuration": 0.01
|
||||||
|
},
|
||||||
|
"x-last-seen-ts": 1567750581.75,
|
||||||
|
"x-sample-entry": 0,
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"description": "Generic request body",
|
"description": "Generic request body",
|
||||||
"content": {
|
"content": {
|
||||||
@@ -131,8 +131,8 @@
|
|||||||
"/body-required": {
|
"/body-required": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "/body-required",
|
"summary": "/body-required",
|
||||||
"description": "Mizu observed 1 entries (0 failed), at 0.000 hits/s, average response time is 0.001 seconds",
|
"description": "Mizu observed 1 entries (0 failed), at 0.00 hits/s, average response time is 0.00 seconds",
|
||||||
"operationId": "d0958c5a-dce6-4616-99f4-201dbc51457a",
|
"operationId": "<UUID4>",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Successful call with status 200",
|
"description": "Successful call with status 200",
|
||||||
@@ -145,22 +145,22 @@
|
|||||||
"": {
|
"": {
|
||||||
"entries": 1,
|
"entries": 1,
|
||||||
"failures": 0,
|
"failures": 0,
|
||||||
"firstSeen": 1567750581.757122,
|
"firstSeen": 1567750581.75,
|
||||||
"lastSeen": 1567750581.757122,
|
"lastSeen": 1567750581.75,
|
||||||
"sumRT": 0.001,
|
"sumRT": 0.00,
|
||||||
"sumDuration": 0
|
"sumDuration": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-sample-entry": 0,
|
|
||||||
"x-counters-total": {
|
"x-counters-total": {
|
||||||
"entries": 1,
|
"entries": 1,
|
||||||
"failures": 0,
|
"failures": 0,
|
||||||
"firstSeen": 1567750581.757122,
|
"firstSeen": 1567750581.75,
|
||||||
"lastSeen": 1567750581.757122,
|
"lastSeen": 1567750581.75,
|
||||||
"sumRT": 0.001,
|
"sumRT": 0.00,
|
||||||
"sumDuration": 0
|
"sumDuration": 0
|
||||||
},
|
},
|
||||||
"x-last-seen-ts": 1567750581.757122,
|
"x-last-seen-ts": 1567750581.75,
|
||||||
|
"x-sample-entry": 0,
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"description": "Generic request body",
|
"description": "Generic request body",
|
||||||
"content": {
|
"content": {
|
||||||
@@ -175,8 +175,8 @@
|
|||||||
"/form-multipart": {
|
"/form-multipart": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "/form-multipart",
|
"summary": "/form-multipart",
|
||||||
"description": "Mizu observed 1 entries (0 failed), at 0.000 hits/s, average response time is 0.001 seconds",
|
"description": "Mizu observed 1 entries (0 failed), at 0.00 hits/s, average response time is 0.00 seconds",
|
||||||
"operationId": "cab5a2f3-c18a-4d5a-8f92-e40da4fd6603",
|
"operationId": "<UUID4>",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Successful call with status 200",
|
"description": "Successful call with status 200",
|
||||||
@@ -187,26 +187,26 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-sample-entry": 0,
|
|
||||||
"x-counters-per-source": {
|
"x-counters-per-source": {
|
||||||
"": {
|
"": {
|
||||||
"entries": 1,
|
"entries": 1,
|
||||||
"failures": 0,
|
"failures": 0,
|
||||||
"firstSeen": 1567750582.7471218,
|
"firstSeen": 1567750582.74,
|
||||||
"lastSeen": 1567750582.7471218,
|
"lastSeen": 1567750582.74,
|
||||||
"sumRT": 0.001,
|
"sumRT": 0.00,
|
||||||
"sumDuration": 0
|
"sumDuration": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-last-seen-ts": 1567750582.7471218,
|
|
||||||
"x-counters-total": {
|
"x-counters-total": {
|
||||||
"entries": 1,
|
"entries": 1,
|
||||||
"failures": 0,
|
"failures": 0,
|
||||||
"firstSeen": 1567750582.7471218,
|
"firstSeen": 1567750582.74,
|
||||||
"lastSeen": 1567750582.7471218,
|
"lastSeen": 1567750582.74,
|
||||||
"sumRT": 0.001,
|
"sumRT": 0.00,
|
||||||
"sumDuration": 0
|
"sumDuration": 0
|
||||||
},
|
},
|
||||||
|
"x-last-seen-ts": 1567750582.74,
|
||||||
|
"x-sample-entry": 0,
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"description": "Generic request body",
|
"description": "Generic request body",
|
||||||
"content": {
|
"content": {
|
||||||
@@ -243,8 +243,8 @@
|
|||||||
"/form-urlencoded": {
|
"/form-urlencoded": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "/form-urlencoded",
|
"summary": "/form-urlencoded",
|
||||||
"description": "Mizu observed 2 entries (0 failed), at 0.500 hits/s, average response time is 0.001 seconds",
|
"description": "Mizu observed 2 entries (0 failed), at 0.50 hits/s, average response time is 0.00 seconds",
|
||||||
"operationId": "7c373ad7-6ab5-422e-971b-1cf56b18a7a2",
|
"operationId": "<UUID4>",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Successful call with status 200",
|
"description": "Successful call with status 200",
|
||||||
@@ -253,25 +253,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-last-seen-ts": 1567750581.7471218,
|
|
||||||
"x-counters-total": {
|
|
||||||
"entries": 2,
|
|
||||||
"failures": 0,
|
|
||||||
"firstSeen": 1567750580.7471218,
|
|
||||||
"lastSeen": 1567750581.7471218,
|
|
||||||
"sumRT": 0.002,
|
|
||||||
"sumDuration": 1
|
|
||||||
},
|
|
||||||
"x-counters-per-source": {
|
"x-counters-per-source": {
|
||||||
"": {
|
"": {
|
||||||
"entries": 2,
|
"entries": 2,
|
||||||
"failures": 0,
|
"failures": 0,
|
||||||
"firstSeen": 1567750580.7471218,
|
"firstSeen": 1567750580.74,
|
||||||
"lastSeen": 1567750581.7471218,
|
"lastSeen": 1567750581.74,
|
||||||
"sumRT": 0.002,
|
"sumRT": 0.00,
|
||||||
"sumDuration": 1
|
"sumDuration": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"x-counters-total": {
|
||||||
|
"entries": 2,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750580.74,
|
||||||
|
"lastSeen": 1567750581.74,
|
||||||
|
"sumRT": 0.00,
|
||||||
|
"sumDuration": 1
|
||||||
|
},
|
||||||
|
"x-last-seen-ts": 1567750581.74,
|
||||||
"x-sample-entry": 0,
|
"x-sample-entry": 0,
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"description": "Generic request body",
|
"description": "Generic request body",
|
||||||
@@ -319,11 +319,347 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/param-patterns/prefix-gibberish-fine/{prefixgibberishfineId}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"param-patterns"
|
||||||
|
],
|
||||||
|
"summary": "/param-patterns/prefix-gibberish-fine/{prefixgibberishfineId}",
|
||||||
|
"description": "Mizu observed 1 entries (0 failed), at 0.00 hits/s, average response time is 0.00 seconds",
|
||||||
|
"operationId": "<UUID4>",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Successful call with status 200",
|
||||||
|
"content": {
|
||||||
|
"": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-counters-per-source": {
|
||||||
|
"": {
|
||||||
|
"entries": 1,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750582,
|
||||||
|
"lastSeen": 1567750582,
|
||||||
|
"sumRT": 0.00,
|
||||||
|
"sumDuration": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-counters-total": {
|
||||||
|
"entries": 1,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750582,
|
||||||
|
"lastSeen": 1567750582,
|
||||||
|
"sumRT": 0.00,
|
||||||
|
"sumDuration": 0
|
||||||
|
},
|
||||||
|
"x-last-seen-ts": 1567750582,
|
||||||
|
"x-sample-entry": 0
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "prefixgibberishfineId",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"style": "simple",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
|
"example #0": {
|
||||||
|
"value": "234324"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"/param-patterns/{parampatternId}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"param-patterns"
|
||||||
|
],
|
||||||
|
"summary": "/param-patterns/{parampatternId}",
|
||||||
|
"description": "Mizu observed 2 entries (0 failed), at 0.00 hits/s, average response time is 0.00 seconds",
|
||||||
|
"operationId": "<UUID4>",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Successful call with status 200",
|
||||||
|
"content": {
|
||||||
|
"": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-counters-per-source": {
|
||||||
|
"": {
|
||||||
|
"entries": 2,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750582.00,
|
||||||
|
"lastSeen": 1567750582.00,
|
||||||
|
"sumRT": 0.00,
|
||||||
|
"sumDuration": 9.53e-7
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-counters-total": {
|
||||||
|
"entries": 2,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750582.00,
|
||||||
|
"lastSeen": 1567750582.00,
|
||||||
|
"sumRT": 0.00,
|
||||||
|
"sumDuration": 9.53e-7
|
||||||
|
},
|
||||||
|
"x-last-seen-ts": 1567750582.00,
|
||||||
|
"x-sample-entry": 0
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "parampatternId",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"style": "simple",
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^prefix-gibberish-.+"
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
|
"example #0": {
|
||||||
|
"value": "prefix-gibberish-sfdlasdfkadf87sd93284q24r"
|
||||||
|
},
|
||||||
|
"example #1": {
|
||||||
|
"value": "prefix-gibberish-adslkfasdf89sa7dfasddafa8a98sd7kansdf"
|
||||||
|
},
|
||||||
|
"example #2": {
|
||||||
|
"value": "prefix-gibberish-4jk5l2345h2452l4352435jlk45"
|
||||||
|
},
|
||||||
|
"example #3": {
|
||||||
|
"value": "prefix-gibberish-84395h2j4k35hj243j5h2kl34h54k"
|
||||||
|
},
|
||||||
|
"example #4": {
|
||||||
|
"value": "prefix-gibberish-afterwards"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"/param-patterns/{parampatternId}/1": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"param-patterns"
|
||||||
|
],
|
||||||
|
"summary": "/param-patterns/{parampatternId}/1",
|
||||||
|
"description": "Mizu observed 1 entries (0 failed), at 0.00 hits/s, average response time is 0.00 seconds",
|
||||||
|
"operationId": "<UUID4>",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Successful call with status 200",
|
||||||
|
"content": {
|
||||||
|
"": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-counters-per-source": {
|
||||||
|
"": {
|
||||||
|
"entries": 1,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750582.00,
|
||||||
|
"lastSeen": 1567750582.00,
|
||||||
|
"sumRT": 0.00,
|
||||||
|
"sumDuration": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-counters-total": {
|
||||||
|
"entries": 1,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750582.00,
|
||||||
|
"lastSeen": 1567750582.00,
|
||||||
|
"sumRT": 0.00,
|
||||||
|
"sumDuration": 0
|
||||||
|
},
|
||||||
|
"x-last-seen-ts": 1567750582.00,
|
||||||
|
"x-sample-entry": 0
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "parampatternId",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"style": "simple",
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^prefix-gibberish-.+"
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
|
"example #0": {
|
||||||
|
"value": "prefix-gibberish-sfdlasdfkadf87sd93284q24r"
|
||||||
|
},
|
||||||
|
"example #1": {
|
||||||
|
"value": "prefix-gibberish-adslkfasdf89sa7dfasddafa8a98sd7kansdf"
|
||||||
|
},
|
||||||
|
"example #2": {
|
||||||
|
"value": "prefix-gibberish-4jk5l2345h2452l4352435jlk45"
|
||||||
|
},
|
||||||
|
"example #3": {
|
||||||
|
"value": "prefix-gibberish-84395h2j4k35hj243j5h2kl34h54k"
|
||||||
|
},
|
||||||
|
"example #4": {
|
||||||
|
"value": "prefix-gibberish-afterwards"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"/param-patterns/{parampatternId}/static": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"param-patterns"
|
||||||
|
],
|
||||||
|
"summary": "/param-patterns/{parampatternId}/static",
|
||||||
|
"description": "Mizu observed 1 entries (0 failed), at 0.00 hits/s, average response time is 0.00 seconds",
|
||||||
|
"operationId": "<UUID4>",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Successful call with status 200",
|
||||||
|
"content": {
|
||||||
|
"": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-counters-per-source": {
|
||||||
|
"": {
|
||||||
|
"entries": 1,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750582.00,
|
||||||
|
"lastSeen": 1567750582.00,
|
||||||
|
"sumRT": 0.00,
|
||||||
|
"sumDuration": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-counters-total": {
|
||||||
|
"entries": 1,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750582.00,
|
||||||
|
"lastSeen": 1567750582.00,
|
||||||
|
"sumRT": 0.00,
|
||||||
|
"sumDuration": 0
|
||||||
|
},
|
||||||
|
"x-last-seen-ts": 1567750582.00,
|
||||||
|
"x-sample-entry": 0
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "parampatternId",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"style": "simple",
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^prefix-gibberish-.+"
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
|
"example #0": {
|
||||||
|
"value": "prefix-gibberish-sfdlasdfkadf87sd93284q24r"
|
||||||
|
},
|
||||||
|
"example #1": {
|
||||||
|
"value": "prefix-gibberish-adslkfasdf89sa7dfasddafa8a98sd7kansdf"
|
||||||
|
},
|
||||||
|
"example #2": {
|
||||||
|
"value": "prefix-gibberish-4jk5l2345h2452l4352435jlk45"
|
||||||
|
},
|
||||||
|
"example #3": {
|
||||||
|
"value": "prefix-gibberish-84395h2j4k35hj243j5h2kl34h54k"
|
||||||
|
},
|
||||||
|
"example #4": {
|
||||||
|
"value": "prefix-gibberish-afterwards"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"/param-patterns/{parampatternId}/{param1}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"param-patterns"
|
||||||
|
],
|
||||||
|
"summary": "/param-patterns/{parampatternId}/{param1}",
|
||||||
|
"description": "Mizu observed 1 entries (0 failed), at 0.00 hits/s, average response time is 0.00 seconds",
|
||||||
|
"operationId": "<UUID4>",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Successful call with status 200",
|
||||||
|
"content": {
|
||||||
|
"": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-counters-per-source": {
|
||||||
|
"": {
|
||||||
|
"entries": 1,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750582.00,
|
||||||
|
"lastSeen": 1567750582.00,
|
||||||
|
"sumRT": 0.00,
|
||||||
|
"sumDuration": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-counters-total": {
|
||||||
|
"entries": 1,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750582.00,
|
||||||
|
"lastSeen": 1567750582.00,
|
||||||
|
"sumRT": 0.00,
|
||||||
|
"sumDuration": 0
|
||||||
|
},
|
||||||
|
"x-last-seen-ts": 1567750582.00,
|
||||||
|
"x-sample-entry": 0
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "param1",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"style": "simple",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
|
"example #0": {
|
||||||
|
"value": "23421"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "parampatternId",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"style": "simple",
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^prefix-gibberish-.+"
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
|
"example #0": {
|
||||||
|
"value": "prefix-gibberish-sfdlasdfkadf87sd93284q24r"
|
||||||
|
},
|
||||||
|
"example #1": {
|
||||||
|
"value": "prefix-gibberish-adslkfasdf89sa7dfasddafa8a98sd7kansdf"
|
||||||
|
},
|
||||||
|
"example #2": {
|
||||||
|
"value": "prefix-gibberish-4jk5l2345h2452l4352435jlk45"
|
||||||
|
},
|
||||||
|
"example #3": {
|
||||||
|
"value": "prefix-gibberish-84395h2j4k35hj243j5h2kl34h54k"
|
||||||
|
},
|
||||||
|
"example #4": {
|
||||||
|
"value": "prefix-gibberish-afterwards"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"/{Id}": {
|
"/{Id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "/{Id}",
|
"summary": "/{Id}",
|
||||||
"description": "Mizu observed 1 entries (0 failed), at 0.000 hits/s, average response time is 0.630 seconds",
|
"description": "Mizu observed 1 entries (0 failed), at 0.00 hits/s, average response time is 0.63 seconds",
|
||||||
"operationId": "99f1d11f-29c0-48f9-8bf0-9f4b407c7c3f",
|
"operationId": "<UUID4>",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Successful call with status 200",
|
"description": "Successful call with status 200",
|
||||||
@@ -334,26 +670,26 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-sample-entry": 0,
|
|
||||||
"x-last-seen-ts": 1567750579.7471218,
|
|
||||||
"x-counters-total": {
|
|
||||||
"entries": 1,
|
|
||||||
"failures": 0,
|
|
||||||
"firstSeen": 1567750579.7471218,
|
|
||||||
"lastSeen": 1567750579.7471218,
|
|
||||||
"sumRT": 0.63,
|
|
||||||
"sumDuration": 0
|
|
||||||
},
|
|
||||||
"x-counters-per-source": {
|
"x-counters-per-source": {
|
||||||
"": {
|
"": {
|
||||||
"entries": 1,
|
"entries": 1,
|
||||||
"failures": 0,
|
"failures": 0,
|
||||||
"firstSeen": 1567750579.7471218,
|
"firstSeen": 1567750579.74,
|
||||||
"lastSeen": 1567750579.7471218,
|
"lastSeen": 1567750579.74,
|
||||||
"sumRT": 0.63,
|
"sumRT": 0.63,
|
||||||
"sumDuration": 0
|
"sumDuration": 0
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"x-counters-total": {
|
||||||
|
"entries": 1,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750579.74,
|
||||||
|
"lastSeen": 1567750579.74,
|
||||||
|
"sumRT": 0.63,
|
||||||
|
"sumDuration": 0
|
||||||
|
},
|
||||||
|
"x-last-seen-ts": 1567750579.74,
|
||||||
|
"x-sample-entry": 0
|
||||||
},
|
},
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
@@ -366,10 +702,10 @@
|
|||||||
},
|
},
|
||||||
"examples": {
|
"examples": {
|
||||||
"example #0": {
|
"example #0": {
|
||||||
"value": "e21f7112-3d3b-4632-9da3-a4af2e0e9166"
|
"value": "<UUID4>"
|
||||||
},
|
},
|
||||||
"example #1": {
|
"example #1": {
|
||||||
"value": "952bea17-3776-11ea-9341-42010a84012a"
|
"value": "<UUID4>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -378,8 +714,8 @@
|
|||||||
"/{Id}/sub1": {
|
"/{Id}/sub1": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "/{Id}/sub1",
|
"summary": "/{Id}/sub1",
|
||||||
"description": "Mizu observed 1 entries (0 failed), at 0.000 hits/s, average response time is 0.111 seconds",
|
"description": "Mizu observed 1 entries (0 failed), at 0.00 hits/s, average response time is 0.11 seconds",
|
||||||
"operationId": "f7e299d2-253c-4eef-975c-9a5659a7fc50",
|
"operationId": "<UUID4>",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Successful call with status 200",
|
"description": "Successful call with status 200",
|
||||||
@@ -388,25 +724,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-last-seen-ts": 1567750483.864529,
|
|
||||||
"x-counters-total": {
|
|
||||||
"entries": 1,
|
|
||||||
"failures": 0,
|
|
||||||
"firstSeen": 1567750483.864529,
|
|
||||||
"lastSeen": 1567750483.864529,
|
|
||||||
"sumRT": 0.111,
|
|
||||||
"sumDuration": 0
|
|
||||||
},
|
|
||||||
"x-counters-per-source": {
|
"x-counters-per-source": {
|
||||||
"": {
|
"": {
|
||||||
"entries": 1,
|
"entries": 1,
|
||||||
"failures": 0,
|
"failures": 0,
|
||||||
"firstSeen": 1567750483.864529,
|
"firstSeen": 1567750483.86,
|
||||||
"lastSeen": 1567750483.864529,
|
"lastSeen": 1567750483.86,
|
||||||
"sumRT": 0.111,
|
"sumRT": 0.11,
|
||||||
"sumDuration": 0
|
"sumDuration": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"x-counters-total": {
|
||||||
|
"entries": 1,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750483.86,
|
||||||
|
"lastSeen": 1567750483.86,
|
||||||
|
"sumRT": 0.11,
|
||||||
|
"sumDuration": 0
|
||||||
|
},
|
||||||
|
"x-last-seen-ts": 1567750483.86,
|
||||||
"x-sample-entry": 0
|
"x-sample-entry": 0
|
||||||
},
|
},
|
||||||
"parameters": [
|
"parameters": [
|
||||||
@@ -420,10 +756,10 @@
|
|||||||
},
|
},
|
||||||
"examples": {
|
"examples": {
|
||||||
"example #0": {
|
"example #0": {
|
||||||
"value": "e21f7112-3d3b-4632-9da3-a4af2e0e9166"
|
"value": "<UUID4>"
|
||||||
},
|
},
|
||||||
"example #1": {
|
"example #1": {
|
||||||
"value": "952bea17-3776-11ea-9341-42010a84012a"
|
"value": "<UUID4>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -432,8 +768,8 @@
|
|||||||
"/{Id}/sub2": {
|
"/{Id}/sub2": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "/{Id}/sub2",
|
"summary": "/{Id}/sub2",
|
||||||
"description": "Mizu observed 1 entries (0 failed), at 0.000 hits/s, average response time is 0.630 seconds",
|
"description": "Mizu observed 1 entries (0 failed), at 0.00 hits/s, average response time is 0.63 seconds",
|
||||||
"operationId": "23a54e06-4298-4ea5-b1f0-09b0354a0598",
|
"operationId": "<UUID4>",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Successful call with status 200",
|
"description": "Successful call with status 200",
|
||||||
@@ -444,25 +780,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-last-seen-ts": 1567750578.7471218,
|
|
||||||
"x-counters-total": {
|
|
||||||
"entries": 1,
|
|
||||||
"failures": 0,
|
|
||||||
"firstSeen": 1567750578.7471218,
|
|
||||||
"lastSeen": 1567750578.7471218,
|
|
||||||
"sumRT": 0.63,
|
|
||||||
"sumDuration": 0
|
|
||||||
},
|
|
||||||
"x-counters-per-source": {
|
"x-counters-per-source": {
|
||||||
"": {
|
"": {
|
||||||
"entries": 1,
|
"entries": 1,
|
||||||
"failures": 0,
|
"failures": 0,
|
||||||
"firstSeen": 1567750578.7471218,
|
"firstSeen": 1567750578.74,
|
||||||
"lastSeen": 1567750578.7471218,
|
"lastSeen": 1567750578.74,
|
||||||
"sumRT": 0.63,
|
"sumRT": 0.63,
|
||||||
"sumDuration": 0
|
"sumDuration": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"x-counters-total": {
|
||||||
|
"entries": 1,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750578.74,
|
||||||
|
"lastSeen": 1567750578.74,
|
||||||
|
"sumRT": 0.63,
|
||||||
|
"sumDuration": 0
|
||||||
|
},
|
||||||
|
"x-last-seen-ts": 1567750578.74,
|
||||||
"x-sample-entry": 0
|
"x-sample-entry": 0
|
||||||
},
|
},
|
||||||
"parameters": [
|
"parameters": [
|
||||||
@@ -476,32 +812,32 @@
|
|||||||
},
|
},
|
||||||
"examples": {
|
"examples": {
|
||||||
"example #0": {
|
"example #0": {
|
||||||
"value": "e21f7112-3d3b-4632-9da3-a4af2e0e9166"
|
"value": "<UUID4>"
|
||||||
},
|
},
|
||||||
"example #1": {
|
"example #1": {
|
||||||
"value": "952bea17-3776-11ea-9341-42010a84012a"
|
"value": "<UUID4>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-counters-total": {
|
|
||||||
"entries": 13,
|
|
||||||
"failures": 0,
|
|
||||||
"firstSeen": 1567750483.864529,
|
|
||||||
"lastSeen": 1567750582.7471218,
|
|
||||||
"sumRT": 3.268,
|
|
||||||
"sumDuration": 2.010000228881836
|
|
||||||
},
|
|
||||||
"x-counters-per-source": {
|
"x-counters-per-source": {
|
||||||
"": {
|
"": {
|
||||||
"entries": 13,
|
"entries": 19,
|
||||||
"failures": 0,
|
"failures": 0,
|
||||||
"firstSeen": 1567750483.864529,
|
"firstSeen": 1567750483.86,
|
||||||
"lastSeen": 1567750582.7471218,
|
"lastSeen": 1567750582.74,
|
||||||
"sumRT": 3.268,
|
"sumRT": 3.27,
|
||||||
"sumDuration": 2.010000228881836
|
"sumDuration": 2.01
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"x-counters-total": {
|
||||||
|
"entries": 19,
|
||||||
|
"failures": 0,
|
||||||
|
"firstSeen": 1567750483.86,
|
||||||
|
"lastSeen": 1567750582.74,
|
||||||
|
"sumRT": 3.27,
|
||||||
|
"sumDuration": 2.01
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
50
agent/pkg/oas/test_artifacts/trcc.json
Normal file
50
agent/pkg/oas/test_artifacts/trcc.json
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"info": {
|
||||||
|
"title": "Preloaded TRCC",
|
||||||
|
"version": "0.1",
|
||||||
|
"description": "Test file for loading pre-existing OAS"
|
||||||
|
},
|
||||||
|
"paths": {
|
||||||
|
"/models/{id}": {
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"style": "simple",
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": ".+(_|-|\\.).+"
|
||||||
|
},
|
||||||
|
"example": "some-uuid-maybe"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"/models/{id}/{id2}": {
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"style": "simple",
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": ".+(_|-|\\.).+"
|
||||||
|
},
|
||||||
|
"example": "some-uuid-maybe"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "id2",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"style": "simple",
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "\\d+"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
package oas
|
package oas
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"encoding/json"
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/chanced/openapi"
|
"github.com/chanced/openapi"
|
||||||
"github.com/up9inc/mizu/shared/logger"
|
"github.com/up9inc/mizu/shared/logger"
|
||||||
|
"net/url"
|
||||||
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NodePath = []string
|
type NodePath = []string
|
||||||
@@ -49,8 +50,8 @@ func (n *Node) getOrSet(path NodePath, existingPathObj *openapi.PathObj) (node *
|
|||||||
node = n.searchInConstants(pathChunk)
|
node = n.searchInConstants(pathChunk)
|
||||||
}
|
}
|
||||||
|
|
||||||
if node == nil {
|
if node == nil && pathChunk != "" {
|
||||||
node = n.searchInParams(paramObj, chunkIsGibberish)
|
node = n.searchInParams(paramObj, pathChunk, chunkIsGibberish)
|
||||||
}
|
}
|
||||||
|
|
||||||
// still no node found, should create it
|
// still no node found, should create it
|
||||||
@@ -76,6 +77,10 @@ func (n *Node) getOrSet(path NodePath, existingPathObj *openapi.PathObj) (node *
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Log.Warningf("Failed to add example to a parameter: %s", err)
|
logger.Log.Warningf("Failed to add example to a parameter: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(*exmp) >= 3 && node.pathParam.Schema.Pattern == nil { // is it enough to decide on 2 samples?
|
||||||
|
node.pathParam.Schema.Pattern = getPatternFromExamples(exmp)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: eat up trailing slash, in a smart way: node.pathObj!=nil && path[1]==""
|
// TODO: eat up trailing slash, in a smart way: node.pathObj!=nil && path[1]==""
|
||||||
@@ -88,6 +93,57 @@ func (n *Node) getOrSet(path NodePath, existingPathObj *openapi.PathObj) (node *
|
|||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getPatternFromExamples(exmp *openapi.Examples) *openapi.Regexp {
|
||||||
|
allInts := true
|
||||||
|
strs := make([]string, 0)
|
||||||
|
for _, example := range *exmp {
|
||||||
|
exampleObj, err := example.ResolveExample(exampleResolver)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var value string
|
||||||
|
err = json.Unmarshal(exampleObj.Value, &value)
|
||||||
|
if err != nil {
|
||||||
|
logger.Log.Warningf("Failed decoding parameter example into string: %s", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
strs = append(strs, value)
|
||||||
|
|
||||||
|
if _, err := strconv.Atoi(value); err != nil {
|
||||||
|
allInts = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if allInts {
|
||||||
|
re := new(openapi.Regexp)
|
||||||
|
re.Regexp = regexp.MustCompile(`\d+`)
|
||||||
|
return re
|
||||||
|
} else {
|
||||||
|
prefix := longestCommonXfixStr(strs, true)
|
||||||
|
suffix := longestCommonXfixStr(strs, false)
|
||||||
|
|
||||||
|
pat := ""
|
||||||
|
separators := "-._/:|*,+" // TODO: we could also cut prefix till the last separator
|
||||||
|
if len(prefix) > 0 && strings.Contains(separators, string(prefix[len(prefix)-1])) {
|
||||||
|
pat = "^" + regexp.QuoteMeta(prefix)
|
||||||
|
}
|
||||||
|
|
||||||
|
pat += ".+"
|
||||||
|
|
||||||
|
if len(suffix) > 0 && strings.Contains(separators, string(suffix[0])) {
|
||||||
|
pat += regexp.QuoteMeta(suffix) + "$"
|
||||||
|
}
|
||||||
|
|
||||||
|
if pat != ".+" {
|
||||||
|
re := new(openapi.Regexp)
|
||||||
|
re.Regexp = regexp.MustCompile(pat)
|
||||||
|
return re
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (n *Node) createParam() *openapi.ParameterObj {
|
func (n *Node) createParam() *openapi.ParameterObj {
|
||||||
name := "param"
|
name := "param"
|
||||||
|
|
||||||
@@ -118,23 +174,30 @@ func (n *Node) createParam() *openapi.ParameterObj {
|
|||||||
return newParam
|
return newParam
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) searchInParams(paramObj *openapi.ParameterObj, chunkIsGibberish bool) *Node {
|
func (n *Node) searchInParams(paramObj *openapi.ParameterObj, chunk string, chunkIsGibberish bool) *Node {
|
||||||
// look among params
|
// look among params
|
||||||
if paramObj != nil || chunkIsGibberish {
|
for _, subnode := range n.children {
|
||||||
for _, subnode := range n.children {
|
if subnode.constant != nil {
|
||||||
if subnode.constant != nil {
|
continue
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: check the regex pattern of param? for exceptions etc
|
|
||||||
|
|
||||||
if paramObj != nil {
|
|
||||||
// TODO: mergeParam(subnode.pathParam, paramObj)
|
|
||||||
return subnode
|
|
||||||
} else {
|
|
||||||
return subnode
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if paramObj != nil {
|
||||||
|
// TODO: mergeParam(subnode.pathParam, paramObj)
|
||||||
|
return subnode
|
||||||
|
} else if subnode.pathParam.Schema.Pattern != nil { // it has defined param pattern, have to respect it
|
||||||
|
// TODO: and not in exceptions
|
||||||
|
if subnode.pathParam.Schema.Pattern.Match([]byte(chunk)) {
|
||||||
|
return subnode
|
||||||
|
} else if chunkIsGibberish {
|
||||||
|
// TODO: what to do if gibberish chunk does not match the pattern and not in exceptions?
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
} else if chunkIsGibberish {
|
||||||
|
return subnode
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -290,6 +290,53 @@ func longestCommonXfix(strs [][]string, pre bool) []string { // https://github.c
|
|||||||
return xfix
|
return xfix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func longestCommonXfixStr(strs []string, pre bool) string { // https://github.com/jpillora/longestcommon
|
||||||
|
//short-circuit empty list
|
||||||
|
if len(strs) == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
xfix := strs[0]
|
||||||
|
//short-circuit single-element list
|
||||||
|
if len(strs) == 1 {
|
||||||
|
return xfix
|
||||||
|
}
|
||||||
|
//compare first to rest
|
||||||
|
for _, str := range strs[1:] {
|
||||||
|
xfixl := len(xfix)
|
||||||
|
strl := len(str)
|
||||||
|
//short-circuit empty strings
|
||||||
|
if xfixl == 0 || strl == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
//maximum possible length
|
||||||
|
maxl := xfixl
|
||||||
|
if strl < maxl {
|
||||||
|
maxl = strl
|
||||||
|
}
|
||||||
|
//compare letters
|
||||||
|
if pre {
|
||||||
|
//prefix, iterate left to right
|
||||||
|
for i := 0; i < maxl; i++ {
|
||||||
|
if xfix[i] != str[i] {
|
||||||
|
xfix = xfix[:i]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//suffix, iternate right to left
|
||||||
|
for i := 0; i < maxl; i++ {
|
||||||
|
xi := xfixl - i - 1
|
||||||
|
si := strl - i - 1
|
||||||
|
if xfix[xi] != str[si] {
|
||||||
|
xfix = xfix[xi+1:]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return xfix
|
||||||
|
}
|
||||||
|
|
||||||
func getSimilarPrefix(strs []string) string {
|
func getSimilarPrefix(strs []string) string {
|
||||||
chunked := make([][]string, 0)
|
chunked := make([][]string, 0)
|
||||||
for _, item := range strs {
|
for _, item := range strs {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ type serviceMap struct {
|
|||||||
|
|
||||||
type ServiceMap interface {
|
type ServiceMap interface {
|
||||||
Enable()
|
Enable()
|
||||||
|
Disable()
|
||||||
IsEnabled() bool
|
IsEnabled() bool
|
||||||
NewTCPEntry(source *tapApi.TCP, destination *tapApi.TCP, protocol *tapApi.Protocol)
|
NewTCPEntry(source *tapApi.TCP, destination *tapApi.TCP, protocol *tapApi.Protocol)
|
||||||
GetStatus() ServiceMapStatus
|
GetStatus() ServiceMapStatus
|
||||||
@@ -159,6 +160,11 @@ func (s *serviceMap) Enable() {
|
|||||||
s.enabled = true
|
s.enabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *serviceMap) Disable() {
|
||||||
|
s.Reset()
|
||||||
|
s.enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
func (s *serviceMap) IsEnabled() bool {
|
func (s *serviceMap) IsEnabled() bool {
|
||||||
return s.enabled
|
return s.enabled
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,13 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
core "k8s.io/api/core/v1"
|
||||||
rbac "k8s.io/api/rbac/v1"
|
rbac "k8s.io/api/rbac/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/up9inc/mizu/cli/apiserver"
|
"github.com/up9inc/mizu/cli/apiserver"
|
||||||
"github.com/up9inc/mizu/cli/config"
|
"github.com/up9inc/mizu/cli/config"
|
||||||
@@ -38,6 +41,10 @@ func runMizuCheck() {
|
|||||||
if checkPassed {
|
if checkPassed {
|
||||||
checkPassed = checkK8sTapPermissions(ctx, kubernetesProvider)
|
checkPassed = checkK8sTapPermissions(ctx, kubernetesProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if checkPassed {
|
||||||
|
checkPassed = checkImagePullInCluster(ctx, kubernetesProvider)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if checkPassed {
|
if checkPassed {
|
||||||
checkPassed = checkK8sResources(ctx, kubernetesProvider)
|
checkPassed = checkK8sResources(ctx, kubernetesProvider)
|
||||||
@@ -315,3 +322,104 @@ func checkPermissionExist(group string, resource string, verb string, exist bool
|
|||||||
logger.Log.Infof("%v can %v %v in group '%v'", fmt.Sprintf(uiUtils.Green, "√"), verb, resource, group)
|
logger.Log.Infof("%v can %v %v in group '%v'", fmt.Sprintf(uiUtils.Green, "√"), verb, resource, group)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkImagePullInCluster(ctx context.Context, kubernetesProvider *kubernetes.Provider) bool {
|
||||||
|
logger.Log.Infof("\nimage-pull-in-cluster\n--------------------")
|
||||||
|
|
||||||
|
podName := "image-pull-in-cluster"
|
||||||
|
|
||||||
|
defer removeImagePullInClusterResources(ctx, kubernetesProvider, podName)
|
||||||
|
if err := createImagePullInClusterResources(ctx, kubernetesProvider, podName); err != nil {
|
||||||
|
logger.Log.Errorf("%v error while creating image pull in cluster resources, err: %v", fmt.Sprintf(uiUtils.Red, "✗"), err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := checkImagePulled(ctx, kubernetesProvider, podName); err != nil {
|
||||||
|
logger.Log.Errorf("%v cluster is not able to pull mizu containers from docker hub, err: %v", fmt.Sprintf(uiUtils.Red, "✗"), err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Log.Infof("%v cluster is able to pull mizu containers from docker hub", fmt.Sprintf(uiUtils.Green, "√"))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkImagePulled(ctx context.Context, kubernetesProvider *kubernetes.Provider, podName string) error {
|
||||||
|
podExactRegex := regexp.MustCompile(fmt.Sprintf("^%s$", podName))
|
||||||
|
podWatchHelper := kubernetes.NewPodWatchHelper(kubernetesProvider, podExactRegex)
|
||||||
|
eventChan, errorChan := kubernetes.FilteredWatch(ctx, podWatchHelper, []string{config.Config.MizuResourcesNamespace}, podWatchHelper)
|
||||||
|
|
||||||
|
timeAfter := time.After(30 * time.Second)
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case wEvent, ok := <-eventChan:
|
||||||
|
if !ok {
|
||||||
|
eventChan = nil
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
pod, err := wEvent.ToPod()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if pod.Status.Phase == core.PodRunning {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
case err, ok := <-errorChan:
|
||||||
|
if !ok {
|
||||||
|
errorChan = nil
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
case <-timeAfter:
|
||||||
|
return fmt.Errorf("image not pulled in time")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeImagePullInClusterResources(ctx context.Context, kubernetesProvider *kubernetes.Provider, podName string) {
|
||||||
|
if err := kubernetesProvider.RemovePod(ctx, config.Config.MizuResourcesNamespace, podName); err != nil {
|
||||||
|
logger.Log.Debugf("error while removing image pull in cluster resources, err: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !config.Config.IsNsRestrictedMode() {
|
||||||
|
if err := kubernetesProvider.RemoveNamespace(ctx, config.Config.MizuResourcesNamespace); err != nil {
|
||||||
|
logger.Log.Debugf("error while removing image pull in cluster resources, err: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func createImagePullInClusterResources(ctx context.Context, kubernetesProvider *kubernetes.Provider, podName string) error {
|
||||||
|
if !config.Config.IsNsRestrictedMode() {
|
||||||
|
if _, err := kubernetesProvider.CreateNamespace(ctx, config.Config.MizuResourcesNamespace); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var zero int64
|
||||||
|
pod := &core.Pod{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: podName,
|
||||||
|
},
|
||||||
|
Spec: core.PodSpec{
|
||||||
|
Containers: []core.Container{
|
||||||
|
{
|
||||||
|
Name: "probe",
|
||||||
|
Image: "up9inc/busybox",
|
||||||
|
ImagePullPolicy: "Always",
|
||||||
|
Command: []string{"cat"},
|
||||||
|
Stdin: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
TerminationGracePeriodSeconds: &zero,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := kubernetesProvider.CreatePod(ctx, config.Config.MizuResourcesNamespace, pod); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ metadata:
|
|||||||
name: mizu-runner-debug-clusterrolebindings
|
name: mizu-runner-debug-clusterrolebindings
|
||||||
subjects:
|
subjects:
|
||||||
- kind: User
|
- kind: User
|
||||||
name: user1
|
name: user-with-clusterwide-access
|
||||||
apiGroup: rbac.authorization.k8s.io
|
apiGroup: rbac.authorization.k8s.io
|
||||||
roleRef:
|
roleRef:
|
||||||
kind: ClusterRole
|
kind: ClusterRole
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ metadata:
|
|||||||
name: mizu-resolver-clusterrolebindings
|
name: mizu-resolver-clusterrolebindings
|
||||||
subjects:
|
subjects:
|
||||||
- kind: User
|
- kind: User
|
||||||
name: user1
|
name: user-with-clusterwide-access
|
||||||
apiGroup: rbac.authorization.k8s.io
|
apiGroup: rbac.authorization.k8s.io
|
||||||
roleRef:
|
roleRef:
|
||||||
kind: ClusterRole
|
kind: ClusterRole
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ rules:
|
|||||||
- apiGroups: [""]
|
- apiGroups: [""]
|
||||||
resources: ["configmaps"]
|
resources: ["configmaps"]
|
||||||
verbs: ["create"]
|
verbs: ["create"]
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["pods/log"]
|
||||||
|
verbs: ["get"]
|
||||||
---
|
---
|
||||||
kind: ClusterRoleBinding
|
kind: ClusterRoleBinding
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
@@ -29,7 +32,7 @@ metadata:
|
|||||||
name: mizu-runner-clusterrolebindings
|
name: mizu-runner-clusterrolebindings
|
||||||
subjects:
|
subjects:
|
||||||
- kind: User
|
- kind: User
|
||||||
name: user1
|
name: user-with-clusterwide-access
|
||||||
apiGroup: rbac.authorization.k8s.io
|
apiGroup: rbac.authorization.k8s.io
|
||||||
roleRef:
|
roleRef:
|
||||||
kind: ClusterRole
|
kind: ClusterRole
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ kind: Role
|
|||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
metadata:
|
metadata:
|
||||||
name: mizu-runner-debug-role
|
name: mizu-runner-debug-role
|
||||||
namespace: user1
|
|
||||||
rules:
|
rules:
|
||||||
- apiGroups: ["events.k8s.io"]
|
- apiGroups: ["events.k8s.io"]
|
||||||
resources: ["events"]
|
resources: ["events"]
|
||||||
@@ -16,10 +15,9 @@ kind: RoleBinding
|
|||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
metadata:
|
metadata:
|
||||||
name: mizu-runner-debug-rolebindings
|
name: mizu-runner-debug-rolebindings
|
||||||
namespace: user1
|
|
||||||
subjects:
|
subjects:
|
||||||
- kind: User
|
- kind: User
|
||||||
name: user1
|
name: user-with-restricted-access
|
||||||
apiGroup: rbac.authorization.k8s.io
|
apiGroup: rbac.authorization.k8s.io
|
||||||
roleRef:
|
roleRef:
|
||||||
kind: Role
|
kind: Role
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ kind: Role
|
|||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
metadata:
|
metadata:
|
||||||
name: mizu-resolver-role
|
name: mizu-resolver-role
|
||||||
namespace: user1
|
|
||||||
rules:
|
rules:
|
||||||
- apiGroups: [""]
|
- apiGroups: [""]
|
||||||
resources: ["serviceaccounts"]
|
resources: ["serviceaccounts"]
|
||||||
@@ -28,10 +27,9 @@ kind: RoleBinding
|
|||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
metadata:
|
metadata:
|
||||||
name: mizu-resolver-rolebindings
|
name: mizu-resolver-rolebindings
|
||||||
namespace: user1
|
|
||||||
subjects:
|
subjects:
|
||||||
- kind: User
|
- kind: User
|
||||||
name: user1
|
name: user-with-restricted-access
|
||||||
apiGroup: rbac.authorization.k8s.io
|
apiGroup: rbac.authorization.k8s.io
|
||||||
roleRef:
|
roleRef:
|
||||||
kind: Role
|
kind: Role
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ kind: Role
|
|||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
metadata:
|
metadata:
|
||||||
name: mizu-runner-role
|
name: mizu-runner-role
|
||||||
namespace: user1
|
|
||||||
rules:
|
rules:
|
||||||
- apiGroups: [""]
|
- apiGroups: [""]
|
||||||
resources: ["pods"]
|
resources: ["pods"]
|
||||||
@@ -20,15 +19,17 @@ rules:
|
|||||||
- apiGroups: [""]
|
- apiGroups: [""]
|
||||||
resources: ["configmaps"]
|
resources: ["configmaps"]
|
||||||
verbs: ["create", "delete"]
|
verbs: ["create", "delete"]
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["pods/log"]
|
||||||
|
verbs: ["get"]
|
||||||
---
|
---
|
||||||
kind: RoleBinding
|
kind: RoleBinding
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
metadata:
|
metadata:
|
||||||
name: mizu-runner-rolebindings
|
name: mizu-runner-rolebindings
|
||||||
namespace: user1
|
|
||||||
subjects:
|
subjects:
|
||||||
- kind: User
|
- kind: User
|
||||||
name: user1
|
name: user-with-restricted-access
|
||||||
apiGroup: rbac.authorization.k8s.io
|
apiGroup: rbac.authorization.k8s.io
|
||||||
roleRef:
|
roleRef:
|
||||||
kind: Role
|
kind: Role
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/up9inc/mizu/cli/up9"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/up9inc/mizu/cli/up9"
|
||||||
|
|
||||||
"github.com/creasty/defaults"
|
"github.com/creasty/defaults"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/up9inc/mizu/cli/auth"
|
"github.com/up9inc/mizu/cli/auth"
|
||||||
@@ -115,6 +116,7 @@ func init() {
|
|||||||
tapCmd.Flags().StringSliceP(configStructs.PlainTextFilterRegexesTapName, "r", defaultTapConfig.PlainTextFilterRegexes, "List of regex expressions that are used to filter matching values from text/plain http bodies")
|
tapCmd.Flags().StringSliceP(configStructs.PlainTextFilterRegexesTapName, "r", defaultTapConfig.PlainTextFilterRegexes, "List of regex expressions that are used to filter matching values from text/plain http bodies")
|
||||||
tapCmd.Flags().Bool(configStructs.DisableRedactionTapName, defaultTapConfig.DisableRedaction, "Disables redaction of potentially sensitive request/response headers and body values")
|
tapCmd.Flags().Bool(configStructs.DisableRedactionTapName, defaultTapConfig.DisableRedaction, "Disables redaction of potentially sensitive request/response headers and body values")
|
||||||
tapCmd.Flags().String(configStructs.HumanMaxEntriesDBSizeTapName, defaultTapConfig.HumanMaxEntriesDBSize, "Override the default max entries db size")
|
tapCmd.Flags().String(configStructs.HumanMaxEntriesDBSizeTapName, defaultTapConfig.HumanMaxEntriesDBSize, "Override the default max entries db size")
|
||||||
|
tapCmd.Flags().String(configStructs.InsertionFilterName, defaultTapConfig.InsertionFilter, "Set the insertion filter. Accepts string or a file path.")
|
||||||
tapCmd.Flags().Bool(configStructs.DryRunTapName, defaultTapConfig.DryRun, "Preview of all pods matching the regex, without tapping them")
|
tapCmd.Flags().Bool(configStructs.DryRunTapName, defaultTapConfig.DryRun, "Preview of all pods matching the regex, without tapping them")
|
||||||
tapCmd.Flags().StringP(configStructs.WorkspaceTapName, "w", defaultTapConfig.Workspace, "Uploads traffic to your UP9 workspace for further analysis (requires auth)")
|
tapCmd.Flags().StringP(configStructs.WorkspaceTapName, "w", defaultTapConfig.Workspace, "Uploads traffic to your UP9 workspace for further analysis (requires auth)")
|
||||||
tapCmd.Flags().String(configStructs.EnforcePolicyFile, defaultTapConfig.EnforcePolicyFile, "Yaml file path with policy rules")
|
tapCmd.Flags().String(configStructs.EnforcePolicyFile, defaultTapConfig.EnforcePolicyFile, "Yaml file path with policy rules")
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ func finishTapExecution(kubernetesProvider *kubernetes.Provider) {
|
|||||||
func getTapMizuAgentConfig() *shared.MizuAgentConfig {
|
func getTapMizuAgentConfig() *shared.MizuAgentConfig {
|
||||||
mizuAgentConfig := shared.MizuAgentConfig{
|
mizuAgentConfig := shared.MizuAgentConfig{
|
||||||
MaxDBSizeBytes: config.Config.Tap.MaxEntriesDBSizeBytes(),
|
MaxDBSizeBytes: config.Config.Tap.MaxEntriesDBSizeBytes(),
|
||||||
|
InsertionFilter: config.Config.Tap.GetInsertionFilter(),
|
||||||
AgentImage: config.Config.AgentImage,
|
AgentImage: config.Config.AgentImage,
|
||||||
PullPolicy: config.Config.ImagePullPolicyStr,
|
PullPolicy: config.Config.ImagePullPolicyStr,
|
||||||
LogLevel: config.Config.LogLevel(),
|
LogLevel: config.Config.LogLevel(),
|
||||||
|
|||||||
@@ -3,10 +3,16 @@ package configStructs
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/up9inc/mizu/cli/uiUtils"
|
||||||
"github.com/up9inc/mizu/shared"
|
"github.com/up9inc/mizu/shared"
|
||||||
|
|
||||||
|
basenine "github.com/up9inc/basenine/server/lib"
|
||||||
|
"github.com/up9inc/mizu/shared/logger"
|
||||||
"github.com/up9inc/mizu/shared/units"
|
"github.com/up9inc/mizu/shared/units"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,6 +24,7 @@ const (
|
|||||||
PlainTextFilterRegexesTapName = "regex-masking"
|
PlainTextFilterRegexesTapName = "regex-masking"
|
||||||
DisableRedactionTapName = "no-redact"
|
DisableRedactionTapName = "no-redact"
|
||||||
HumanMaxEntriesDBSizeTapName = "max-entries-db-size"
|
HumanMaxEntriesDBSizeTapName = "max-entries-db-size"
|
||||||
|
InsertionFilterName = "insertion-filter"
|
||||||
DryRunTapName = "dry-run"
|
DryRunTapName = "dry-run"
|
||||||
WorkspaceTapName = "workspace"
|
WorkspaceTapName = "workspace"
|
||||||
EnforcePolicyFile = "traffic-validation-file"
|
EnforcePolicyFile = "traffic-validation-file"
|
||||||
@@ -27,26 +34,27 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type TapConfig struct {
|
type TapConfig struct {
|
||||||
UploadIntervalSec int `yaml:"upload-interval" default:"10"`
|
UploadIntervalSec int `yaml:"upload-interval" default:"10"`
|
||||||
PodRegexStr string `yaml:"regex" default:".*"`
|
PodRegexStr string `yaml:"regex" default:".*"`
|
||||||
GuiPort uint16 `yaml:"gui-port" default:"8899"`
|
GuiPort uint16 `yaml:"gui-port" default:"8899"`
|
||||||
ProxyHost string `yaml:"proxy-host" default:"127.0.0.1"`
|
ProxyHost string `yaml:"proxy-host" default:"127.0.0.1"`
|
||||||
Namespaces []string `yaml:"namespaces"`
|
Namespaces []string `yaml:"namespaces"`
|
||||||
Analysis bool `yaml:"analysis" default:"false"`
|
Analysis bool `yaml:"analysis" default:"false"`
|
||||||
AllNamespaces bool `yaml:"all-namespaces" default:"false"`
|
AllNamespaces bool `yaml:"all-namespaces" default:"false"`
|
||||||
PlainTextFilterRegexes []string `yaml:"regex-masking"`
|
PlainTextFilterRegexes []string `yaml:"regex-masking"`
|
||||||
IgnoredUserAgents []string `yaml:"ignored-user-agents"`
|
IgnoredUserAgents []string `yaml:"ignored-user-agents"`
|
||||||
DisableRedaction bool `yaml:"no-redact" default:"false"`
|
DisableRedaction bool `yaml:"no-redact" default:"false"`
|
||||||
HumanMaxEntriesDBSize string `yaml:"max-entries-db-size" default:"200MB"`
|
HumanMaxEntriesDBSize string `yaml:"max-entries-db-size" default:"200MB"`
|
||||||
DryRun bool `yaml:"dry-run" default:"false"`
|
InsertionFilter string `yaml:"insertion-filter" default:""`
|
||||||
Workspace string `yaml:"workspace"`
|
DryRun bool `yaml:"dry-run" default:"false"`
|
||||||
EnforcePolicyFile string `yaml:"traffic-validation-file"`
|
Workspace string `yaml:"workspace"`
|
||||||
ContractFile string `yaml:"contract"`
|
EnforcePolicyFile string `yaml:"traffic-validation-file"`
|
||||||
AskUploadConfirmation bool `yaml:"ask-upload-confirmation" default:"true"`
|
ContractFile string `yaml:"contract"`
|
||||||
ApiServerResources shared.Resources `yaml:"api-server-resources"`
|
AskUploadConfirmation bool `yaml:"ask-upload-confirmation" default:"true"`
|
||||||
TapperResources shared.Resources `yaml:"tapper-resources"`
|
ApiServerResources shared.Resources `yaml:"api-server-resources"`
|
||||||
ServiceMesh bool `yaml:"service-mesh" default:"false"`
|
TapperResources shared.Resources `yaml:"tapper-resources"`
|
||||||
Tls bool `yaml:"tls" default:"false"`
|
ServiceMesh bool `yaml:"service-mesh" default:"false"`
|
||||||
|
Tls bool `yaml:"tls" default:"false"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config *TapConfig) PodRegex() *regexp.Regexp {
|
func (config *TapConfig) PodRegex() *regexp.Regexp {
|
||||||
@@ -59,6 +67,25 @@ func (config *TapConfig) MaxEntriesDBSizeBytes() int64 {
|
|||||||
return maxEntriesDBSizeBytes
|
return maxEntriesDBSizeBytes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (config *TapConfig) GetInsertionFilter() string {
|
||||||
|
insertionFilter := config.InsertionFilter
|
||||||
|
if fs.ValidPath(insertionFilter) {
|
||||||
|
if _, err := os.Stat(insertionFilter); err == nil {
|
||||||
|
b, err := ioutil.ReadFile(insertionFilter)
|
||||||
|
if err != nil {
|
||||||
|
logger.Log.Warningf(uiUtils.Warning, fmt.Sprintf("Couldn't read the file on path: %s, err: %v", insertionFilter, err))
|
||||||
|
} else {
|
||||||
|
insertionFilter = string(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err := basenine.Parse(insertionFilter)
|
||||||
|
if err != nil {
|
||||||
|
logger.Log.Warningf(uiUtils.Warning, fmt.Sprintf("Insertion filter syntax error: %v", err))
|
||||||
|
}
|
||||||
|
return insertionFilter
|
||||||
|
}
|
||||||
|
|
||||||
func (config *TapConfig) Validate() error {
|
func (config *TapConfig) Validate() error {
|
||||||
_, compileErr := regexp.Compile(config.PodRegexStr)
|
_, compileErr := regexp.Compile(config.PodRegexStr)
|
||||||
if compileErr != nil {
|
if compileErr != nil {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ require (
|
|||||||
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
|
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
|
||||||
github.com/spf13/cobra v1.3.0
|
github.com/spf13/cobra v1.3.0
|
||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
|
github.com/up9inc/basenine/server/lib v0.0.0-20220302182733-74dc40dc2ef0
|
||||||
github.com/up9inc/mizu/shared v0.0.0
|
github.com/up9inc/mizu/shared v0.0.0
|
||||||
github.com/up9inc/mizu/tap/api v0.0.0
|
github.com/up9inc/mizu/tap/api v0.0.0
|
||||||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
|
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
|
||||||
@@ -32,8 +33,10 @@ require (
|
|||||||
github.com/MakeNowJust/heredoc v1.0.0 // indirect
|
github.com/MakeNowJust/heredoc v1.0.0 // indirect
|
||||||
github.com/PuerkitoBio/purell v1.1.1 // indirect
|
github.com/PuerkitoBio/purell v1.1.1 // indirect
|
||||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
||||||
|
github.com/alecthomas/participle/v2 v2.0.0-alpha7 // indirect
|
||||||
github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 // indirect
|
github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/dlclark/regexp2 v1.4.0 // indirect
|
||||||
github.com/docker/go-units v0.4.0 // indirect
|
github.com/docker/go-units v0.4.0 // indirect
|
||||||
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
|
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
|
||||||
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
|
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
|
||||||
@@ -68,6 +71,7 @@ require (
|
|||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
|
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
|
||||||
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
|
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
|
||||||
|
github.com/ohler55/ojg v1.12.13 // indirect
|
||||||
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
|
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
|||||||
10
cli/go.sum
10
cli/go.sum
@@ -83,6 +83,10 @@ github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tN
|
|||||||
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
||||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||||
|
github.com/alecthomas/participle/v2 v2.0.0-alpha7 h1:cK4vjj0VSgb3lN1nuKA5F7dw+1s1pWBe5bx7nNCnN+c=
|
||||||
|
github.com/alecthomas/participle/v2 v2.0.0-alpha7/go.mod h1:NumScqsC42o9x+dGj8/YqsIfhrIQjFEOFovxotbBirA=
|
||||||
|
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 h1:GDQdwm/gAcJcLAKQQZGOJ4knlw+7rfEQQcmwTbt4p5E=
|
||||||
|
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
@@ -149,6 +153,8 @@ github.com/denisbrodbeck/machineid v1.0.1 h1:geKr9qtkB876mXguW2X6TU4ZynleN6ezuMS
|
|||||||
github.com/denisbrodbeck/machineid v1.0.1/go.mod h1:dJUwb7PTidGDeYyUBmXZ2GphQBbjJCrnectwCyxcUSI=
|
github.com/denisbrodbeck/machineid v1.0.1/go.mod h1:dJUwb7PTidGDeYyUBmXZ2GphQBbjJCrnectwCyxcUSI=
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||||
|
github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E=
|
||||||
|
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||||
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||||
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
|
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
|
||||||
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||||
@@ -479,6 +485,8 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb
|
|||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||||
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
|
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
|
||||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||||
|
github.com/ohler55/ojg v1.12.13 h1:FvfVpYzLgMraLcg3rrXiRXaihOP6fnzQNEU9YyZ/AmM=
|
||||||
|
github.com/ohler55/ojg v1.12.13/go.mod h1:LBbIVRAgoFbYBXQhRhuEpaJIqq+goSO63/FQ+nyJU88=
|
||||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||||
github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
|
github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
|
||||||
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
@@ -590,6 +598,8 @@ github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69
|
|||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||||
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
|
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
|
||||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
||||||
|
github.com/up9inc/basenine/server/lib v0.0.0-20220302182733-74dc40dc2ef0 h1:9PQamOq285DyVsRlS4KB/x2+xkr5QlpiT9Y/BPutS4A=
|
||||||
|
github.com/up9inc/basenine/server/lib v0.0.0-20220302182733-74dc40dc2ef0/go.mod h1:R9bG4y/iq89jNC0xZ25uKDqenyKFTR3X9acGDOkKWSE=
|
||||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||||
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
|
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
|
||||||
github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk=
|
github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk=
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
# Patterns to ignore when building packages.
|
|
||||||
# This supports shell glob matching, relative path matching, and
|
|
||||||
# negation (prefixed with !). Only one pattern per line.
|
|
||||||
.DS_Store
|
|
||||||
# Common VCS dirs
|
|
||||||
.git/
|
|
||||||
.gitignore
|
|
||||||
.bzr/
|
|
||||||
.bzrignore
|
|
||||||
.hg/
|
|
||||||
.hgignore
|
|
||||||
.svn/
|
|
||||||
# Common backup files
|
|
||||||
*.swp
|
|
||||||
*.bak
|
|
||||||
*.tmp
|
|
||||||
*.orig
|
|
||||||
*~
|
|
||||||
# Various IDEs
|
|
||||||
.project
|
|
||||||
.idea/
|
|
||||||
*.tmproj
|
|
||||||
.vscode/
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
apiVersion: v2
|
|
||||||
name: mizuhelm
|
|
||||||
description: Mizu helm chart for Kubernetes
|
|
||||||
type: application
|
|
||||||
version: 0.1.1
|
|
||||||
kubeVersion: ">= 1.16.0-0"
|
|
||||||
appVersion: "0.21.29"
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
kind: PersistentVolumeClaim
|
|
||||||
apiVersion: v1
|
|
||||||
metadata:
|
|
||||||
name: {{ .Values.volumeClaim.name }}
|
|
||||||
namespace: {{ .Release.Namespace }}
|
|
||||||
spec:
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
storage: 700M
|
|
||||||
requests:
|
|
||||||
storage: 700M
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
{{- if .Values.rbac.create -}}
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: ClusterRole
|
|
||||||
metadata:
|
|
||||||
name: {{ .Values.rbac.name }}
|
|
||||||
namespace: {{ .Release.Namespace }}
|
|
||||||
labels:
|
|
||||||
mizu-cli-version: {{ .Chart.AppVersion }}
|
|
||||||
heritage: {{ .Release.Service }}
|
|
||||||
release: {{ .Release.Name }}
|
|
||||||
rules:
|
|
||||||
- apiGroups: [ "", "extensions", "apps" ]
|
|
||||||
resources: [ "endpoints", "pods", "services", "namespaces" ]
|
|
||||||
verbs: [ "get", "list", "watch" ]
|
|
||||||
---
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: ClusterRoleBinding
|
|
||||||
metadata:
|
|
||||||
name: {{ .Values.rbac.roleBindingName }}
|
|
||||||
labels:
|
|
||||||
mizu-cli-version: {{ .Chart.AppVersion }}
|
|
||||||
roleRef:
|
|
||||||
apiGroup: rbac.authorization.k8s.io
|
|
||||||
kind: ClusterRole
|
|
||||||
name: {{ .Values.rbac.name }}
|
|
||||||
subjects:
|
|
||||||
- kind: ServiceAccount
|
|
||||||
name: {{ .Values.serviceAccountName }}
|
|
||||||
namespace: {{ .Release.Namespace }}
|
|
||||||
{{- end -}}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: {{ .Values.configMap.name }}
|
|
||||||
namespace: {{ .Release.Namespace }}
|
|
||||||
data:
|
|
||||||
mizu-config.json: >-
|
|
||||||
{"maxDBSizeBytes":200000000,"agentImage":"{{ .Values.container.tapper.image.repository }}:{{ .Values.container.tapper.image.tag }}","pullPolicy":"Always","logLevel":4,"tapperResources":{"CpuLimit":"750m","MemoryLimit":"1Gi","CpuRequests":"50m","MemoryRequests":"50Mi"},"mizuResourceNamespace":"{{ .Release.Namespace }}","agentDatabasePath":"/app/data/","standaloneMode":true}
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: {{ .Values.pod.name }}
|
|
||||||
namespace: {{ .Release.Namespace }}
|
|
||||||
labels:
|
|
||||||
app: {{ .Values.pod.name }}
|
|
||||||
spec:
|
|
||||||
replicas: {{ .Values.deployment.replicaCount }}
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: {{ .Values.pod.name }}
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
name: {{ .Values.pod.name }}
|
|
||||||
creationTimestamp: null
|
|
||||||
labels:
|
|
||||||
app: {{ .Values.pod.name }}
|
|
||||||
spec:
|
|
||||||
volumes:
|
|
||||||
- name: {{ .Values.configMap.name }}
|
|
||||||
configMap:
|
|
||||||
name: {{ .Values.configMap.name }}
|
|
||||||
defaultMode: 420
|
|
||||||
- name: {{ .Values.volumeClaim.name }}
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: {{ .Values.volumeClaim.name }}
|
|
||||||
containers:
|
|
||||||
- name: {{ .Values.pod.name }}
|
|
||||||
image: "{{ .Values.container.mizuAgent.image.repository }}:{{ .Values.container.mizuAgent.image.tag | default .Chart.AppVersion }}"
|
|
||||||
command:
|
|
||||||
- ./mizuagent
|
|
||||||
- '--api-server'
|
|
||||||
env:
|
|
||||||
- name: SYNC_ENTRIES_CONFIG
|
|
||||||
- name: LOG_LEVEL
|
|
||||||
value: INFO
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
cpu: 750m
|
|
||||||
memory: 1Gi
|
|
||||||
requests:
|
|
||||||
cpu: 50m
|
|
||||||
memory: 50Mi
|
|
||||||
volumeMounts:
|
|
||||||
- name: {{ .Values.configMap.name }}
|
|
||||||
mountPath: /app/config/
|
|
||||||
- name: {{ .Values.volumeClaim.name }}
|
|
||||||
mountPath: /app/data/
|
|
||||||
livenessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /echo
|
|
||||||
port: {{ .Values.pod.port }}
|
|
||||||
scheme: HTTP
|
|
||||||
initialDelaySeconds: 1
|
|
||||||
timeoutSeconds: 1
|
|
||||||
periodSeconds: 10
|
|
||||||
successThreshold: 1
|
|
||||||
failureThreshold: 3
|
|
||||||
terminationMessagePath: /dev/termination-log
|
|
||||||
terminationMessagePolicy: File
|
|
||||||
imagePullPolicy: Always
|
|
||||||
- name: {{ .Values.container.basenine.name }}
|
|
||||||
image: "{{ .Values.container.basenine.image.repository }}:{{ .Values.container.basenine.image.tag | default .Chart.AppVersion }}"
|
|
||||||
command:
|
|
||||||
- /basenine
|
|
||||||
args:
|
|
||||||
- '-addr'
|
|
||||||
- 0.0.0.0
|
|
||||||
- '-port'
|
|
||||||
- '9099'
|
|
||||||
- '-persistent'
|
|
||||||
workingDir: /app/data/
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
cpu: 750m
|
|
||||||
memory: 1Gi
|
|
||||||
requests:
|
|
||||||
cpu: 50m
|
|
||||||
memory: 50Mi
|
|
||||||
volumeMounts:
|
|
||||||
- name: {{ .Values.configMap.name }}
|
|
||||||
mountPath: /app/config/
|
|
||||||
- name: {{ .Values.volumeClaim.name }}
|
|
||||||
mountPath: /app/data/
|
|
||||||
readinessProbe:
|
|
||||||
tcpSocket:
|
|
||||||
port: 9099
|
|
||||||
timeoutSeconds: 1
|
|
||||||
periodSeconds: 1
|
|
||||||
successThreshold: 1
|
|
||||||
failureThreshold: 3
|
|
||||||
terminationMessagePath: /dev/termination-log
|
|
||||||
terminationMessagePolicy: File
|
|
||||||
imagePullPolicy: Always
|
|
||||||
- name: kratos
|
|
||||||
image: "{{ .Values.container.kratos.image.repository }}:{{ .Values.container.kratos.image.tag | default .Chart.AppVersion }}"
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
cpu: 750m
|
|
||||||
memory: 1Gi
|
|
||||||
requests:
|
|
||||||
cpu: 50m
|
|
||||||
memory: 50Mi
|
|
||||||
volumeMounts:
|
|
||||||
- name: {{ .Values.configMap.name }}
|
|
||||||
mountPath: /app/config/
|
|
||||||
- name: {{ .Values.volumeClaim.name }}
|
|
||||||
mountPath: /app/data/
|
|
||||||
readinessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /health/ready
|
|
||||||
port: 4433
|
|
||||||
scheme: HTTP
|
|
||||||
timeoutSeconds: 1
|
|
||||||
periodSeconds: 1
|
|
||||||
successThreshold: 1
|
|
||||||
failureThreshold: 3
|
|
||||||
terminationMessagePath: /dev/termination-log
|
|
||||||
terminationMessagePolicy: File
|
|
||||||
imagePullPolicy: Always
|
|
||||||
restartPolicy: Always
|
|
||||||
terminationGracePeriodSeconds: 0
|
|
||||||
dnsPolicy: ClusterFirstWithHostNet
|
|
||||||
serviceAccountName: {{ .Values.serviceAccountName }}
|
|
||||||
serviceAccount: {{ .Values.serviceAccountName }}
|
|
||||||
securityContext: { }
|
|
||||||
schedulerName: default-scheduler
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: Role
|
|
||||||
metadata:
|
|
||||||
name: {{ .Values.roleName }}
|
|
||||||
namespace: {{ .Release.Namespace }}
|
|
||||||
labels:
|
|
||||||
mizu-cli-version: {{ .Chart.AppVersion }}
|
|
||||||
rules:
|
|
||||||
- apiGroups: [ "apps" ]
|
|
||||||
resources: [ "daemonsets" ]
|
|
||||||
verbs: [ "patch", "get", "list", "create", "delete" ]
|
|
||||||
- apiGroups: [ "events.k8s.i" ]
|
|
||||||
resources: [ "events" ]
|
|
||||||
verbs: [ "list", "watch" ]
|
|
||||||
---
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: RoleBinding
|
|
||||||
metadata:
|
|
||||||
name: {{ .Values.roleBindingName }}
|
|
||||||
namespace: {{ .Release.Namespace }}
|
|
||||||
roleRef:
|
|
||||||
apiGroup: rbac.authorization.k8s.io
|
|
||||||
kind: Role
|
|
||||||
name: {{ .Values.roleName }}
|
|
||||||
subjects:
|
|
||||||
- kind: ServiceAccount
|
|
||||||
name: {{ .Values.serviceAccountName }}
|
|
||||||
namespace: {{ .Release.Namespace }}
|
|
||||||
---
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: {{ .Values.service.name }}
|
|
||||||
namespace: {{ .Release.Namespace }}
|
|
||||||
spec:
|
|
||||||
type: {{ .Values.service.type }}
|
|
||||||
ports:
|
|
||||||
- name: api
|
|
||||||
port: {{ .Values.service.port }}
|
|
||||||
targetPort: {{ .Values.pod.port }}
|
|
||||||
protocol: TCP
|
|
||||||
selector:
|
|
||||||
app: {{ .Values.pod.name }}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: ServiceAccount
|
|
||||||
metadata:
|
|
||||||
name: {{ .Values.serviceAccountName }}
|
|
||||||
namespace: {{ .Release.Namespace }}
|
|
||||||
labels:
|
|
||||||
mizu-cli-version: {{ .Chart.AppVersion }}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
# Default values for mizu.
|
|
||||||
rbac:
|
|
||||||
create: true
|
|
||||||
name: "mizu-cluster-role"
|
|
||||||
roleBindingName: "mizu-role-binding"
|
|
||||||
|
|
||||||
serviceAccountName: "mizu-service-account"
|
|
||||||
|
|
||||||
roleName: "mizu-role-daemon"
|
|
||||||
roleBindingName: "mizu-role-binding-daemon"
|
|
||||||
|
|
||||||
service:
|
|
||||||
name: "mizu-api-server"
|
|
||||||
type: ClusterIP
|
|
||||||
port: 80
|
|
||||||
|
|
||||||
pod:
|
|
||||||
name: "mizu-api-server"
|
|
||||||
port: 8899
|
|
||||||
|
|
||||||
container:
|
|
||||||
mizuAgent:
|
|
||||||
image:
|
|
||||||
repository: "gcr.io/up9-docker-hub/mizu/main"
|
|
||||||
tag: "0.22.0"
|
|
||||||
tapper:
|
|
||||||
image:
|
|
||||||
repository: "gcr.io/up9-docker-hub/mizu/main"
|
|
||||||
tag: "0.22.0"
|
|
||||||
basenine:
|
|
||||||
name: "basenine"
|
|
||||||
port: 9099
|
|
||||||
image:
|
|
||||||
repository: "ghcr.io/up9inc/basenine"
|
|
||||||
tag: "v0.3.0"
|
|
||||||
kratos:
|
|
||||||
name: "kratos"
|
|
||||||
port: 4433
|
|
||||||
image:
|
|
||||||
repository: "gcr.io/up9-docker-hub/mizu-kratos/stable"
|
|
||||||
tag: "0.0.0"
|
|
||||||
|
|
||||||
deployment:
|
|
||||||
replicaCount: 1
|
|
||||||
|
|
||||||
configMap:
|
|
||||||
name: "mizu-config"
|
|
||||||
|
|
||||||
volumeClaim:
|
|
||||||
create: true
|
|
||||||
name: "mizu-volume-claim"
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
GCP_PROJECT=up9-docker-hub
|
|
||||||
REPOSITORY=gcr.io/$GCP_PROJECT
|
|
||||||
SERVER_NAME=mizu
|
|
||||||
GIT_BRANCH=ci
|
|
||||||
|
|
||||||
DOCKER_REPO=$REPOSITORY/$SERVER_NAME/$GIT_BRANCH
|
|
||||||
VER=${VER=0.0}
|
|
||||||
|
|
||||||
DOCKER_TAGGED_BUILD="$DOCKER_REPO:$VER"
|
|
||||||
|
|
||||||
echo "building $DOCKER_TAGGED_BUILD"
|
|
||||||
docker build -t ${DOCKER_TAGGED_BUILD} --build-arg VER=${VER} --build-arg BUILD_TIMESTAMP=${BUILD_TIMESTAMP} --build-arg GIT_BRANCH=${GIT_BRANCH} --build-arg COMMIT_HASH=${COMMIT_HASH} .
|
|
||||||
@@ -35,6 +35,7 @@ type Resources struct {
|
|||||||
|
|
||||||
type MizuAgentConfig struct {
|
type MizuAgentConfig struct {
|
||||||
MaxDBSizeBytes int64 `json:"maxDBSizeBytes"`
|
MaxDBSizeBytes int64 `json:"maxDBSizeBytes"`
|
||||||
|
InsertionFilter string `json:"insertionFilter"`
|
||||||
AgentImage string `json:"agentImage"`
|
AgentImage string `json:"agentImage"`
|
||||||
PullPolicy string `json:"pullPolicy"`
|
PullPolicy string `json:"pullPolicy"`
|
||||||
LogLevel logging.Level `json:"logLevel"`
|
LogLevel logging.Level `json:"logLevel"`
|
||||||
|
|||||||
Reference in New Issue
Block a user