Skip to content

Commit

Permalink
Fix Swagger and Gatling
Browse files Browse the repository at this point in the history
  • Loading branch information
blootsvoets committed Oct 28, 2021
1 parent 9ccd509 commit bc0eec6
Show file tree
Hide file tree
Showing 27 changed files with 54 additions and 44 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ prometheus_simpleclient_version=0.0.20
postgresql_version=42.2.14
springdoc_version=1.5.2
spring_boot_version=2.5.5
gatling_version=3.3.1
gatling_version=3.6.1
mapstruct_version=1.4.2.Final
undertow_version=1.4.10.Final
yarn_version=1.22.15
Expand Down
5 changes: 1 addition & 4 deletions gradle/gatling.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,14 @@ tasks.addRule("Pattern: gatlingRun<ID>") { String taskName ->
final def sourceSet = sourceSets.gatling

classpath sourceSet.output + files(manifestJar.archiveFile) + files("${gatlingSrc}/resources")
main = "io.gatling.app.Gatling"
mainClass.set("io.gatling.app.Gatling")

environment GATLING_HOME:''

def className = taskName - 'gatlingRun'

args '-df', "${gatlingSrc}/data"
args '-rf', "${project.buildDir.absolutePath}/reports/gatling"
args '-bdf', "${gatlingSrc}/bodies"
args '-sf', gatlingSimulations
args '-m'
args '-s', className
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/liquibase.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {
if (OperatingSystem.current().isWindows()) {
task pathingLiquibaseJar(type: Jar) {
dependsOn configurations.liquibase
appendix = 'pathingLiquibase'
archiveAppendix.set('pathingLiquibase')

doFirst {
manifest {
Expand Down
4 changes: 2 additions & 2 deletions gradle/openapi.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ apply plugin: 'de.undercouch.download'

task generateOpenApiSpec(type: Download) {
description = "Fetch the OpenAPI spec from the Swagger endpoint. The application needs to be running at http://localhost:8080/."
src 'http://localhost:8080/v2/api-docs'
src 'http://localhost:8080/api-docs'
dest file('build/swagger-spec/swagger.json')
}

task generateOpenApiSpecProd(type: Download) {
description = "Fetch the OpenAPI spec from the Swagger endpoint. The application needs to be running at http://localhost:8080/."
src 'http://localhost:8080/managementportal/v2/api-docs'
src 'http://localhost:8080/managementportal/api-docs'
dest file('build/swagger-spec/swagger.json')
}
5 changes: 3 additions & 2 deletions gradle/profile_dev.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ dependencies {
implementation "org.springframework.boot:spring-boot-devtools"
}

def profiles = 'dev'
def profiles = 'dev,api-docs'
if (project.hasProperty('no-liquibase')) {
profiles += ',no-liquibase'
}

bootRun {
args = []
systemProperty "spring.profiles.active", profiles
}

task webpackBuildDev(type: YarnTask) {
Expand All @@ -35,7 +36,7 @@ processResources {
it.replace('#spring.profiles.active#', profiles)
}
filter {
it.replace('#project.version#', version)
it.replace('#project.version#', project.version)
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions gradle/profile_prod.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ if (project.hasProperty('no-liquibase')) {
profiles += ',no-liquibase'
}

if (project.hasProperty('swagger')) {
profiles += ',swagger'
if (project.hasProperty('api-docs')) {
profiles += ',api-docs'
}

bootRun {
args = []
systemProperty "spring.profiles.active", profiles
}

task webpack(type: YarnTask, dependsOn: 'yarn_install') {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"ngx-webstorage": "^8.0.0",
"popper.js": "^1.16.1",
"rxjs": "~6.6.0",
"swagger-ui": "2.2.10",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
Expand Down
5 changes: 3 additions & 2 deletions proxy.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"/oauth",
"/api",
"/management",
"/swagger-resources",
"/v2/api-docs",
"/api-docs",
"/swagger-ui.html",
"/swagger-ui",
"/h2-console"
],
"target": "http://127.0.0.1:8080",
Expand Down
2 changes: 1 addition & 1 deletion src/gatling/scala/ManagementPortalSimulation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ abstract class ManagementPortalSimulation extends Simulation {
def run(): Unit = {
val users = scenario("Users").exec(scn)
setUp(
users.inject(rampUsers(100) during (1 minutes))
users.inject(rampUsers(100) during (1.minutes))
).protocols(httpConf)
}
}
2 changes: 1 addition & 1 deletion src/gatling/scala/ProjectGatlingTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ProjectGatlingTest extends ManagementPortalSimulation {
.get("/api/projects")
.headers(headers_http_authenticated)
.check(status.is(200)))
.pause(5 seconds, 10 seconds)
.pause(5.seconds, 10.seconds)
.feed(randomString)
.exec(http("Create new project")
.post("/api/projects")
Expand Down
2 changes: 1 addition & 1 deletion src/gatling/scala/SensorDataGatlingTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SensorDataGatlingTest extends ManagementPortalSimulation {
.get("/api/source-data")
.headers(headers_http_authenticated)
.check(status.is(200)))
.pause(5 seconds, 10 seconds)
.pause(5.seconds, 10.seconds)
.feed(randomString)
.exec(http("Create new sourceData")
.post("/api/source-data")
Expand Down
2 changes: 1 addition & 1 deletion src/gatling/scala/SourceGatlingTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SourceGatlingTest extends ManagementPortalSimulation {
.get("/api/sources")
.headers(headers_http_authenticated)
.check(status.is(200)))
.pause(5 seconds, 10 seconds)
.pause(5.seconds, 10.seconds)
.feed(randomString)
.exec(http("Create new source")
.post("/api/sources")
Expand Down
2 changes: 1 addition & 1 deletion src/gatling/scala/SourceTypeGatlingTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SourceTypeGatlingTest extends ManagementPortalSimulation {
.get("/api/source-types")
.headers(headers_http_authenticated)
.check(status.is(200)))
.pause(5 seconds, 10 seconds)
.pause(5.seconds, 10.seconds)
.feed(randomString)
.exec(http("Create new sourceType")
.post("/api/source-types")
Expand Down
2 changes: 1 addition & 1 deletion src/gatling/scala/SubjectGatlingTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SubjectGatlingTest extends ManagementPortalSimulation {
.get("/api/subjects")
.headers(headers_http_authenticated)
.check(status.is(200)))
.pause(5 seconds, 10 seconds)
.pause(5.seconds, 10.seconds)
.feed(randomString)
.exec(http("Create new subject")
.post("/api/subjects")
Expand Down
2 changes: 1 addition & 1 deletion src/main/docker/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
managementportal-app:
image: managementportal
environment:
- SPRING_PROFILES_ACTIVE=prod,swagger
- SPRING_PROFILES_ACTIVE=prod,api-docs
- SPRING_DATASOURCE_URL=jdbc:postgresql://managementportal-postgresql:5432/managementportal
- SPRING_DATASOURCE_USERNAME=radarbase
- SPRING_DATASOURCE_PASSWORD=radarbase
Expand Down
2 changes: 1 addition & 1 deletion src/main/docker/management-portal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
managementportal-app:
image: radarbase/management-portal
environment:
- SPRING_PROFILES_ACTIVE=prod,swagger
- SPRING_PROFILES_ACTIVE=prod,api-docs
- SPRING_DATASOURCE_URL=jdbc:postgresql://managementportal-postgresql:5432/managementportal
- SPRING_DATASOURCE_USERNAME=radarbase
- SPRING_DATASOURCE_PASSWORD=radarbase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.radarbase.management;

import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Profiles;
import tech.jhipster.config.JHipsterConstants;
import java.net.InetAddress;
import java.net.UnknownHostException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import tech.jhipster.config.JHipsterConstants;

@Configuration
@Profile(JHipsterConstants.SPRING_PROFILE_API_DOCS)
public class OpenApiConfiguration {
@Bean
public OpenAPI customOpenAPI() {
Expand Down
18 changes: 18 additions & 0 deletions src/main/resources/config/application-api-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ===================================================================
# Spring Boot configuration for the "dev" profile.
#
# This configuration overrides the application.yml file.
#
# More information on profiles: https://jhipster.github.io/profiles/
# More information on configuration properties: https://jhipster.github.io/common-application-properties/
# ===================================================================

# ===================================================================
# Standard Spring Boot properties.
# Full reference is available at:
# http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
# ===================================================================

springdoc:
api-docs.enabled: true
swagger-ui.enabled: true
4 changes: 2 additions & 2 deletions src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ spring:
springdoc:
api-docs:
path: /api-docs
enabled: true
enabled: false
swagger-ui:
enabled: true
enabled: false

server:
servlet:
Expand Down
5 changes: 0 additions & 5 deletions src/main/webapp/app/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,3 @@ export * from './user-management/user-management.route';
export * from './user-management/user-modal.service';
export * from './admin.route';
export * from './user-management/user-mgnt-send-activation.component';
// export * from './project-authorities/role.component';
// export * from './project-authorities/role-dialog.component';
// export * from './project-authorities/role-popup.service';
// export * from './project-authorities/role.route';
// export * from './project-authorities/role-detail.component';
2 changes: 1 addition & 1 deletion src/main/webapp/app/layouts/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<span [translate]="'global.menu.admin.logs'"></span>
</a>
</li>
<li *ngIf="swaggerEnabled">
<li *ngIf="apiDocsEnabled">
<a class="dropdown-item" routerLink="docs" routerLinkActive="active" (click)="collapseNavbar()">
<i class="fa fa-fw fa-book" aria-hidden="true"></i>
<span [translate]="'global.menu.admin.apidocs'"></span>
Expand Down
5 changes: 3 additions & 2 deletions src/main/webapp/app/layouts/navbar/navbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class NavbarComponent implements OnInit, OnDestroy {
inProduction: boolean;
isNavbarCollapsed: boolean;
languages: any[];
swaggerEnabled: boolean;
apiDocsEnabled: boolean;
modalRef: NgbModalRef;
version: string;

Expand All @@ -48,14 +48,15 @@ export class NavbarComponent implements OnInit, OnDestroy {
}

ngOnInit() {
this.principal.identity().then(account => this.currentAccount = account);
this.loadRelevantProjects();
this.languageHelper.getAll().then((languages) => {
this.languages = languages;
});

this.profileService.getProfileInfo().then((profileInfo) => {
this.inProduction = profileInfo.inProduction;
this.swaggerEnabled = profileInfo.swaggerEnabled;
this.apiDocsEnabled = profileInfo.apiDocsEnabled;
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/layouts/profiles/profile-info.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ export class ProfileInfo {
activeProfiles: string[];
ribbonEnv: string;
inProduction: boolean;
swaggerEnabled: boolean;
apiDocsEnabled: boolean;
}
4 changes: 2 additions & 2 deletions src/main/webapp/app/layouts/profiles/profile.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export class ProfileService {
.pipe(map(data => {
const pi = new ProfileInfo();
pi.activeProfiles = data.activeProfiles;
pi.ribbonEnv = data.ribbonEnv;
pi.ribbonEnv = data.activeProfiles.includes('dev') ? 'dev' : ''
pi.inProduction = data.activeProfiles.includes('prod');
pi.swaggerEnabled = data.activeProfiles.includes('swagger');
pi.apiDocsEnabled = data.activeProfiles.includes('api-docs');
return pi;
})).toPromise();
}
Expand Down
3 changes: 0 additions & 3 deletions src/main/webapp/app/shared/project/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export class ProjectService {

update(project: Project): Observable<Project> {
const copy: Project = Object.assign({}, project);

copy.startDate = toDate(project.startDate);

copy.endDate = toDate(project.endDate);
return this.http.put<Project>(this.resourceUrl, copy);
}
Expand Down Expand Up @@ -66,5 +64,4 @@ export class ProjectService {
}
return jsonResponse;
}

}
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7946,11 +7946,6 @@ svgo@^2.3.0:
csso "^4.2.0"
stable "^0.1.8"

[email protected]:
version "2.2.10"
resolved "https://registry.yarnpkg.com/swagger-ui/-/swagger-ui-2.2.10.tgz#b25e7a21664e5d90bf391db30db08de41e852d7b"
integrity sha1-sl56IWZOXZC/OR2zDbCN5B6FLXs=

[email protected]:
version "4.0.0"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-4.0.0.tgz#5b425f192279e87f2f9b937ac8540d1984b39205"
Expand Down

0 comments on commit bc0eec6

Please sign in to comment.