26
26
import org .apache .shardingsphere .test .e2e .env .container .atomic .storage .config .StorageContainerConfiguration ;
27
27
import org .apache .shardingsphere .test .e2e .env .container .atomic .storage .config .mount .MountConfigurationResourceGenerator ;
28
28
import org .apache .shardingsphere .test .e2e .env .container .atomic .storage .config .mount .MountSQLResourceGenerator ;
29
+ import org .apache .shardingsphere .test .e2e .env .container .atomic .util .DockerImageVersion ;
29
30
import org .apache .shardingsphere .test .e2e .env .container .atomic .util .StorageContainerUtils ;
30
31
import org .apache .shardingsphere .test .e2e .env .container .wait .JdbcConnectionWaitStrategy ;
31
32
import org .apache .shardingsphere .test .e2e .env .runtime .DataSourceEnvironment ;
@@ -51,6 +52,9 @@ public class DockerStorageContainer extends DockerITContainer implements Storage
51
52
52
53
private final StorageContainerConfiguration storageContainerConfig ;
53
54
55
+ @ Getter
56
+ private final int majorVersion ;
57
+
54
58
@ Getter
55
59
private final Map <String , DataSource > actualDataSourceMap = new LinkedHashMap <>();
56
60
@@ -61,14 +65,15 @@ public DockerStorageContainer(final DatabaseType databaseType, final String cont
61
65
super (databaseType .getType ().toLowerCase (), Strings .isNullOrEmpty (containerImage ) ? storageContainerConfig .getConfigurationOption ().getDefaultImageName () : containerImage );
62
66
this .databaseType = databaseType ;
63
67
this .storageContainerConfig = storageContainerConfig ;
68
+ majorVersion = new DockerImageVersion (containerImage ).getMajorVersion ();
64
69
}
65
70
66
71
@ Override
67
72
protected final void configure () {
68
73
setCommands ();
69
74
addEnvironments ();
70
- mapResources (new MountConfigurationResourceGenerator (storageContainerConfig .getConfigurationOption (), databaseType ).generate (getMajorVersion () , storageContainerConfig .getScenario ()));
71
- mapResources (new MountSQLResourceGenerator (storageContainerConfig .getConfigurationOption (), databaseType ).generate (getMajorVersion () , storageContainerConfig .getScenario ()));
75
+ mapResources (new MountConfigurationResourceGenerator (storageContainerConfig .getConfigurationOption (), databaseType ).generate (majorVersion , storageContainerConfig .getScenario ()));
76
+ mapResources (new MountSQLResourceGenerator (storageContainerConfig .getConfigurationOption (), databaseType ).generate (majorVersion , storageContainerConfig .getScenario ()));
72
77
setPrivilegedMode ();
73
78
withExposedPorts (getExposedPort ());
74
79
withStartupTimeout (Duration .of (storageContainerConfig .getConfigurationOption ().getStartupTimeoutSeconds (), ChronoUnit .SECONDS ));
@@ -93,7 +98,7 @@ private void setPrivilegedMode() {
93
98
}
94
99
95
100
private String getURL () {
96
- return storageContainerConfig .getConfigurationOption ().getDefaultDatabaseName (getMajorVersion () )
101
+ return storageContainerConfig .getConfigurationOption ().getDefaultDatabaseName (majorVersion )
97
102
.map (optional -> DataSourceEnvironment .getURL (databaseType , "localhost" , getFirstMappedPort (), optional ))
98
103
.orElseGet (() -> DataSourceEnvironment .getURL (databaseType , "localhost" , getFirstMappedPort ()));
99
104
}
@@ -130,7 +135,7 @@ public final DataSource createAccessDataSource(final String dataSourceName) {
130
135
*/
131
136
public final String getJdbcUrl (final String dataSourceName ) {
132
137
return DataSourceEnvironment .getURL (databaseType , getHost (), getMappedPort (),
133
- Strings .isNullOrEmpty (dataSourceName ) ? storageContainerConfig .getConfigurationOption ().getDefaultDatabaseName (getMajorVersion () ).orElse ("" ) : dataSourceName );
138
+ Strings .isNullOrEmpty (dataSourceName ) ? storageContainerConfig .getConfigurationOption ().getDefaultDatabaseName (majorVersion ).orElse ("" ) : dataSourceName );
134
139
}
135
140
136
141
/**
0 commit comments