Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,17 @@
/plugin-backend
/cover.out
tmp.Dockerfile
tmp/
tmp/

# Benchmark results (generated files, but keep baseline)
benchmark-*.txt
/pkg/server/benchmark-current.txt
/pkg/server/benchmark-results.txt
!/pkg/server/benchmark-baseline.txt
**/gui_test_screenshots/
/web/cypress/results/

# htpasswd test user files
htpasswd-test-users
test-users-credentials.txt
cypress.env.json
131 changes: 120 additions & 11 deletions web/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,133 @@
import { defineConfig } from "cypress";
// eslint-disable-next-line @typescript-eslint/no-var-requires
const cypressGrepPlugin = require('@cypress/grep/src/plugin');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require('fs');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');

export default defineConfig({
viewportWidth: 1600,
viewportHeight: 800,
defaultCommandTimeout: 10000,
viewportWidth: 1920,
viewportHeight: 1080,
defaultCommandTimeout: 30000,
projectId: "tjknpb",
screenshotsFolder: './gui_test_screenshots/cypress/screenshots',
screenshotOnRunFailure: true,
trashAssetsBeforeRuns: true,
videosFolder: './gui_test_screenshots/cypress/videos',
video: true,
videoCompression: false,
reporter: './node_modules/cypress-multi-reporters',
reporterOptions: {
configFile: 'reporter-config.json',
},
fixturesFolder: 'cypress/fixtures',
env: {
grepFilterSpecs: true,
...(process.env.IS_OPENSHIFT === 'true' && {
'LOGIN_USERNAME': process.env.CYPRESS_LOGIN_USERS?.split(',')[0].split(':')[0],
'LOGIN_PASSWORD': process.env.CYPRESS_LOGIN_USERS?.split(',')[0].split(':')[1],
'LOGIN_IDP': process.env.CYPRESS_LOGIN_IDP,
'KUBECONFIG_PATH': process.env.CYPRESS_KUBECONFIG_PATH,
'NOO_CATALOG_SOURCE': process.env.NOO_CATALOG_SOURCE,
'NOO_CS_IMAGE': process.env.MULTISTAGE_PARAM_OVERRIDE_CYPRESS_NOO_CS_IMAGE || process.env.NOO_CS_IMAGE,
'SKIP_NOO_INSTALL': process.env.SKIP_NOO_INSTALL,
'LOGIN_USERS': process.env.LOGIN_USERS || process.env.CYPRESS_LOGIN_USERS,
}),
},

e2e: {
baseUrl: process.env.CYPRESS_BASE_URL || 'http://localhost:9001',
testIsolation: false,
experimentalMemoryManagement: true,
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require("./cypress/plugins/index.js")(on, config);
},
specPattern: "cypress/e2e/**/*.{js,jsx,ts,tsx}",
},
require("./cypress/plugins/index.js")(on, config);
config = cypressGrepPlugin(config);
on('before:browser:launch', (browser = {
name: "",
family: "chromium",
channel: "",
displayName: "",
version: "",
majorVersion: "",
path: "",
isHeaded: false,
isHeadless: false
}, launchOptions) => {
if (browser.name === 'electron') {
// Fix for Electron rendering issues on macOS
launchOptions.args.push('--disable-gpu')
launchOptions.args.push('--no-sandbox')
launchOptions.args.push('--disable-dev-shm-usage')
}

if (browser.family === 'chromium' && browser.name !== 'electron') {
// auto open devtools
launchOptions.args.push('--enable-precise-memory-info')
}

return launchOptions

component: {
devServer: {
framework: "react",
bundler: "webpack",
});
// `on` is used to hook into various events Cypress emits
on('task', {
log(message) {
console.log(message);
return null;
},
logError(message) {
console.error(message);
return null;
},
logTable(data) {
console.table(data);
return null;
},
readFileIfExists(filename) {
if (fs.existsSync(filename)) {
return fs.readFileSync(filename, 'utf8');
}
return null;
},
});
on('after:screenshot', (details) => {
// Prepend "1_", "2_", etc. to screenshot filenames because they are sorted alphanumerically in CI's artifacts dir
const pathObj = path.parse(details.path);
fs.readdir(pathObj.dir, (error, files) => {
const newPath = `${pathObj.dir}${path.sep}${files.length}_${pathObj.base}`;
return new Promise((resolve, reject) => {
// eslint-disable-next-line consistent-return
fs.rename(details.path, newPath, (err) => {
if (err) return reject(err);
// because we renamed and moved the image, resolve with the new path
// so it is accurate in the test results
resolve({ path: newPath });
});
});
});
});
on(
'after:spec',
(spec: Cypress.Spec, results: CypressCommandLine.RunResult) => {
if (results && results.video) {
// Do we have failures for any retry attempts?
const failures = results.tests.some((test) =>
test.attempts.some((attempt) => attempt.state === 'failed')
)
if (!failures && fs.existsSync(results.video)) {
// delete the video if the spec passed and no tests retried
fs.unlinkSync(results.video)
}
}
}
);
return config;
},
specPattern: "cypress/{e2e,integration-tests}/**/*{.cy,.spec}.{js,jsx,ts,tsx}",
},
numTestsKeptInMemory: 5,
// required for guidedTour to not pop when running with cypress.
userAgent: 'ConsoleIntegrationTestEnvironment'
});
28 changes: 28 additions & 0 deletions web/cypress/fixtures/dns_errors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
kind: Namespace
metadata:
name: dns-traffic

---
apiVersion: v1
kind: Pod
metadata:
name: dnsutils
namespace: dns-traffic
spec:
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
dnsConfig:
options:
- name: "use-vc"
containers:
- name: utils
image: docker.io/massenz/dnsutils:2.4.0
# do dns requests to non-existent service to induce dns errors
command: ["/bin/sh", "-ec", "while :; do dig nginx-service.test.svc.cluster.local; sleep 1 ; done"]
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
20 changes: 20 additions & 0 deletions web/cypress/fixtures/flowcollector/fc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
kind: FlowCollector
apiVersion: flows.netobserv.io/v1beta2
metadata:
name: cluster
spec:
agent:
ebpf:
sampling: 1
type: eBPF
loki:
enable: true
mode: Monolithic
monolithic:
installDemoLoki: true
namespace: netobserv
consolePlugin:
portNaming:
enable: true
portNames:
'3100': loki
23 changes: 23 additions & 0 deletions web/cypress/fixtures/flowcollector/fc_DNSTracking.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
kind: FlowCollector
apiVersion: flows.netobserv.io/v1beta2
metadata:
name: cluster
spec:
agent:
ebpf:
sampling: 1
features:
- DNSTracking
type: eBPF
loki:
enable: true
mode: Monolithic
monolithic:
installDemoLoki: true
namespace: netobserv
processor:
metrics:
includeList:
- namespace_dns_latency_seconds
- node_dns_latency_seconds
- workload_dns_latency_seconds
27 changes: 27 additions & 0 deletions web/cypress/fixtures/flowcollector/fc_bytesMetrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
kind: FlowCollector
apiVersion: flows.netobserv.io/v1beta2
metadata:
name: cluster
spec:
agent:
ebpf:
sampling: 1
type: eBPF
loki:
enable: true
mode: Monolithic
monolithic:
installDemoLoki: true
namespace: netobserv
processor:
metrics:
includeList:
- node_flows_total
- node_ingress_bytes_total
- node_egress_bytes_total
- namespace_flows_total
- namespace_ingress_bytes_total
- namespace_egress_bytes_total
- workload_flows_total
- workload_ingress_bytes_total
- workload_egress_bytes_total
18 changes: 18 additions & 0 deletions web/cypress/fixtures/flowcollector/fc_conversations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
kind: FlowCollector
apiVersion: flows.netobserv.io/v1beta2
metadata:
name: cluster
spec:
agent:
ebpf:
sampling: 1
type: eBPF
deploymentModel: Direct
loki:
enable: true
mode: Monolithic
monolithic:
installDemoLoki: true
namespace: netobserv
processor:
logTypes: All
23 changes: 23 additions & 0 deletions web/cypress/fixtures/flowcollector/fc_flowRTT.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
kind: FlowCollector
apiVersion: flows.netobserv.io/v1beta2
metadata:
name: cluster
spec:
agent:
ebpf:
sampling: 1
features:
- FlowRTT
type: eBPF
loki:
enable: true
mode: Monolithic
monolithic:
installDemoLoki: true
namespace: netobserv
processor:
metrics:
includeList:
- namespace_rtt_seconds
- node_rtt_seconds
- workload_rtt_seconds
11 changes: 11 additions & 0 deletions web/cypress/fixtures/flowcollector/fc_lokiDisabled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
kind: FlowCollector
apiVersion: flows.netobserv.io/v1beta2
metadata:
name: cluster
spec:
agent:
ebpf:
sampling: 1
type: eBPF
loki:
enable: false
62 changes: 62 additions & 0 deletions web/cypress/fixtures/flowcollector/fc_networkalert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
kind: FlowCollector
apiVersion: flows.netobserv.io/v1beta2
metadata:
name: cluster
spec:
agent:
ebpf:
sampling: 1
features:
- DNSTracking
type: eBPF
loki:
enable: true
mode: Monolithic
monolithic:
installDemoLoki: true
namespace: netobserv
consolePlugin:
portNaming:
enable: true
portNames:
'3100': loki
processor:
advanced:
env:
EXPERIMENTAL_ALERTS_HEALTH: "true"
metrics:
includeList:
- workload_dns_latency_seconds
- node_dns_latency_seconds
- node_egress_bytes_total
- namespace_egress_bytes_total
- workload_egress_bytes_total
- node_ingress_bytes_total
- namespace_ingress_bytes_total
- workload_ingress_bytes_total
healthRules:
- mode: Alert
template: DNSNxDomain
variants:
- groupBy: "" # global
mode: Recording
thresholds:
critical: "15"
info: "2"
warning: "5"
- groupBy: Namespace
thresholds:
critical: "15"
info: "2"
warning: "5"
- groupBy: Node
mode: Recording
thresholds:
critical: "15"
info: "2"
warning: "5"
- groupBy: Workload
thresholds:
critical: "15"
info: "2"
warning: "5"
Loading
Loading