Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc4b26f3

Browse files
authored
test: verify that enterprise tests are being run (#12871)
1 parenta2b28f8 commitc4b26f3

File tree

6 files changed

+72
-32
lines changed

6 files changed

+72
-32
lines changed

‎Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,9 @@ install: build/coder_$(VERSION)_$(GOOS)_$(GOARCH)$(GOOS_BIN_EXT)
382382
cp "$<" "$$output_file"
383383
.PHONY: install
384384

385-
BOLD :=$(shell tput bold)
386-
GREEN :=$(shell tput setaf 2)
387-
RESET :=$(shell tput sgr0)
385+
BOLD :=$(shell tput bold 2>/dev/null)
386+
GREEN :=$(shell tput setaf 2 2>/dev/null)
387+
RESET :=$(shell tput sgr0 2>/dev/null)
388388

389389
fmt: fmt/eslint fmt/prettier fmt/terraform fmt/shfmt fmt/go
390390
.PHONY: fmt

‎site/e2e/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,7 @@ export const gitAuth = {
3333
installationsPath:"/installations",
3434
};
3535

36+
exportconstrequireEnterpriseTests=Boolean(
37+
process.env.CODER_E2E_REQUIRE_ENTERPRISE_TESTS,
38+
);
3639
exportconstenterpriseLicense=process.env.CODER_E2E_ENTERPRISE_LICENSE??"";

‎site/e2e/global.setup.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{test,expect}from"@playwright/test";
1+
import{expect,test}from"@playwright/test";
22
import{Language}from"pages/CreateUserPage/CreateUserForm";
33
import*asconstantsfrom"./constants";
44
import{storageState}from"./playwright.config";
@@ -18,7 +18,12 @@ test("setup deployment", async ({ page }) => {
1818
awaitpage.getByTestId("button-select-template").isVisible();
1919

2020
// Setup license
21-
if(constants.enterpriseLicense){
21+
if(constants.requireEnterpriseTests||constants.enterpriseLicense){
22+
// Make sure that we have something that looks like a real license
23+
expect(constants.enterpriseLicense).toBeTruthy();
24+
expect(constants.enterpriseLicense.length).toBeGreaterThan(92);// the signature alone should be this long
25+
expect(constants.enterpriseLicense.split(".").length).toBe(3);// otherwise it's invalid
26+
2227
awaitpage.goto("/deployment/licenses",{waitUntil:"domcontentloaded"});
2328

2429
awaitpage.getByText("Add a license").click();

‎site/e2e/helpers.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
coderPort,
1919
enterpriseLicense,
2020
prometheusPort,
21+
requireEnterpriseTests,
2122
}from"./constants";
2223
import{
2324
Agent,
@@ -33,6 +34,10 @@ import {
3334

3435
// requiresEnterpriseLicense will skip the test if we're not running with an enterprise license
3536
exportfunctionrequiresEnterpriseLicense(){
37+
if(requireEnterpriseTests){
38+
return;
39+
}
40+
3641
test.skip(!enterpriseLicense);
3742
}
3843

‎site/e2e/reporter.ts

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import type {
1111
importaxiosfrom"axios";
1212
import*asfsfrom"fs/promises";
1313
importtype{Writable}from"stream";
14-
import{coderdPProfPort}from"./constants";
14+
import{coderdPProfPort,enterpriseLicense}from"./constants";
1515

1616
classCoderReporterimplementsReporter{
1717
config:FullConfig|null=null;
1818
testOutput=newMap<string,Array<[Writable,string]>>();
1919
passedCount=0;
20+
skippedCount=0;
2021
failedTests:TestCase[]=[];
2122
timedOutTests:TestCase[]=[];
2223

@@ -31,45 +32,56 @@ class CoderReporter implements Reporter {
3132
}
3233

3334
onStdOut(chunk:string,test?:TestCase,_?:TestResult):void{
34-
for(constlineoffilteredServerLogLines(chunk)){
35-
console.log(`[stdout]${line}`);
36-
}
35+
// If there's no associated test, just print it now
3736
if(!test){
37+
for(constlineoflogLines(chunk)){
38+
console.log(`[stdout]${line}`);
39+
}
3840
return;
3941
}
42+
// Will be printed if the test fails
4043
this.testOutput.get(test.id)!.push([process.stdout,chunk]);
4144
}
4245

4346
onStdErr(chunk:string,test?:TestCase,_?:TestResult):void{
44-
for(constlineoffilteredServerLogLines(chunk)){
45-
console.error(`[stderr]${line}`);
46-
}
47+
// If there's no associated test, just print it now
4748
if(!test){
49+
for(constlineoflogLines(chunk)){
50+
console.error(`[stderr]${line}`);
51+
}
4852
return;
4953
}
54+
// Will be printed if the test fails
5055
this.testOutput.get(test.id)!.push([process.stderr,chunk]);
5156
}
5257

5358
asynconTestEnd(test:TestCase,result:TestResult){
54-
console.log(`==> Finished test${test.title}:${result.status}`);
59+
try{
60+
if(test.expectedStatus==="skipped"){
61+
console.log(`==> Skipping test${test.title}`);
62+
this.skippedCount++;
63+
return;
64+
}
5565

56-
if(result.status==="passed"){
57-
this.passedCount++;
58-
}
66+
console.log(`==> Finished test${test.title}:${result.status}`);
5967

60-
if(result.status==="failed"){
61-
this.failedTests.push(test);
62-
}
68+
if(result.status==="passed"){
69+
this.passedCount++;
70+
return;
71+
}
6372

64-
if(result.status==="timedOut"){
65-
this.timedOutTests.push(test);
66-
}
73+
if(result.status==="failed"){
74+
this.failedTests.push(test);
75+
}
76+
77+
if(result.status==="timedOut"){
78+
this.timedOutTests.push(test);
79+
}
6780

68-
constfsTestTitle=test.title.replaceAll(" ","-");
69-
constoutputFile=`test-results/debug-pprof-goroutine-${fsTestTitle}.txt`;
70-
awaitexportDebugPprof(outputFile);
81+
constfsTestTitle=test.title.replaceAll(" ","-");
82+
constoutputFile=`test-results/debug-pprof-goroutine-${fsTestTitle}.txt`;
83+
awaitexportDebugPprof(outputFile);
7184

72-
if(result.status!=="passed"){
7385
console.log(`Data from pprof has been saved to${outputFile}`);
7486
console.log("==> Output");
7587
constoutput=this.testOutput.get(test.id)!;
@@ -90,13 +102,22 @@ class CoderReporter implements Reporter {
90102
console.log(attachment);
91103
}
92104
}
105+
}finally{
106+
this.testOutput.delete(test.id);
93107
}
94-
this.testOutput.delete(test.id);
95108
}
96109

97110
onEnd(result:FullResult){
98111
console.log(`==> Tests${result.status}`);
112+
if(!enterpriseLicense){
113+
console.log(
114+
"==> Enterprise tests were skipped, because no license was provided",
115+
);
116+
}
99117
console.log(`${this.passedCount} passed`);
118+
if(this.skippedCount>0){
119+
console.log(`${this.skippedCount} skipped`);
120+
}
100121
if(this.failedTests.length>0){
101122
console.log(`${this.failedTests.length} failed`);
102123
for(consttestofthis.failedTests){
@@ -112,11 +133,7 @@ class CoderReporter implements Reporter {
112133
}
113134
}
114135

115-
constshouldPrintLine=(line:string)=>
116-
[" error=EOF","coderd: audit_log"].every((noise)=>!line.includes(noise));
117-
118-
constfilteredServerLogLines=(chunk:string):string[]=>
119-
chunk.trimEnd().split("\n").filter(shouldPrintLine);
136+
constlogLines=(chunk:string):string[]=>chunk.trimEnd().split("\n");
120137

121138
constexportDebugPprof=async(outputFile:string)=>{
122139
constresponse=awaitaxios.get(

‎site/e2e/tests/enterprise.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import{expect,test}from"@playwright/test";
2+
import{requiresEnterpriseLicense}from"../helpers";
3+
4+
test("license was added successfully",async({ page})=>{
5+
requiresEnterpriseLicense();
6+
7+
awaitpage.goto("/deployment/licenses",{waitUntil:"domcontentloaded"});
8+
constlicense=page.locator(".MuiPaper-root",{hasText:"#1"});
9+
awaitexpect(license).toBeVisible();
10+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp